Clocking data - the best way to do it?

westaust55

Moderator
SOMO 14D is working correctly

well pulled out my SOMO 14D module, found a speaker (8 Ohm 3 Watt) and hooked up to a PICAXE 18X.

Downloaded the zip file from the 4D Systems website to have quick access to some AD4 files. Then ran the code already tried by Grogster upon which we have all been working.
Only change was different IO pin assignments (see below)

dta = $0001 gives me the first tune,
dta = $0002 thru $0004 gives me some speech extracts
dta = $0005 is another fine.

Code:
SYMBOL control	= b0 	 	; used for control bits - DONT use for anything else 
symbol dta		= w6		'Data to module is a word(16-bit) value
symbol x		= b3		'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		=3		'Serial data output is on pin2
symbol scl		=2		'Serial clock output is on pin1
symbol busy	=2		'Busy line back from SOMO 14D - not used as yet
init:
high scl				'Set clock idle state high
low sda				'Set data  idle state low

wait 5		'Allow everything to start before sending any commands


start:		'Test routine - select file 0001.ad4 and start playback
	 dta	= $0001	'Select file # 0001.ad4 from micro-SD card
	 gosub shiftout	'Tell that to the module
	 high scl		'Set clock-line idle-state high
	 low sda
 end


'================================
'CLOCK DATA TO MODULE SUBROUTINE:
'================================

shiftout:
  low scl		'Pull clock-line low
  pause 3		'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,30
  dta = dta * 2
skippulse:
  next x		'End of shiftout code
  high scl		'Pull clock-line high
  pause 3		'End-bit time
  return

Will now proceed to convert a range of mp3 files and test a little more thoroughly.


Had a giggle at 4D Systems 0001.ad4 file which says (roughly):
" Hello World. This is 4D Systems. You are using the SOMO 14D module.
Please make sure that you have connected your SOMO 14D module as shown in the connection diagram . . ." :rolleyes:

Bit like those instruction manual that once you have ripped open the box and pulled out the goodies, the instruction manual states:
" please read these instructions on how to unpack your equipment" :eek:

EDIT:
further information:
1. I am running the SOMO 14D module at 3.3V
2. tried minimising the delays: reduced the PAUSE 3 to PAUSE 2 and the PULSEOUT from 30 to 20 and still works okay
 
Last edited:

westaust55

Moderator
SOMO 14D code to play a series of sound files

Took the code and did some further adjustments.

I found that:
1. the busy signal is not made high for around 5 to 7 msec after an audio filename is sent
2. the SOMO module is not ready to accept the next audio filename for around 5 to 7 msec after the busy line goes low.

Have not verified yet if this also applies to sending other commands such as volume level but took the precaution for now in the following code.

This code will play the first six audio files consecutively, waiting for each to complete before starting the next file. I have shuffled a few variable allocations and labels around from the earlier code worked upon with Grogster (so beware)

Code:
SYMBOL control		= b0 	 			; Used for control bits - DONT use for anything else 
SYMBOL mask		= bit0			; Mask word for the shiftout procedure
SYMBOL index		= b1				; Bit counter for shifting data to SOMO 14D
SYMBOL song		= w1				; Pointer to the required song file
SYMBOL dta		= w2				; Data to send to SOMO 14D module is a word(16-bit) value

symbol MSB		= $8000			; Mask for the Most Significant Bit = bit 16

symbol sda		= 3				; Serial data output is on pin3
symbol scl		= 2				; Serial clock output is on pin2
symbol busy		= pin2			; Busy line back from SOMO 14D

;=========================================
;Initialisation
;=========================================

Init:
	high scl					; Set clock to high idle state
	wait 5					; Allow everything to start before sending any commands

;=========================================
;Main Program
;=========================================
Main:							
	For song = 0 to 5				; Lets play the first 6 audio files (0001.AD4 to 0005.AD4)
	
		dta = $FFFF - w0			; set a volume level - slightly quieter for each file
		GOSUB Send2SOMO
		GOSUB Holdtilldone
		
	 	dta	= song			; Provide the .ad4 file number on the micro-SD card
	 	GOSUB Send2SOMO			; Pass the filename/number to the SOMO 14D module
		GOSUB Holdtilldone			
	NEXT song
END

;=========================================
;CLOCK DATA TO SOMO-14D MODULE
;=========================================

Send2SOMO:
	LOW scl					; Pull clock-line low for a start
	PAUSE 2					; Start-bit time >= 2msec to indicate a start of command
	FOR index = 1 TO 16			; loop for each of 16 bits of filename/number
  		mask = dta AND MSB / MSB 	; ascertain if next bit is 1 or 0
		LOW sda
		IF mask = 0 THEN SkipMSB	
		HIGH sda				; if bit is 1 set data high high
SkipMSB:
		IF index = 16 THEN Skip16th	; Skip here as 16th bit is clocked out at the end
  		PULSOUT scl, 20			; Create 200usec clock pulse for the current data bit
  		dta = dta * 2
Skip16th:
	NEXT index					; Go back for the next bit till all 16 sent

	HIGH scl					; Pull clock-line high which clocks out the 16th data bit
	PAUSE 2					; End-bit minimum time >= 2msec for STOP indication
	RETURN

;=========================================
;WAIT UNTIL THE COMMAND IS COMPLETE
;=========================================

Holdtilldone:
 	PAUSE 10				; Need at wait briefly as it seemingly takes ~5-7msec for the busy line to go high = busy
	IF busy = 1 THEN Holdtilldone
	PAUSE 10				; Need to wait briefly as it seemingly takes ~5-7msec after busy released before SOMO ready for new instruction
	RETURN
 

Grogster

Senior Member
That's typical...
Works for you, but not for me. ;)

I will watch this thread for the next few days, but as goom suggested, I have moved onto something else for the moment, just to give myself a break from it, or I will certainly drive myself insane...

