So i need some help...
I need to send in 6 variables through the serial port in the Mega.
The variables are 4 ints and 2 floats. The ints are between -180 and +180, the floats are Latitude and Longitude from GPS, both are 7 digit numbers.
Now i've set up everything and everything works like a charm. But, i want to get my program to execute at least 200Hz, and the bottleneck is the serial communication. Without it , my program runs near 500Hz, but with the serial i can only get 100Hz.
It takes about 3-4ms for the Serial to send everything i want, while my program executes about 1-1.5ms. Is there a way i can make the serial much faster, at least twice as fast? My baudrate is already at 115200.
I would like to only send only 6 (no more than 6) variables as well, so i am clueless how to go about increasing the speed.
The program on the computer side, reads the serial buffer 6 times and stores the values. Then i do some graphical stuff with the data, "real time". So every time i am sending data it must be 6 variables, no less no more.
I am thinking of sending the data through I2C to another Arduino that then sends its to my computer. Acting something like a Register (pipeline). That way my mega can continue to run. Not sure if it work they way i think it would...
So while i am working on that, i thought that i would ask for help.
Some things i've tried, but failed:
Sending the GPS data only when it was available ( 1 Hz). It works until the gps data needs to be send. I am using a timer interrupt, so for 200 Hz, the timer interrupt is set at 5ms. As soon I send the GPS data , the thing farts and crashes...
Converting the floats to a long, but the converted long takes longer to send so not really an improvement.
Summary of my problem: Takes too long to send what i want. Goal is to have the program execute at least at 200Hz, and sending everything (the 6 variables mentioned above). Is it realistically possible? If so do you guys have any ideas how?
Please help. ![]()