Slow baud rates and the Raspberry Pi Pico
/It’s strange the things you discover when you try to do something. Today it was all about slow baud rates.
What’s a baud rate? I hear you ask. Well, baud apparently stands for “binary asynchronous unit of data”. Or it’s an abbreviation for the name Emile Buadot who was a French pioneer of digital communication and had an amazing moustache and beard. Emile was sending text down a single wire and he was doing it one bit at a time. Assemble enough bits and you can match patterns of ons and offs to particular characters. The data stream would begin with a start bit (to tell the receiver that a character was coming) and then have a bunch of signal levels that represent the character being sent. One thing that was important is that the sender and the receiver needed to agree on the rate at which the data was sent. Otherwise things get garbled. So they invented the baud rate (number of bits per second) and created some standard speeds (110,300,600,1200, 2400, 9600, 115200 and so on…) Baud rates are still used today. The GPS receiver in your mobile phone will be sending position information into your phone processor via a serial data stream with a particular baud rate.
When I connect a Hull Pixelbot to a computer I have to set a baud rate for the serial connection. I use the horrendously slow “baud rate” of 1,200 bits per second. This is because the program that the robot receives is stored in EEPROM in the robot (EEPROM stands for “Electrically Erasable Programmable Read-Only Memory). This is so we can turn the robot off and it will still remember the program it has been given. EEPEOM is awesome, but it is also very slow to write. The hardware has to bash the bits into the hardware components in the memory device and this takes time. I could have added handshaking - where the robot sets a signal to tell the host computer to stop sending - but instead I did something quick and dirty, which was to slow down the robot baud rate to the point where the EEPROM could keep up.
This kludgy decision came back to haunt me today when I tried to use an Arduino programmed Raspberry Pi PICO at 1200 baud. The PICO seems to get upset when you try to talk to it via a serial port running at 1200 baud. Not sure why, but the result is that my robot code doesn’t work properly. Oh well. I’ll just have to speed up the serial port and add some handshaking. I believe this is called “paying off technical debt”….