@ goom - checked card, and files are 0001.ad4, 0002.ad4, 0003.ad4 as instructed.
Will try your $000C idea - will put a 0450.ad4 file in the card and try to play that tomorrow.

I HAVE NEVER CONNECTED THE RESET LINE - I see that westaust55 did - perhaps this is my problem? Perhaps I need to issue a reset pulse first?

QUESTION: Why do devices like this even bother to communicate using bit-banging methods? Why not plain old serial comms or even I2C? I'm not aware of any PIC beyond entry-level these days which can't send/receive serial comms or use the I2C bus.

This method, to me, is just confusing, frustrating and more then a little difficult to get working.
If the module used serial or I2C, it's a known protocol, and talking to the device should be so simple, you could just about do it with your eyes closed.

...just a thought...
 
Last edited:

hippy

Technical Support
Staff member
QUESTION: Why do devices like this even bother to communicate using bit-banging methods? Why not plain old serial comms or even I2C? I'm not aware of any PIC beyond entry-level these days which can't send/receive serial comms or use the I2C bus.

This method, to me, is just confusing, frustrating and more then a little difficult to get working.
If the module used serial or I2C, it's a known protocol, and talking to the device should be so simple, you could just about do it with your eyes closed.
This SPI-style, data plus clock, should be just as simple to use as serial or I2C, and often more so. It's an equally known protocol style.

The reason for choosing this protocol is that it can be implemented by almost anything and without the complexity of polarity and timing requirements of serial and the complexities of the I2C protocol. Serial and I2C are only 'so easy' on the PICAXE because the protocols are all handled for you, but even then we see interfacing problems rising on this forum with serial using Txxxx baud rates. If you had to implement all protocols yourself you'd appreciate why SPI-style is often chosen; it's not a 'bad choice' in any way.
 

westaust55

Moderator
I HAVE NEVER CONNECTED THE RESET LINE - I see that westaust55 did - perhaps this is my problem? Perhaps I need to issue a reset pulse first?

[/I]
Actually it is the BUSY pin and not the RESET pin that I have utilised.

Not so critical if playing audio files and you do not care if a file has finished before you start the next. Sending a new file number immediately starts playing the new file unless you check the BUSY line.

While my module is playing the correct file number relative to what the PICAXE program sends, I am after some testing this evening finding that there are some occasional "hiccups".

For example:
1. it might correctly play files 0 to 4 then stalls at file 5.

2. I found when I had an invalid file name (eg 000A.ad4) that it would play file 0000.ad4 then the programming counted through to about song/file 19 checking the busy pin before it actually resumed with audio output.



In line/response to goom's questions/comments,

sending $0009 is the same as sending $9 or 9 (decimal) or %1001.
Likewise $0013 is the same as $13 or 19 (decimal) or %0010011.

For all variants of the number format:
- must be stored in a (16-bit) word variable as Grogster is doing.
- pass those 16 bits of data to the SOMO 14D audio module.
 
Last edited:

Grogster

Senior Member
This SPI-style, data plus clock, should be just as simple to use as serial or I2C, and often more so. It's an equally known protocol style.

The reason for choosing this protocol is that it can be implemented by almost anything and without the complexity of polarity and timing requirements of serial and the complexities of the I2C protocol. Serial and I2C are only 'so easy' on the PICAXE because the protocols are all handled for you, but even then we see interfacing problems rising on this forum with serial using Txxxx baud rates. If you had to implement all protocols yourself you'd appreciate why SPI-style is often chosen; it's not a 'bad choice' in any way.
Okey dokey - I see now what you are saying. Makes sense - thanks. :)
 
Last edited:

Grogster

Senior Member
Hi everyone. :)

- RESET pin on the SOMO will not work via potential divider from the PICAXE pin. It ignores the reset commands from the 18X, unless I directly connect the reset pin on the module, to the output pin on the 18X, and run the 18X from the same 3.3v supply as the the SOMO module.

Have not yet tested the 0450.ad4 or $000C(12 dec)idea, but am off to do that now.

