... and I was using a 14M PICAXE in my experiments.
Code:
'SOMO sound module controller interface
'Version: 2A - [29/11/2009] Original code
' 3A - [28/12/2009] Pre-requisite changed to <SOMO>
'CHIP: 14M PICAXE, Firmware version 9D or higher - won't work on 9B firmware.
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'----------------
'PIN ASSIGNMENTS:
'----------------
'INPUT0 used for serial command input
'INPUT1,2,3 not used
'INPUT4 used for busy signal from SOMO module
'OUTPUT0 not used
'OUTPUT1 used for SOMO control(clock line)
'OUTPUT2 used for SOMO control(data line)
'OUTPUT3 used for SOMO control(reset line)
'OUTPUT4 used for 'Syntax Error' LED(not always used)
'OUTPUT5 used for piezo sounder(short beep for command acknowledge)
symbol control=b0 'Used for control bits - don't use for anything else
symbol dta=w6 'Data to module is a word(16-bit) value
symbol x=b5 'X marks the spot...
symbol mask=bit0 'Mask word for the shiftout proceedure
symbol MSB=$8000 'Most Significant Bit position is bit 16
symbol sda=2 'Serial data output is on pin2
symbol scl=1 'Serial clock output is on pin1
init:
high scl 'Set clock idle state high
low sda 'Set data idle state low
wait 3
gosub piezo
'dta=$015F
'gosub shiftout
high scl
low sda
start:
serin 0,N1200,("<SOMO>"),b1,b2,b3,b4'Pre-requisite bytes + command bytes
gosub piezo 'Sound piezo buzzer
b13 = b1 * 16 + b2
b12 = b3 * 16 + b4
gosub shiftout
high scl 'Set clock-line idle-high
low sda 'Set data-line idle-low
goto start 'Loop to start if no valid command byte
'================================
'CLOCK DATA TO MODULE SUBROUTINE:
'================================
shiftout:
gosub rst 'Reset module first
low scl 'Pull clock-line low
pause 2 'Start-bit time
for x = 1 to 16 'Start of shiftout code
mask = dta and MSB / MSB
low sda
if mask=0 then skipMSB
high sda
skipMSB:
if x = 16 then skippulse
pulsout scl,20 '100uS minimum pulse-width for clock or data lines
dta = dta * 2
skippulse:
next x 'End of shiftout code
high scl 'Pull clock-line high
pause 2 'End-bit time
return
rst:
low 3 'Reset module
pause 5 'Reset pulse-width as per manual ver 3.0
high 3 '"Release" reset
pause 300 'Reset to first bit wait time as per manual ver 3.0
return
'=======================
'BEEP PIEZO SUB-ROUTINE:
'=======================
piezo:
high 5 'Turn on piezo beeper
pause 150 'Wait some time
low 5 'Turn off piezo beeper
return
This code just waits for control bytes to be sent to the PICAXE at 1200 baud, and the 14M takes care of all the bit-banging etc. This works VERY well for me, and is dead easy to control with another PICAXE and a serout command.
I've also attached my schematic for you to look at how I have things wired up.
This circuit incorporates several ideas from this thread, and also the muting on the audio-out to stop clicks at the end of playback - the latter provided by 4D systems.
I'm not sure if this suits your purposes, but should give you and others something to go on, and what has been proven to work(for me) with the exception of some uSD cards...
Bookmarks