Thursday 25 June 2015

S3860M-S breadboard adapter

I sell on Tindie

kicad files


updated version:
- with reset button and on/off button (MFB)
- 2leds
- option to select between XS3868 and S3860M-S module
- made by
- will be sold on after test with 0402 resistors and jack (hard to find this in low quantity)

check my store on tindie:

I sell on Tindie

Wednesday 24 June 2015

SOYO-BT24G03 kicad lib and module

finaly I have time to make package module for kicad of SOYO bluetooth module SOYO-BT24G03:

lib files:
SOYO-BT24G03.dcm SOYO-BT24G03.lib

and module:

also one new smt jack PJ320B (stereo, 3.5mm) I found in my pile of scrap parts:


Friday 12 June 2015

new kicad libraries and modules

on project of bluetooth support for old vw group head units I have to try more bt modules, so I made kicad files needed to make breadbord adapter , SOYO-BT24G03 is in queue also...

MB-CM15113.kicad_mod - old module which has no uart, I made Fritzing file for this module, I try this module one more time
(library files: MB-CM15113.lib, MB-CM15113.dcm)

BLK-MD-SPK-B.kicad_mod - module mentioned on this blog, no call posible with this module or I'm lame :)
(library files: BLK-MD-SPK-B.lib, BLK-MD-SPK-B.dcm)