It is strange how it is working in reverse for me.($0009 plays #1, $0008 plays #2, $0007 plays #3 etc...)
 

goom

Senior Member
Thanks westaust55 for taking the time to experiment with, and report on your findings. This has answered many of the questions that I had. It was particularly useful to learn that issuing a new play command stops the existing playing file, and then proceeds to play the new one. Is this nore-or-less instantaneous?
It's a pity that the datasheet is not a bit more comprehensive.

Good idea posting on the 4DSystems forum (http://4d.websitetoolbox.com/post?id=3780589).

I am now almost 100% sure that the unit will suit my immediate needs (a sailboat race countdown timer). I built on before using an ISD2560 sound chip, from which I called up a sequence of short sound clips (as low as 900ms length). I may try the same strategy with the SOMO-14D. Do you think that it will be possible to call up 900ms sound files at 1 second intervals? If not, I will just have to put together some 1 minute long sequences instead, which is not a problem with up to 2GB of storage available.

I am also thinking of using the SOMO as the basis for a model boat sound system. It should be quite simple to play various sounds based on input from a spare RC channel.
 
Last edited:

Grogster

Senior Member
I 2nd that goom - Re: westaust55 trying out his one and reporting back. I also want to thank all others who post here - all knowledge is power!!! :D

hippy has come to the table many times on this thread to offer code variants, and this too has been very useful for experimentation, so thanks hippy!!! :)

I note that when you use the MP3 to AD4 converter tool, it only converts one channel if the MP3 is stereo.

@ westaust55 - are you powering the PICAXE from 5v and using the resistors on the clock and data lines, or are you directly connecting the PICAXE to the SOMO and running them both on 3.3v?
If you are using reistors and a 5v PICAXE supply, what value are you using for the resistors?


EDIT: Tried running PICAXE on 3.3v and directly connecting to clock and data, but same problem.

Added 0012.ad4 and 0450.ad4 to the SD card, now when fired up in button mode, won't play anything when you press NEXT button(used to play 0001.ad4), 2nd press and it plays file #10, then #1, then #2, then #3 etc. File #10 would not play(although it was on the card) before even in button mode. It would get to #9, then skip #10 and go back to #1. Module flat-out refuses to play anything over #10 - it won't play #12($000C) or #0450 which I added to the card this morning - it can't see these files either in button or PICAXE methods. There is no file #11, or file #13-439, but one would hope that it would have the intelligence to just skip to the next file in the list - you would not think that sequenctial numbers would HAVE to be there, in order for it to play the next highest number. *sigh* Starting to lose interest in this module.
 
Last edited:

Grogster

Senior Member
OK, playing with the demo AD4 files now, to see if I have any joy with them.

Sending $0000 plays file #0 - Good :)
Sending $0001 plays file #0 - Not good :(
Sending $0002 plays file #1
Sending $0003 plays file #1
Sending $0004 plays file #2
Sending $0005 plays file #2
Sending $0006 plays file #3
Sending $0007 plays file #3
Sending $0008 plays file #4
Sending $0009 plays file #4
Sending $0010 plays nothing
Sending $0011 plays nothing

Cannot play the last file(0005.ad4) no matter what.
Every time the PIC was programmed with a different number to send, I cycled the power to make sure that something was not getting stuffed up by the power being on all the time, so it should have been a cold-start each time.

If I start the module in button-mode, pressing PLAY/PAUSE starts plaing file #0 - good.
Pressing NEXT at this point, results in the module jumping to file #5 - not good.
From that point on, pressing next advances one song in the wrong order, so the sequence from startup using PLAY then the NEXT button is: 0000.ad4, 0005.ad4, 0004.ad4, 0003.ad4, 0002.ad4, 0001.ad4

EDIT: PREVIOUS and NEXT pins do the reverse of each other. If I put the button for next, onto pin1 of the module(previous button), then pressing "Previous" triggers a next operation. IE: The "Previous" button is next, and the "Next" button is previous... *sigh*

PLAY/PAUSE does not - it is PLAY/STOP. Pressing PLAY/PAUSE during playback stops playback, but does not pause it. Pressing PLAY/PAUSE again results in the module starting playback of that file again from the beginning - it does not resume from where it was paused. Not that this really matters to me, but am posting it for other people's information mainly.
 
Last edited:

westaust55

Moderator
I have just started a new thread at the 4D Systems forum with my findings and problems.
http://4d.websitetoolbox.com/post?id=3826190&pid=36213966#post36213966

I found that I could :
1. play the 6 ad4 files (0000.ad4 to 0005.ad4) downloaded from the 4D systems website correctly.

2. could consistently play my own song files from 0000.ad4 to 0005.ad4.

3. after shuffling some files (mainly swapping file 0005 with another having a higher value), I can consistently play files 0000 to 0006.

4. with around 30 audio files on the SD card, if I try to play all files in sequence, it will play 0000 to 0006 and typically scan over the rest - is this a result of the BUSY line not being set? Very occasionally it will resume to play more files sequentially starting at a higher number such as 0019.sd4.

Will report back when I have some feedback form 4D systems or others and have some consistency in operation of the SOMO module.
 
Last edited:

westaust55

Moderator
I 2nd that goom - Re: westaust55 trying out his one and reporting back. I also want to thank all others who post here - all knowledge is power!!! :D

@ westaust55 - are you powering the PICAXE from 5v and using the resistors on the clock and data lines, or are you directly connecting the PICAXE to the SOMO and running them both on 3.3v?
If you are using reistors and a 5v PICAXE supply, what value are you using for the resistors?
I am running the PICAXE 18X at 5Vdc on this occasion.
While I do note that the datasheet indicates series resistor of 100 to 470 Ohms, I am actually using 4.7 kOhm.
I am playing files numbered 000 to 0006 correctly and consistently so it is seemingly not a circuit issue, and I do not think a programming error.

There is no file #11, or file #13-439, but one would hope that it would have the intelligence to just skip to the next file in the list - you would not think that sequenctial numbers would HAVE to be there, in order for it to play the next highest number.
Not sure there is enough intelligence on the SOMO card. When I in error named some files as 000A.ad4 through 000F.ad4, it played 000.ad4 then jumped to file 0014.sd4
 
Last edited:

goom

Senior Member
Is it possible that the BUSY pin is in a high impedance state when not high? A pulldown resistor may be required. However my (faulty) unit does seem to indicate that it can both source and sink current.
Do you have an LED indicator connected? It's probably a good troubleshooting guide. Maybe worth having 2 LED's to indicate both high and low.
Depending on what type of input pin you are using on the -18X, the BUSY output voltage may be insufficient to register as a high. However, since you are using Pin2 (TTL type), this should not be an issue.

You may have to wait a while before getting a response on the 4DSystems forum (not like the almost instant responses that we have come to expect here). However, I did get responses when I posted there.
Since there are now two people experiencing problems with playing the correct files, it may indicate a fault in the SOMO logic which tranlates the word command into a command to read the appropriate file.
 

Grogster

Senior Member
Using the code in post #41 by westaust55, the module does not respond at all.
I will try another module, as I have four - perhaps my 1st one was crook?
 

Grogster

Senior Member
Here is my latest attempt.
It uses the PICAXE to pulse the NEXT button input(labeled as PREVIOUS on the datasheet, I kid you not...)

This works well, and I can play any file I wish by changing the value of song

Code:
symbol x=b1		'X marks the spot...
symbol song=b2	'Variable for the song number you want

high 1		'Idle NEXT pin high
high 2		'Hold reset off
wait 2		'Wait for module to fire up


song=1		'Pre-select song #1
gosub test		'Find it and play it!
wait 10		'Play 10s of song then move to the next
song=5		'Pre-select song #5
gosub test		'Find it and play it!
wait 10		'Play 10s of song then move to the next
song=3		'Pre-select song #3
gosub test		'Find it and play it!
wait 10		'Play 10s of song then finish

high 1		'Once finished put NEXT button idle-high
high 2		'Once finished put RESET pin idle-high
end			'And so we come to the end...
  
  
  

'==========================================================
'"CLOCK" THE 'NEXT' BUTTON PIN TO SELECT THE SONG YOU WANT:
'==========================================================
  
  
test:
  gosub reset	'Reset module before doing anything else
  for x=1 to song	'Pulse the previous button loop
   low 1		'"Push" the next button
   pause 85		'Time for module to "See" the push
   high 1		'"Release" the next button
   pause 85		'Time for module to "See" the release
   next		'Goto the next push
  return
  
  
reset:
  low 2		'Reset module
  pause 80		'Wait for module to "See" the reset
  high 2		'Idle-high reset pin
  pause 250		'Wait for module to finish resetting itself
  return
Not exactly pretty, but it works.
File #0 is not an option on this code, as you can't have some code that says for x=0 to 0, for example, but I will just not use file #0, and there is no problem.

This code is only for testing, as you can see.
PICAXE run from 3.3v, and RESET and NEXT directly connected.
Probably only suitable for less then 50 files or so, or the number of pulses to get to the file would equate to a long delay - that's why I was hoping to be able to use the data method, but it just refuses to work for me... :(
 
Last edited:

westaust55

Moderator
A brief report without advancement.

I tried increasing timing/delays in various parts of my code and even added a specific command to stop after each song was played.

Once only was file 0007.ad4 played. But in general cannot get past file 0006.ad4 in any reliable way. :(
 

Grogster

Senior Member
Well, I have purchased a 2nd-hand iPod Nano, and a docking connector breakout PCB, and plan to tinker as per the AXE119 instructions. I will keep watching this thread until the bits arrive, but perhaps I will have better luck using the iPod method?

Hope, hope...
 

westaust55

Moderator
Can't you get advice from the Manufacturer?
I did yesterday (Aust time) post my code and queries on the 4D forum.


Lunchtime today I rang Atilla at 4D Systems. Their Technical Engineer is looking at my post to see if they can identify/overcome the problems being experienced.

Following my past emails relating to their website, 4D has been proactive and has now updated their website with respect to the access for users seeking files in relation to their modules.


So for now it is a combination of awaiting any response from 4D about the SOMO 14D module and in the meantime some further experimenting in case we can come up with a solution here if it is down to timing issues.
 
Last edited:

westaust55

Moderator
Yesterday 4D Systems has posted some new datasheets and audio file conversion software on Wednesday (25th) on their website.

Datasheet now has some timing details for:
- the Busy signal (which are longer than I have been previously trying with).
- a recomemded circuit to avoid noise clicks that can occur between playing audio files.

Have not received any direct response to my phone calls and queries posted on the 4D forum but might dig out my SOMO-14D and do some more experiements tonight based on the new infomation/software.
 

Grogster

Senior Member
Excellent update. I am just checking in here to see how things are going. Please do post back with anthing you discover westaust55, as I would love to be able to get these modules working. :) I guess other members following this thread also think the same way...

About to tinker with the iPod thing(as my pod breakout PCB thing-y's arrived the other day), but any problems etc with that, will be in a new thread.

I see on the updated datasheet, that they have changed the NEXT and PREVIOUS button pin assignments, so it was not just me imagining it!!! :p I also note that they now mention that clock and data pulses must be 100uS minimum - didn't we experiment with that kind of timing earlier in this thread? I'm sure we did...
 
Last edited:

Grogster

Senior Member
Having MUCH more luck with the new code now that we have some accurate timings from 4D.

I have been able to play any file number I want now. :)

The experiment continues, but we are on a winner here...
The critical thing seems to be the 100uS pulsout along with the 2ms start/stop bit - any combination OTHER then that, and the timing is wrong(as far as the SOMO is concerned I guess), and it won't work.

My working code(with remarks):
Code:
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=b3		'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 idel state low
 wait 5		'Allow everything to start before sending any commands

start:		'Test routine - select file 0010.ad4 and start playback
 dta=$000A		'Set playback filenumber to decimal 10($000A HEX)
 gosub shiftout	'Tell that to the module
 high scl		'Set clock-line idle-state high
 low sda		'Set date-line idle-state low
 
 
 end




'================================
'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,100	'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 4		'Reset module
  pause 5		'Reset pulse-width as per manual ver 3.0
  high 4		'"Release" reset
  pause 300		'Reset to first bit wait time as per manual ver 3.0
  return
 

goom

Senior Member
I received a replacement SOMO-14D to replace my "defective" one. It was just the same as the first (would not work). I bought yet another uSD card (the third one, a ScanDisk 2GB), and started to have some success. The lesson here is that not all memory cards are created equal. Both Kingston amd noname 2GB units were apparently incompatible. The revised datasheet does warn about possible incompatibility, but fails to give any clues as to which cards do or do not work.
Which uSD cards are you using Grogster and westaus55?

I have found the coding for transmission of the clocked serial data trivial in comparison to other issues. Here is my latest code:
Code:
'PICAXE-18X connections are:
' Leg 1 (In2) Hold/Race switch (10K to ground, switch to 5V)
' Leg 2 (Serial out) NC 
' Leg 3 (Serial in) Tie to ground through 10K resistor
' Leg 4 (Reset) Tie to +5V through 4.7K, switch to ground
' Leg 5 (Ground) Negative of battery
' Leg 6 (Out0) Bi-color status LED through 310 ohm resistor 
' Leg 7 (Out1) NC
' Leg 8 (Out2) NC
' Leg 9 (Out3) NC
' Leg 10(Out4) Leg 4 (DATA) of SOMO-14D thru 470 Ohm
' Leg 11(Out5) Leg 3 (CLK) of SOMO-14D thru 470 Ohm
' Leg 12(Out6) NC (but used as dummy pause/pulse output)
' Leg 13(Out7) Leg 10 (RESET) of SOMO-14D thru 470 Ohm
' Leg 14(V+) +5V
' Leg 15(In6) Tie to ground (or +5V)
' Leg 16(In7) Leg 5 (BUSY) output from SOMO-14D
' Leg 17(In0) Countdown time select
' Leg 18(In1) Run/Pause (10K to ground, switch to 5V)
symbol Dat = W0 'Data to send to SOMO-14D
symbol WBT = 500 'Time to wait between playing sound files
symbol Pout=20 'Set clock pulse to 200us (at 4MHz)
symbol Pout_start=200 'Set start/stop clock pulse to 2ms (at 4MHz)
symbol Temp=b2
#Picaxe 18X
 
high 5 'Clock line is high initially
'low 7 'Hard reset of SOMO-14D (probably not needed)
'Pause 500
'high 7
Pause 1000 'Wait for stable startup of SOMO (may not be needed)
Dat=$FFFF 'Soft reset of SOMO-14D (may not be needed)
gosub Send_Data
pause 1000
Dat=1
gosub Send_Data 'Play audio file 0001.ad4
if pin7=1 then gosub Busy'Wait for BUSY line to go low
pause WBT 'Wait 1/2 second before playing next file
Dat=0
gosub Send_Data 'Play audio file 0000.ad4
if pin7=1 then gosub Busy'Wait for BUSY line to go low
pause WBT 'Wait 1/2 second before playing next file
Dat=2
gosub Send_Data 'Play audio file 0002.ad4
if pin7=1 then gosub Busy'Wait for BUSY line to go low
pause WBT 'Wait 1/2 second before playing next file
end
Busy:
loop0:
if pin7=1 then loop0 'wait for BUSY line to go low
pause 10 'wait for SOMO to be ready to receive next command
Return
Send_Data:
low 5
pulsout 6,Pout_start 'Pause 2ms by pulsing dummy pin (needs >2ms low start clock level)
for Temp=1 to 15 'Loop through first 15 bits
outpin4=bit15 'Set data to MSB
pulsout 5,Pout 'Clock high for 200us to latch data on pin1
pulsout 6,Pout 'Pause 200us by pulsing dummy pin (low clock)
Dat=Dat*2 'Shift left to get next significant bit
next Temp
outpin4=bit15 'Set last data bit
high 5 'Clock idles high after last bit sent
'pulsout 6,Pout_start 'Pause 2ms by pulsing dummy pin (needs >2ms high stop clock level)
pause 20 'Ensure 20ms before next command issued and for BUSY high to establish
Return
return
I have been experimenting with different .wav file bit rates, but am still not able to play a series of files reliably. Currently, I am unable to get any file to play to the end. They all terminate prematurely, even the demo files from 4DSystems. Some play to about 1/2 way through, some considerably less. I have tried reformatting the card (many times). Any ideas or suggestions? I will try the updated conversion utility, but it seems to be an issue with the SOMO-14D being unable to read files correctly as others have also discovered, albeit with different symptoms.

The slow or complete lack of response from 4DSystems tehnical support concerns me. The product has great potential, but seems to have been released prematurely with insufficient testing and documentation.

I will post again if and when I make any progress.
 

westaust55

Moderator
I bought yet another uSD card (the third one, a ScanDisk 2GB), and started to have some success. The lesson here is that not all memory cards are created equal. Both Kingston amd noname 2GB units were apparently incompatible. The revised datasheet does warn about possible incompatibility, but fails to give any clues as to which cards do or do not work.
Which uSD cards are you using Grogster and westaus55?
Mine is a Kingmax brand uSD card.

Will have a "play" again this my SOMO shortly and report back . . .
 

Grogster

Senior Member
@ goom - that's interesting what you say, as once I changed the pulsout to 100 and the pauses for the start/stop bits to 2ms, everything is working - and this is still on the exact same module which WOULD NOT work before, and the exact same uSD card and exact same collection of files.

My card is a Kingston 1GB one.
Perhaps the module does not like cards bigger then 1024MB?
I would be interested to see what happens with your module, if you had a 1GB card to try out with it.

I also thought it was an odd thing to say in the new manual, about certain brands of uSD card just not working - that does not add up to me. So long as you can write the files to the card, reading the data back is considerably less stressful to the card(then writing), so that's a strange thing to put in there. Frankly, it reads like a cop-out for anything they can't explain if a certain card won't work, but in this day and age...

I have had my module occasionally drop a song in the middle of playing it, as you have.
It only seemed to do that with songs which were very loud - I put an 18R resistor in series with the SP+ line from the module, and the problem has vanished - perhaps the audio output stage was getting a bit overloaded/overheated and the module skips songs to help things cool off?

@ westaust55 - out of interest, what capacity card are you using for your testing?

One thing I have noticed during my testing today, is that if you switch on a light, the module will skip to the next track. This seems to be a PICAXE issue though, cos if I disconnect the CLK, DTA and RESET lines, refire the module, and manually start playback, then switch on the light, it does not skip.

The problem with this, is that you can't put ANY cap across the output of the 5v regulator feeding the PICAXE - if you do(even something as small as 100n), then the SOMO won't play the correct file. I don't have an explination for this at all, but try it for yourselves and let me know how you get on there - take all the caps of the 5v side of the regulator and see if your modules work then.

Kinda annoying, as I always like to have at least 100n across the 5v supply to the PICAXE right by the PICAXE chip itself, but as I say - do that, and in my case, the module plays file 4 instead of file 6 - remove the 100n and it plays the correct file every time. I wonder if life in general is supposed to be this difficult?(rhetorical!)

EDIT: - Fixed that problem with the light-switch thing by removing the LED's on the DTA, CLK and RESET lines - that done, I can put the 100n back across the PICAXE supply, and the correct file plays, and the light switch does not much it up anymore either - LED's must have been doing something to confuse the issue...

EDIT_2: - Just sucessfully played file #250($00FA) no problems now. There are technically 21 files on the card at the moment; 20 files named 1-20, and this last one named 0250.ad4. Things are going very well(for me) at the moment. ;) I hope it will last...
 
Last edited:

westaust55

Moderator
@ Groster:
My card is a small 64MB uSD card.

wrt your code, I note also in the new datasheet that the pulse duration for each bit being entered is specified as >= 100uSec (was >= 200usec).

Your program line: pulsout scl,100 is 100 x 10usec = 1000usec.
Your program should (?) work with a much shorter value.
suggest give a try with - pulsout scl,10
but a pulsout scl,20 would be a "safer" value long term (ie not right on the min limit).

mind you relative to file durations of seconds or minutes, the time to get the filename transferred is just a few msec's.

= = = = = = = = = = = = = = = = = = = = = =

@all,

Okay initially tried playing further with timing alone but no further success.
In most cases the new minimium time setting were half what was in Rev 2 of the datasheet.

Mine or Grogster's code played files 0 to 5. Select any higher number and nothing . . .

I am using the busy line to monitor for end of playing a file and have not observed that tunes/files are cutting out early. They are playing to the end each and every time.

Now while the 4D Systems website has KINGMAX as acceptable for their OLED cards, I note that in response to goom's post on their website forum that they have only tested the SOMO module with Sandisk and Kingston.


EDIT:
Okay I had also noticed that the new revision of the SOMO datasheet stated to format the uSD card and put all new files on each time rather than adding new files, but . . . I had already been doing that (and mentioned so to 4D systems).

But I also noticed that the mp3 to ad4 converter software has ALSO been updated.

I have just re-converted the 30 test audio files I am working with from mp3 to ad4 format and put 11 as a starter onto the uSD card.
Most of my files were originally sampled at around 250kbits/sec. I have tried previously with "original" and 12k bps sample rate for the converter with no chnage. This time I have just re-converted and used the 12k bps sample same.

(used 11 song that had not been played at least 100 times :eek: already to keep my princess happy - there is only so many times one wants to listen to the same song :rolleyes: )
and the . . Yahoo . . . it played all 11 in sequence without a hiccup.

Have now re formatted the uSD card and put the full 30 files onto the card.
Playing through them right now . . . . it has gone from 0 to 8 and still going as I dash off for a while :)

