Mixing Baud Rates

joe paul

Senior Member
Hi Folks,

Can you mix baud rates in the same program? I am trying to use the HC-06 module and the MDFLY MP3 board together with an 18M2. The MP3 board is 4800 and although it is possible to re-set the baud rate on the HC-06 with AT commands, the Bluetooth board is 9600. When I merge the 2 programs that work separately, the MP3 board doesn't work.

Thanks!

Take care, Joe.
 

eggdweather

Senior Member
Yes, you can switch baud rates as much as you like. On a serial display I have, on power-up it always starts at 9600 baud, so I set the initial rate to 9600 and then the picaxe sends a command to increase speed to 57600 and then I set the Picaxe to the same 57600, it works fine.
 

premelec

Senior Member
Be more specific on your code input / output instructions you are using and how you are setting them up... [together with setfreq if that's in there].
 

joe paul

Senior Member
Hi Folks,

Here is my code:
Code:
Symbol Baud = T4800           ; Set Baud Rate for Audio Module
Symbol Voice_Out = C.3        ; Set Serial Output pin on 18M2 for Audio Module

High C.3

pause 1000

serout Voice_Out, Baud, ($EF) ; STOP MP3 module when initialising power up 

pause 2000



setfreq m8 
main:

 serin B.5, T9600_8,b0 
 
  if b0=114 then goto red 
  if b0=98 then goto blue 
  if b0=103 then goto green 
  if b0=104 then goto song1
  if b0=105 then goto song2
 
  
goto main


 red:  
 for b1=1 to 4
 high B.4
 pause 1000
 low B.4
 pause 100
 next b1
 goto main

blue:
 for b1=1 to 4
 high B.3
 pause 1000
 low B.3
 pause 200
 next b1
 goto main

green:
 for b1=1 to 4
 high B.6
 pause 1000
 low B.6
 pause 150
 next b1
 goto main
 
 song1:
 
 serout Voice_Out, Baud, ($02)
 pause 1000
 
 goto main
 
 song2:
 
 serout Voice_Out, Baud, ($03)
 pause 1000
 
 goto main
I have been screwing around with it for hours; this was my last attempt.

Thanks!

Take care, Joe.
 

joe paul

Senior Member
Hi bpowell,

You did it!!!!!!!!!!!!!!!!!! It works. I was pulling out what's left of my hair.

Many thanks!!!!!!!!!!

Take care, Joe.

Code:
Symbol Baud = T4800_8           ; Set Baud Rate for Audio Module
Symbol Voice_Out = C.3        ; Set Serial Output pin on 18M2 for Audio Module

High C.3

pause 1000

serout Voice_Out, Baud, ($EF) ; STOP MP3 module when initialising power up 

pause 2000



setfreq m8 
main:

 serin B.5, T9600_8,b0 
 
  if b0=114 then goto red 
  if b0=98 then goto blue 
  if b0=103 then goto green 
  if b0=104 then goto song1
  if b0=105 then goto song2
 
  
goto main


 red:  
 for b1=1 to 4
 high B.4
 pause 1000
 low B.4
 pause 100
 next b1
 goto main

blue:
 for b1=1 to 4
 high B.3
 pause 1000
 low B.3
 pause 200
 next b1
 goto main

green:
 for b1=1 to 4
 high B.6
 pause 1000
 low B.6
 pause 150
 next b1
 goto main
 
 song1:
 
 serout Voice_Out, Baud, ($02)
 pause 1000
 
 goto main
 
 song2:
 
 serout Voice_Out, Baud, ($03)
 pause 1000
 
 goto mainI have been screwing around with it for hours; this was my last attempt.

 Thanks!
 

hippy

Technical Support
Staff member
You did it!!!!!!!!!!!!!!!!!! It works.
Not entirely. The initial "Stop MP3" SEROUT command at the beginning is used before you change operating speed to 8MHz so that is now being sent with the incorrect baud rate.
 

joe paul

Senior Member
Hi Hippy,

That MP3 board usually would start playing the first file on the SD card, but stopped with the last version of the code before the addition of the "_8" to the baud rate. I will put the "setfreq m8" at the very top of the code to ward off any other issues.

Thanks,

Take care, Joe.
 

joe paul

Senior Member
Hi 1968Neil,

Thanks for the info and the link, and the your code from the other thread. I don't think I'll use that busy feature just yet, but I will fool around with it later. I am trying to maximize the number of pins on that 18M2 chip. So far I've used 9 and I am saving a serial out pin for the Bluetooth app if I want or need feedback. I need at least 4 more.

The sound quality of that MP3 board is great! I didn't have any issues using a tiny SD card in an adaptor. Once I get it all working well, I will change the sound files. Don't want to tempt the fates just yet!

Worked today on a bank of 6 relays and tested them with my model train trackside throttle idea that uses a diode string to reduce voltage in 4 steps of 2 volts each step, either AC or DC to the tracks. Easier than PWM and for AC, I don't want to fool around with TRIACs.
Later I will try the PWM within a train, but that is a long way off.

Thanks!

Take care, Joe.
 

joe paul

Senior Member
Hi 1968 Neil,

I was looking over your code in the thread you directed me to a couple messages earlier, and noticed that you used B.3 for the serout to the MDFLY board, with the 18M2 chip. I was tying up B.2 for serin from the Bluetooth module. (I was under the miss-impression that you had to use a pin with hserin and hserout for the serial to and from the Bluetooth transceiver.) So I tired C.0 for serin from the Bluetooth module, and it worked. Now I have the full 8 outputs (B.0 - B.7) connected to the Darlington array. I had intentionally broken off the corresponding pins on the Darlington array for B.2 and B.5 for the serin and serout for the Bluetooth board (HC-06), but now replaced the array with a spare, and I am good to go for all 8 outputs. I ordered a few spare Darlington arrays and sockets for future projects.

So for the 18M2 chip, am I correct in my understanding that any pin capable of In/Out can handle serin and serout, and doesn't have to be a pin labeled hserin or hserout?

Thanks!

Take care, Joe.
 

inglewoodpete

Senior Member
Don't break off the pins of the darlington array. Instead, bend them out slightly, so that they 'miss' their holes in the IC socket. That way, your darlington chip can be reused.
 

joe paul

Senior Member
Hi InglewoodPete,

Thanks for the tip!

One pin I was able to bend out of the way, the other broke off (seemed brittle), so I broke off both. But that array won't go to waste, I will use it for about 3 or 4 outputs from the other side of the board, for the typical input pins that I will use for additional outputs.

Thing is, now that I am pushing 60, the dexterity and eyes ain't what they once were!

Take care, Joe
 
Top