Need a Point in Right Direction

-Gary

New Member
Greetings All,
I have built my BeerBot and have it in the Blogs. The final bit of wiring I need has not shown up in many searches. I use 2-protoytpe boards. The AXE118 with a 20M2 and the 08 Protoboard with the 08M chip. 08 runs the Tenda Speech board and the Adafruit Audio amp great. 08 runs at "#setfreq 8".
Now I need to wire the 20M2 to the 08 so I can program the 20M2 to tell the 08 which mp3 file to play. Sounds easy, but I don't want to just try something to see if it works.
The code I have done so far is just to make the servos turn and motor run. Just testing my wiring.
Does this jog any ones memory of a previous post that you could point me to?

Thanks for any help!

-Gary
 

Rick100

Senior Member
Hello Gary,

Here is a link that might help.
http://www.picaxeforum.co.uk/showthread.php?22070-Simple-serial-circuit-with-two-08M2-picaxe-and-LED-help


If both Picaxes share the same power supply, you just have to connect the serout pin of the transmitter to the serin pin of the receiver. If they have different power supplies of the same voltage, you will have to connect the grounds together so they have a common ground. I would put a resistor of at least 330 Ohms between the serout pin of the transmitter and the serin pin of the receiver. This will protect the pins in case a programming mistake makes them both outputs.

If you only have a few sound files to pick from you could probably just send a byte(value 0-255) to the receiver telling it which file to play.

Can you confirm you are using the older 08M and not the 08M2?

Good luck,
Rick
 

-Gary

New Member
Hey Rick,
That was just the info I needed! I'll wire it this weekend and create a test program. The Tenda spec sheet says it will play 200 (000.mp3 to 199.mp3) songs or phrases.

There are separate power supplies, as the servos really put noise in my speaker. I do have the power supply grounds connected. My 08 protoboard has the older 08M chip. I do have a 08M2 chip I could use if you think it will make a difference.

I will let you know how it works out.
Thanks again for your help!
-Gary
 

Rick100

Senior Member
Hello Gary,

I noticed in your blog you said:
Had to add the 08M Protoboard to control the Tenda as my servo's went nuts when I set the 20M2 freq to 8mhz.
From the servo command documentation:
The servo command will function correctly at 4MHz on all parts (except X2 parts, which only function at 8 or 32MHz). 16MHz is also additionally supported on M2 and X1 parts. No other frequency will work correctly.
I was wondering why you needed a 2nd Picaxe to control the Tenda board. I've never used one of these boards but it's my understanding they use serial commands. Did you have trouble sending the commands directly from the 20M2?

Good luck,
Rick
 

-Gary

New Member
Hey Rick,
I was going by this post I found for using the Tenda sound board:

http://www.picaxeforum.co.uk/showthread.php?25574-Looking-for-MDFLY-pinout&highlight=mdfly

The #3 & #4 post is where I got the code. Originally I added this code to the simple test code I wrote for my 20M2.
Post stated that:
#setfreq m8 'Must be set to 8mhz for Serout command to work
With the #setfreq m8 on the 20M2, the servos all went to the stop then never returned to center. So I tried using my 08M to control the Tenda and everything worked well. I removed the Tenda code and the #setfreq m8 from the 20M2 and all was good. So I left the 08M control the Tenda and the 20M2 have the rest of the bot plus the 08M.

This weekend I will add the wiring and a program to play selected mp3 phrases using the 20m2 board to run the 08M board. This Tenda board is a lot of fun to use. With the Adafruit audio amplifier https://www.adafruit.com/products/987 this $20 combo will really make a speaker scream.
I see they have a model on sale that plays .wav and .mp3 files on sale for $4.99
http://www.mdfly.com/index.php?main_page=product_info&cPath=0&products_id=1030
The only tricky part was finding how to make it play a mp3 file that was converted from a wav file. The wav file has to be created at 8khz. My first attempts were with the Audacity program and is defaults to 44khz. The speaker will be completely silent as the wav file plays then you hear a little static when it ends. My friend suggested the 8khz recording speed and this worked. You may be able to record at a higher speed, never tried it. Audacity has 13 record frequency speeds to select from.

Thanks again for your help!

-Gary
 

Rick100

Senior Member
Hello Gary,

The documentation for the Tenda board in the above link says the baudrate should be 4800. The 08M has to run at 8 MHz to do 4800 baud.
The program uses the line:

Code:
serout SOUT,T2400,(0xEF) 'STOP module
The 'T2400' refers to 2400 baud with a 4 Mhz clock. The baud rate will actually be the correct 4800 baud at 8 MHz. The proper way to write the line would be:

Code:
serout SOUT,T4800_8,(0xEF) 'STOP module 4800 baud at 8 Mhz clock speed
They both do the same thing but the second line is less confusing.

The M2 parts like the 20M2 or the 08M2 will do serout at 4800 baud with a 4 Mhz clock. Her's a sample line:

Code:
serout SOUT,T4800_4,(0xEF) 'STOP module 4800 baud at 4 Mhz clock speed
In the serout documentation, there is a table showing clock speeds and baud rates.
http://www.picaxe.com/BASIC-Commands/Serial-RS232-Interfacing/serout/

So I left the 08M control the Tenda and the 20M2 have the rest of the bot plus the 08M.
I understand. I'm just pointing these things out for clarity. Since I was confused, I thought other people reading the thread in the future might be confused also.


I used Audacity in the past to convert wave files to a raw 8 kHz 8 bit file to store on a 24lc256. I spend a couple of hours searching the internet before I figured it out. I wrote down the steps and haven't upgraded Audacity since then. I'm afraid any upgrades might break my conversion process.

Good luck,
Rick
 

papaof2

Senior Member
I used Audacity in the past to convert wave files to a raw 8 kHz 8 bit file to store on a 24lc256. I spend a couple of hours searching the internet before I figured it out. I wrote down the steps and haven't upgraded Audacity since then. I'm afraid any upgrades might break my conversion process.
That's a reason to have a 'beater' PC that you can try new software on without affecting things that you have put a lot of effort into. If version Y of the software works the same as version X, then you can upgrade the primary PC.
 
Top