User avatar
dbasberg
Posts: 56
Joined: Fri Jul 13, 2012 7:28 pm
Location: Michigan, USA

Best reliable baud rate?

Mon Jan 21, 2013 4:25 pm

I searched for rates people are using without errors. Most posts are about failures of their program to communicate properly. So, I ask what rates of serial comm have been used successfully between RPI and ATmega (on the GertBoard)? The examples are all at 9600 baud with display on minicom. In my project, this serial comm will be watched on both ends by a command line interpreter routine. The ATM will be slaved to the RPI. The systems overall response time will be dependent on serial comm speed, so higher rates will help alot. Has anyone used 38.4K or higher successfully? Of course, when I get my initial code running, I need to try rates in my particular setup. I will report my results then.

On a second note, I will need a periodic interrupt to schedule tasks and read I/O. The nice assortment of example code for the ATmega does not have any interrupt examples except for external pin interrupts. A nice periodic timer interrupt example would help a lot of people I think. I can create this myself because I have done commercial software with other processors which gives me experience. Is it a good idea to have a periodic interrupt example in the Arduino IDE file set?

Thanks, Doug
Five RPIs: 2:256 & 2:512 and an RPI3 used for monitor and control in out buildings of farm (embedded controls). Linux/Python novice. Experienced real-time programmer/hardware/systems designer (asm, C, C++).

User avatar
joan
Posts: 14476
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Best reliable baud rate?

Mon Jan 21, 2013 4:43 pm

I'd have thought that 115200 would work. I've used that speed between a Pi and a similar processor to the ATmega.

rickseiden
Posts: 411
Joined: Thu Aug 02, 2012 12:21 pm
Location: Buffalo, NY, USA

Re: Best reliable baud rate?

Mon Jan 21, 2013 5:28 pm

I've just used the examples, and had great success with 9600 and minicom.
There are 10 types of people in this world. Those that understand binary, and those that don't.

User avatar
dbasberg
Posts: 56
Joined: Fri Jul 13, 2012 7:28 pm
Location: Michigan, USA

Re: Best reliable baud rate?

Mon Jan 21, 2013 6:51 pm

joan wrote:I'd have thought that 115200 would work. I've used that speed between a Pi and a similar processor to the ATmega.
Thanks Joan. I have put together a skeleton of a program and will test the rates. If a rate fails with minicom, I will still need to test higher rates when my CLIs are operating on both ends(that will be a while). The faster it works, the better my program will respond time wise. From your comment, it will not be the RPI limiting the speed. :)
Five RPIs: 2:256 & 2:512 and an RPI3 used for monitor and control in out buildings of farm (embedded controls). Linux/Python novice. Experienced real-time programmer/hardware/systems designer (asm, C, C++).

User avatar
dbasberg
Posts: 56
Joined: Fri Jul 13, 2012 7:28 pm
Location: Michigan, USA

Re: Best reliable baud rate?

Mon Jan 21, 2013 6:53 pm

rickseiden wrote:I've just used the examples, and had great success with 9600 and minicom.
Funny tag line about binary Rick :lol:
Five RPIs: 2:256 & 2:512 and an RPI3 used for monitor and control in out buildings of farm (embedded controls). Linux/Python novice. Experienced real-time programmer/hardware/systems designer (asm, C, C++).

User avatar
panik
Posts: 369
Joined: Fri Sep 23, 2011 12:29 pm
Location: Netherlands

Re: Best reliable baud rate?

Mon Jan 21, 2013 10:08 pm

A helpful page is Wormfood's AVR Baudrate calculator: http://www.wormfood.net/avrbaudcalc.php
There are tables of example baudrates starting at page 199 of the Atmega328p datasheet, and a code example on page 183 that explains it well: http://www.atmel.com/Images/doc8161.pdf

User avatar
[email protected]
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: Best reliable baud rate?

Tue Jan 22, 2013 9:24 pm

dbasberg wrote:I searched for rates people are using without errors. Most posts are about failures of their program to communicate properly. So, I ask what rates of serial comm have been used successfully between RPI and ATmega (on the GertBoard)? The examples are all at 9600 baud with display on minicom. In my project, this serial comm will be watched on both ends by a command line interpreter routine. The ATM will be slaved to the RPI. The systems overall response time will be dependent on serial comm speed, so higher rates will help alot. Has anyone used 38.4K or higher successfully? Of course, when I get my initial code running, I need to try rates in my particular setup. I will report my results then.

On a second note, I will need a periodic interrupt to schedule tasks and read I/O. The nice assortment of example code for the ATmega does not have any interrupt examples except for external pin interrupts. A nice periodic timer interrupt example would help a lot of people I think. I can create this myself because I have done commercial software with other processors which gives me experience. Is it a good idea to have a periodic interrupt example in the Arduino IDE file set?

Thanks, Doug
I did a lot of testing at 115200 baud. Seemed to work OK, but my tests were only exchanging short messags (< 100 bytes) at a time. However I was initially programming the ATmegas via serial at 115200 baud and that went OK.

If you want to put a timer in your ATmega code, then there are plenty of examples, but be aware that the timers are currently setup by default to drive the PWM pins on the Atmega if you're using the Arduino wiring libraries. (ie. if you chang them, then the PWM might stop working)

I have an alternative that provides a task scheduller, but I've not had time to package it up for anyone other than me to use yet )-:

-Gordon
--
Gordons projects: https://projects.drogon.net/

User avatar
dbasberg
Posts: 56
Joined: Fri Jul 13, 2012 7:28 pm
Location: Michigan, USA

Re: Best reliable baud rate?

Tue Jan 22, 2013 9:36 pm

Gert;
I would be very interested in your scheduler approach. I almost always use a period timer interrupt in my software...seems to fit well with my 'state machine' mindset. I planned to use a couple of digital outputs to allow me to evaluate the timing relationships between my background tasks and the interrupt routines. My storage scope has surprised me many times when I do this, often leading to a rethink. I try to distribute the computing load by phasing my tasks. A few I/O pins hooked to a scope can really assist.
Thanks for your board/docs/forum posts/ and helpful replys...kudos! :D

Doug
Five RPIs: 2:256 & 2:512 and an RPI3 used for monitor and control in out buildings of farm (embedded controls). Linux/Python novice. Experienced real-time programmer/hardware/systems designer (asm, C, C++).

User avatar
dbasberg
Posts: 56
Joined: Fri Jul 13, 2012 7:28 pm
Location: Michigan, USA

Re: Best reliable baud rate?

Tue Jan 22, 2013 10:28 pm

I have now run a program on the ATmega that sends 30 bytes of data to the RPI every 2 seconds. The minicom display shows no errors. I conclude that the ATmega/Gertboard/RPI/Minicom can handle 115,200 baud successfully.

This will make my program successful at building control where the RPI will run the ATmega as a slave to commands sent by serial at 115,200. The returned data combined with Gertboard data/control will allow data acquisition/control for remote buildings by internet. That will provide security/environmental control/safety for buildings without manning. E-mail alerts, alarm system interaction and internet data/control will allow personnel off-site to handle the building. All that for a system with battery backup that costs less than $300US. I am very pleased! Go technology! :D
Five RPIs: 2:256 & 2:512 and an RPI3 used for monitor and control in out buildings of farm (embedded controls). Linux/Python novice. Experienced real-time programmer/hardware/systems designer (asm, C, C++).

Return to “HATs and other add-ons”