XS3868.kicad_mod - new module I will try, breadbord adapter files here
(library files: XS3860.dcm, XS3860.lib

am1d.kicad_mod - DC - DC convertor 5V->+-12V i have planes to use it for galvanic insulation audio part for low noise in amlifier, which is realy needed....
(library files: aimtec.dcm, aimtec.lib)

also I made some kicad modules for 3.5mm jack from ebay ....


Výsledok vyhľadávania obrázkov pre dopyt PJ-313C

vwcdpic for avr (arduino) and attiny

Porting to arduino's or AVR?

I sell on Tindie
while back I read on hackaday forums about guy who ported some C code for avr (for seeduino mega) originaly ported from k9spud vwcdpic ...

back then I was really bad in arduinos or any coding for mcus, so I was unable to make it work on normal *duino .... 

then i find this post of shyd version of emulator 

and now i'm less lame so I did it :)


for protocol read shyd post, it preaty explain everything about pulses etc ....

problem of porting avr vwcdpic code to arduino:

- ICP pin need to be accesible
- one 16bit timer (attiny hase 2x8bit timer)
- two timers with CTC (atmega8 does not have ctc)

ICP pin

basicaly external logical change interupt on pin called ICP which is directly "wired" to timer1( ICP as INPUT CAPTURE PIN), this pin is not wired on ATMEGA arduino boards (mega1280 and 2560). This is why guy on hackaday use seeduino...
On normal arduino duemilanove or UNO is ICP1 on digital pin 8, so this will work perfectly on duemilanove/uno and also old atmega8 chips.

Also its posible to reprogram code to use standard INTx interupr as I use in attinyx5 version of this code.

16bit timer

this timer is used to measuring pulses length of data send by head unit, more in post here and here.

In original code is set to tick every 0.5us, its 16bit timer, max value of 65536 which corespod to 32000something ms ~ 32second, which is fine, perfect resolution, we can surely set input buffer to zero if this timer overflow (no logical change on ICP pin for 32 seconds...)

but if we have 8bit timer like in attiny85 (255tics to overflow which is 128us if I'm not mistaken) and want to have same resolution as with 16bit timer, to avoid recalculation of tics per pulse.... we must catch overflows and count them, then just calculate pulse lenght as 255*overflows+actual timer

2 timers for timing output packets

next challenge was timing for output to head unit, lets call it packet of 8 bytes, with this timing:

50ms between pakets
at last 700us between bytes in packets (in vwcdpic is note that same head units cant store it if timing was 350us, in some other sources on net, timing is 874us ... but 700us works for me...)

in original code timer0 and timer2 are 8bit timers, in original code used for:

- 700us timing between bytes
- 50ms timing between packets and to cound seconds ... (20x50ms = 1000ms = 1s)

this is no problem on atmega168/328 but its problem on atmega8 and attiny85

atmega8 has no compare register for timer0, attiny85 hase just two 8bit timers/counters

Timer0 on atmega8

atmega has timer0 without CTC mode, no compare possible , so we must make it work other way around, we have overflow:
-  so I set OVF bit to allow execution of OVF runtime routine
- set timer to 4us tics, this make it overflow each 1024us
- initialize timer with value of 6 which make it overflow after 1000us
- in overflow routine  timer is initialize with 6 to overflow again after 1000us

Attiny85 and two 8-bit timers

timer1 is used for input capture with combination on int0 external interrupt and counting overflows... no big deal

timer0 must be used to timing of 1ms tics for seconds count and for output packets timing, so what I did was really easy, and I go to rewrite all code also for atmegax chips to use it. I set timer to tic every 1us, set compare register to be 100, so its fire compare routine every 100us. In this routine I do counting, 50 count to make original code happy ...
and to count to 7 or to 50 to make output packets timing work ...

second timing for output packets is set directly in code which handle sending packet, if it reach end, it will set 50 to wait 50ms between packets, if it just sent less then eirhts byte it set 7, so next byte is flush out after 7 overflows of timer0 = 700us

Output to headunit

output to head-unit is SPI, it's nothing new, but this didn't work for 16Mhz arduinos (simply it's to fast), so software handling of this is used. I like crystal version more over internal RC oscillators becose this is in car application where external crystal should by better, but I do not test or read any paper on this, so correct me please if I'm wrong.

also attiny has no SPI dedicated pins, it it's capable of use some internal magic to have SPI by HW but it use pin which is also INT0, and this we need... so using software here is only option

Serial comunication

Original vwcdpic used 9600bauds serial communication for PJRC player, which I do not know if it is around anymore, but it was also in avr code, so I leave it there just make it fully backward compatible, with "in compile time" configurable #define PJRC, becose this make emulator constantly send "mode" on serial line, which may toggle  "mode" on mpd  each second or so ...

also add option to support shyd version of serial communicaton to control mpd over serial with mpc and python, and receive info from mpd like mode, disc and track number. This is configurable in compile time with  uncommenting #define DISC_TRACK_NUMBER_FROM_MPD, #define JUST_HEX_TO_SERIAL and commenting out #define PJRC

attiny85 use TinyDebugSerial library which is oneway library but it didn't use any timer, so I can use both(timers).

 Mpd control

I made some changes of shyd python script to control mpd both with just hex and pjrc commands , this are on github. Also should support original pic version of vwcdpic, but I have no time to check it.

I make this pythons script handle next/previos CD which are send (as I know) only from audi chorus 1 with enabled CD input and audi concert 1.

video of all of this is here:

how to wire it?

arduino duemilanove/uno or atmega8
RADIO PIN -> arduino pin (chip pin) <- computer
     DataOut -> digital 8      (14)
       DataIn -> digital 13    (19)
         Clock -> digital 12    (18)
                        digital 0      (2)  <------------ serial TX
                        digital 1      (3)  <------------ serial Rx
RADIO PIN -> attiny pin <- computer
     DataOut -> 7
       DataIn -> 6
         Clock -> 5
                        2  <------------- serial RX


 Bluetooth... clearly, I made it here, with blk-md-spk-b module, but it has problem handling calls, so I ordered xs3868 and made kicad module and library. So next to make some breakout boards and try it.

 Next stage is implementing SOYO-BT24G03 (made kicad library, module, get AT command set ) which has support of more profiles (also address book ;) ) and also has support of sdcard and usb :) 

BM20 it will be ;)


arduino,atmegaX8,atmega8 port of  k9spud vwcdpic
port of k9spud vwcdpic with two 8-bit timers (attiny85)