Starts to suggest it is down to the file conversion process rather than our program.

will advise further once I have more successful passes thru the full 30 songs
 
Last edited:

Grogster

Senior Member
@ westaust55 - you're quite right about the pulsout, I got that wrong. For some reason, I thought that pulsout was in single units, 100 being 100uS. I will change it and see what happens. :)

But I also noticed that the mp3 to ad4 converter software has ALSO been updated.
Not from what I can see.
Link takes you to the software of July 2009, version 1.3.0, which is the version I have always been using - it's no different at all. Did you get your copy from another link?
 
Last edited:

westaust55

Moderator
@ westaust55 - you're quite right about the pulsout, I got that wrong. For some reason, I thought that pulsout was in single units, 100 being 100uS. I will change it and see what happens. :)


Not from what I can see.
Link takes you to the software of July 2009, version 1.3.0, which is the version I have always been using - it's no different at all. Did you get your copy from another link?
Yes you are correct. 4D Systems have given a misleading indicator by changing their front page for the SOMO module. See attached:

Notwithstanding same software, at this time my code is back to the original version and I am seeing much better results so far and only new thing is that I have today re-converted the same set of mp3 files for about the 6th time (5 times were about 2 weeks ago).

I had noticed once before (2 weeks ago) that I could not get past file 0005.ad4 and when I swapped file 0006 with another by renumbering, I could then play the extra file.

