I am working on a project that needs fast wireless communication from MATLAB to arduino (One way).
The data that needs to be sent is in the format of string of numbers, where the sending rate is 100Hz.
I am using the XBee 1mW Series 1 and Teensy 3.2.
Here is what I have got working. The data is sent from matlab in this format
<1234123412341234>
The program only looks for the start marker ‘<’ and then starts recording the other numbers until we reach the end marker ‘>’
I would like the main loop to run at 100Hz, but the problem is that the program main loop is only able to run at about 25Hz, which is way too slow for my application.
FYI - I am able to run up to 250hz loop without reading the data string.
Is there a way to optimise the code? Or is serial communication of XBee too slow? How can I improve this?
puedpued:
I would like the main loop to run at 100hz, but the problem is that the program main loop is only able to run at about 25hz, which is way too slow for my application.
FYI - I am able to run up to 250hz loop without reading the data string.
I don't understand what you mean by "loop" in this context.
Also I don't understand from your Original Post what you actually want to send 100 times per second.
I routinely use the code in recvWithStartEndMarkers() at 500,000 baud so the Arduino code is not the obstacle.
I don't have any experience with XBee modules. Have you tried communication using a USB cable rather than the XBee?
Robin2:
I don't understand what you mean by "loop" in this context.
Also I don't understand from your Original Post what you actually want to send 100 times per second.
I routinely use the code in recvWithStartEndMarkers() at 500,000 baud so the Arduino code is not the obstacle.
I don't have any experience with XBee modules. Have you tried communication using a USB cable rather than the XBee?
...R
The data is being sent wirelessly to Xbee at 100hz, but the arduino cant keep up for some reasons. I need it to log all the data that is being sent.
I have a timer in the loop() function that counts the time difference between each time the loop() function is called. I need the time difference between each time loop to be at least 10ms.
I haven't try the USB cable, I might give it ago. But still, I need this to be done wirelessly.
puedpued:
The data is being sent wirelessly to Xbee at 100hz,
WHAT is being sent 100 times per second? Give some examples of typical messages.
I have a timer in the loop() function that counts the time difference between each time the loop() function is called. I need the time difference between each time loop to be at least 10ms.
Post the program with the timing code
I haven't try the USB cable, I might give it ago. But still, I need this to be done wirelessly.
The purpose of trying the USB cable is to see if the XBee is the cause of the problem.