Do baud rates always need to match, or will they need to be different sometimes?
I'm attempting to use the SoftModem library (SoftModem005) to demodulate some FSk. I don't know a lot about the library, I think the low frequency is a 1, and the high frequency is the 0, based on testing with a constant signal. In the .h file I have set the baud rate to 1200, low frequency to 1200, high frequency to 2200, and the buffer size to 32. I'm not exactly sure about what a change in buffer size does, but a tutorial I looked at suggests bigger is better.
I feed a 1200hz square wave into the modem's Rx input (digital pin 6 or pin 7) and I get 11111111 (in binary) repeating with an ocasional error, which definitely makes sense. What I'm confused by is my baud rates. They seem to be all over the place, but only work in this specific configuration.
My serial monitor is at 9600, the arduino is at 115200, and the modem is at 1200. I've tried other combinations and this seems to be the only configuration that delivers the correct output to the serial monitor. Why does it work with these baud rates and not others?
My understanding of baud rates is that they are simply the rate of data transfer, like a defined clock rate rather than an actual clock. They let the receiver know the difference between a 00000000 and just a really slow 0. If this is true, shouldn't they only work if the serial monitor and arduino have matching baud rates?
I haven't tested any other signals other than 00000000 or 11111111, I'm using my phone as a function generator, so that's all I have so far. I'm working out a way to use another arduino to send the data.
Code:
#include <SoftModem.h> //Software Modem Library
SoftModem modem; //Because SoftModem.begin wont work for some reason
int LED = 9;
int x;
void setup()
{
pinMode(LED, OUTPUT);
Serial.begin(115200);
Serial.println("Start :"); //Doesn't work when the serial monitor is on 9600 baud
modem.begin();
}
void loop()
{
while (modem.available ()) //Doesn't work when arduino is on 9600 baud
{
int c = modem.read (); //1byte Lead
if (isprint(c))
{
Serial.write ((char)c);
}
else
{
Serial.write (" "); //Hex printable characters are displayed in
Serial.write (c);
x++;
if (x == 40) {
Serial.println(); //wrapping line
x = 0;
}
}
}
}