As such, at this instant in time, it seems that getting a good set of ad4 files is at least a significant part of the process.

At I type this now, the program is on a third pass through the same set of 30 songs and currently at song 0011 and still going well . . . .

now about to dash out the door for the evening more more tomorrow.
 

Attachments

Grogster

Senior Member
@ westaust55 - Re: Link - go figure... ;)

Yes, if I change the pulsout to 20, it is still working fine.
Note that I now reset the module during the shiftout routine - perhaps this is why things seem now to be working for me?

I have files all over the place now - 20 or so in the 000-020 range, then groups of songs from different bands within other number groups: AC/DC at group 250-300, ZZ TOP at group 325-400, STATUS QUO at group 410-425, BILLY CONNOLLY at group 450-500 to name a few. Not all numbers are used, but they are grouped like this(and written down on paper!). I can access any number file anywhere in the card now - probably should go to bed as it is quarter to one in the morning, but enjoying this thing now that we've got it working. :D

Spoken word, such as the Billy Connolly, is fantastically clear via this module - you can hardly tell the difference from the master CD.

The converter software only converts one channel of the stereo though, so for a "True" audio image via this module, you need to convert any stereo tracks to mono BEFORE converting them via the tool - no major pain, but a bit of a pest that you have to do it at all, and that the converter tool does not do that for you...

Hardware wise, the only things I have changed are:

- Removed diagnostic LED's on CLK, DTA and RESET lines(kept 330R series resistors)
- Added 100n cap across PICAXE(as close as possible) to filter out PSU noise
- Added 470uF/16v cap across SOMO supply, as close to module as possible
- Added transistor circuit as described in rev 3.0 of the manual for the SOMO
- Added 100n cap across SOMO supply, in parallel with the 470uF/16v
- Added RESET line control via PICAXE -- SOMO is reset before selecting any file

That's all I can think of for now.

See ya all in the morning! :)
 

goom

Senior Member
Inspired by one of Grogster's coments, I disconnected the 42 Ohm speaker, and instead used the AUDIO output into an amplifier. Now the files play from start to finish. Reconnect the speaker, and the files all terminate prematurely - most odd.

I am powering both PICAXE and SOMO from a common 3.6V supply using 5V regulated supply through 2 silicon and one germanium diode. 10uF and 0.1uF capacitors across the 3.6V supply. If I remove both capacitors, the partial playing problem came back. However, I have been unable to repeat this - files now play to the end regardless of the prescence or absense of capacitors - most odd.

I decided to retry the 42 Ohm speaker with the BUSY LED disconnected. No files would play. Removed the speaker, still nothing. Restored the LED connection, still nothing. Cycled the power, still nothing. Removed and reinserted the uSD card, and now it works again - most odd.

From my experience and that of Grogster, it does appear that the SOMO is somehow very sensitive to power input quality, and output load at the speaker and BUSY terminals.
 

Grogster

Senior Member
I would want to see you try using a 3.3v regulator for the SOMO - I don't trust the diodes method, although it is certainly a very cheap method.

I tried various combinations of diodes, with various capacitors across the tail(lower voltage) end and GND to see what voltage I got, and it was unreliable. With no cap, voltage stayed at 4.99v(supply from 7805 regulator). With a cap on the "Output" of the diode and GND, the voltage drops down, but still stayed around 3.9v even with 4 4007's in series.

I tried powering the module from five diodes and the cap, which was about 3.5v, but the module flatly refused to do ANYTHING.

Since I started running it from a 3940 regulator fed from the 5v regulator, everything seems to be working - at least for me and at least for now.

You could use any suitable 3.3v regulator - I just happen to have about 20 3940's left over from a bulk order of them, so I am using them.
 

goom

Senior Member
Thanks Grogster, good idea. I have now installed a 3.3V switching regulator (DE-SW033). So far I have been able to play 6 files consecutively without any problems. Tried the other two uSD cards again, but they remain "incompatible". Also no problems with the speaker connected directly. As you surmised, a good solid power supply appears to be essential.
The PICAXE-18X appears to be quite happy at 3.3V, although I believe that this is below the recommended minimum voltage.

I'm currently using 2ms for the start and stop clock, 200us for clocking the data.

One thing that I previously tried as a troubleshooting measure was to try different bit and sampling speeds.
12, 16 or 32 kHz at 16 bits all work fine.
Any sampling rate with 8 bits results in the file playing at 2x speed. So, another bit of information - don't use 8 bit .wav files.
 

westaust55

Moderator
SOMO 14D Success

After some extensive testing today for the SOMO 14D and a quick dash to the shops, I seemingly have success . . .

Rule No 1 = Use a Sandisk or Kingston uSD card – these are the type 4D systems indicated they had tested with in response to goom on the 4D Systems forum.



I was still only having limited success with a Kingsmax memory card. Some history:

1. Similar to Grogster, I had added an electro capacitor (220uF in may case) across the SOMO power supply pins.

2. I had been running the PICAXE 18X from a 5V regulated supply and the SOMO module from a 3.3V regulated supply and even changed the PICAXE to 3.3V as well.

3. I had even tired adding 5 ohms resistance in series with the 8 Ohm speaker and not operating at max volume.

While I was having better success than previously, the SOMO would mostly play to songs 000 to 0013 and then, if the last song (highest number) on the memory card was included in the program list to be played, then and only then the SOMO play that last song.

So at great expense, I went out today and bought a 2GB Sandisk uSD card :eek: (okay . . . really went out for some plants for the garden and took the opportunity to get a new memory card while out – and yes . . . the plant are already in the ground :) ).



Copied an earlier set of ad4 files that had not worked beyond song number 0005.ad4 onto the new Sandisk 2GB memory card (formatted FAT16 of course).

The whole set of songs played perfectly right through. Takes a while to play thru 30 or more files when one is keen to see it is all working :rolleyes:

Next I then :
- removed the resistor in series with the speaker so only an 8 Ohm speaker connected across the speaker terminals
- removed to 220 uF electro capacitor across the power pins so then only 4.7uF at the voltage regulator output terminals on an adjoining board

Again, the whole set of songs played perfectly right through.

Next I put the PICAXE back to 5Vdc and left the 1.2 kOhm resistors between PIACXE outputs and SOMO 14D and ran the program sequence again. So effectively back to a minimalistic circuit.

Again, the whole set of songs played perfectly right through.


So right now I am running with the initial program code I created:

Code:
SYMBOL control	= b0 	 			; Used for control bits - DONT use for anything else 
SYMBOL mask		= bit0			; Mask word for the shiftout procedure
SYMBOL index	= b1				; Bit counter for shifting data to SOMO 14D
SYMBOL song		= w1				; Pointer to the required song file
SYMBOL dta		= w2				; Data to send to SOMO 14D module is a word(16-bit) value

symbol MSB		= $8000			; Mask for the Most Significant Bit = bit 16

symbol sda		= 3				; Serial data output is on pin3
symbol scl		= 2				; Serial clock output is on pin2
symbol busy		= pin2			; Busy line back from SOMO 14D

;**********************************************
;Initialisation
;**********************************************

Init:
	high scl					; Set clock to high idle state
	wait 5					; Allow everything to start before sending any commands

;**********************************************
;Main Program
;**********************************************
Main:							
	For song = 0 to 30				; Lets play the first 30 audio files (0001.AD4 to 0030.AD4)
	
		dta = $FFF5				; set a volume level 
		GOSUB Send2SOMO

	 	dta	= song			; Provide the .ad4 file number on the micro-SD card
	 	GOSUB Send2SOMO			; Pass the filename/number to the SOMO 14D module
		GOSUB Holdtilldone			
	NEXT song
END

;**********************************************
;CLOCK DATA TO SOMO-14D MODULE
;**********************************************

Send2SOMO:
	LOW scl					; Pull clock-line low for a start
	PAUSE 2					; Start-bit time >= 2msec to indicate a start of command
	FOR index = 1 TO 16			; loop for each of 16 bits of filename/number
  		mask = dta AND MSB / MSB 	; ascertain if next bit is 1 or 0
		LOW sda
		IF mask = 0 THEN SkipMSB	
		HIGH sda				; if bit is 1 set data high high
SkipMSB:
		IF index = 16 THEN Skip16th	; Skip here as 16th bit is clocked out at the end
  		PULSOUT scl,20			; Create 200usec clock pulse for the current data bit
  		dta = dta * 2
Skip16th:
	NEXT index					; Go back for the next bit till all 16 sent

	HIGH scl					; Pull clock-line high which clocks out the 16th data bit
	PAUSE 2					; End-bit minimum time >= 2msec for STOP indication
	RETURN

;**********************************************
;WAIT UNTIL THE COMMAND IS COMPLETE
;**********************************************

Holdtilldone:
 	PAUSE 50				; Need at wait briefly as it seemingly takes ~5-7msec for the busy line to go high = busy
	IF busy = 1 THEN Holdtilldone
	PAUSE 50				; Need to wait briefly as it seemingly takes ~5-7msec after busy released before SOMO ready for new instruction
	RETURN
 

Grogster

Senior Member
Looks like we all are finally having some sucess with this thing! :D

I am now able to send commands to a 14M which "Bit-bangs" the 16-bit word to the SOMO.
This makes things very easy - send standard serout 8N1 commands in the form of 8-byte command "Words" via a 2-wire link. I can command the module to do anything using more simple serial comms, and have the 14M convert the commands and take care of the bit-banging for me.

I don't know about the rest of ya, but this has been one INTENSELY interesting process for me. :) Granted, there were some rocky paths, but it looks like they are starting to get smoother now, for want of a roading analogy...

@ goom: I note your comment about 8-bit files. Nice one. Added that to my list of pointers with respect to the use of this module. As I and westaust55 have done, make sure you have a cap across the power-supply for the SOMO, in the order of 220uF-470uF. I used 470uF and put it as physically close to the module as possible. I also put a 100n in parallel with the 470uF right beside the 470(so they are both as close to the module as possible) to act as a filter for any AC mains induced noise perhaps upsetting the module via the power supply lines.
 
Last edited:

hippy

Technical Support
Staff member
Glad to see all involved managed to get the SOMO working.

@ westaust55 : Once you've finished testing and doing any code optimiastions ( if any ) it may be an idea to post the code in the Finished Projects section - Audio Visual I'd suggest, or Code Snippets.
 

goom

Senior Member
It would be really useful if a list of "lessons learned" accompanied the code to be posted in the Finished Projects. Any volonteers? Wesaus55 is probably the best qualified, but I'll give it a go if this is asking too much.
Note that the Kingston 2GB card does not work (the 1GB Kingston card does work according to 4DSystems).

Thanks to all for the help and support. I am no longer amazed, but continue to be delighted by the prompt, polite, patient and helpful responses that is the norm on this forum.
 

Grogster

Senior Member
Thanks to all for the help and support. I am no longer amazed, but continue to be delighted by the prompt, polite, patient and helpful responses that is the norm on this forum.
I second that. :)

Note that the Kingston 2GB card does not work
You have tried one, I guess?

@ westaust55 - Since you recently got hold of a Sandisk 2GB uSD card, have YOU had any problems?

1GB uSD cards are kinda hard to find now days(new, that is)...
 
Last edited:

hippy

Technical Support
Staff member
1GB uSD cards are kinda hard to find now days(new, that is)...

Car Phone Warehouse is where I've recently got my 1GB and 2GB SD cards from in the UK. Unbranded ( CPW stickered ) but very reasonable prices. No idea if they'd work with the SOMO.
 

westaust55

Moderator
SOMO 14D working

@ westaust55 - Since you recently got hold of a Sandisk 2GB uSD card, have YOU had any problems?

1GB uSD cards are kinda hard to find now days(new, that is)...
Yes, I could not find any 1GB uSB cards yesterday when I went out to buy one.



I continued to run my SOMO 14D module through the evening while watching TV in an adjoining room and poping in occasionally to check it was working okay. Takes a while to play through 30 songs.

After a total of 4 passes with the most minimalistic circuit:
- PICAXE 18X at 5Vdc regulated
- SOMO 14D at 3.3Vdc regulated with only a 4.7uF electro
- 1.2k Ohm resistors in data and clock lines
- 8 Ohm speaker across SPK terminals of SOMO
- monitor the busy line for end of each song

it ran perfectly the entire evening.
I had a "DEBUG" comamnd in the loop so I could watch the song file numbers and (sort of) watch for any sign of jumping files - though the time to get thru the 30 songs was an equally good indicator.

The Kingsmax uSD card is a make that 4D systems themselves sell and recommend for the oLED and LCD displays but clearly not compatible with the SOMO module.

I have a hand ful of 1GB and 2GB SD Sandisk and Toshiba cards for my digital SLR camera. All work in the camera and while all work in a Sandisk USB stick SD card type readers, but some will not work in a generic USB stick SD card type readers.

So it is not limited to the SOMO as there are some incompatibilities with various memory cards in other equipment as well.
 
Top