How can I send short text stream over BLE fast? #18824
Unanswered
paulbuzzby
asked this question in
RP2040 / Pico
Replies: 3 comments
-
|
It might work better using |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Does the transmission time correlate with string length? If so, it might be worth considering a compressed format to reduce data volume. |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
A couple of avenues to look into:
I would generally also reccomend aioble like @bikeNomad as it generally allows you to simpify code architecture, though in this case it shouldn't really impact speed. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Everyone,
I am using an Arudino RP2040 Connect for my micromouse project. Running the lastest 1.27v micropython firmware.
I have discovered a bit of a bottleneck in my code where i send short pieces of telemetry over BLE to a terminal app on an old andriod phone.
I am trying to see if there is a way to streamline this process so that the excution time is reduced or offloaded somehow so that the main control loop can keep executing.
The current programms architecture is a main control loop and a timer that run at 100hz. The 100hz timer is responsible for controlling the robot. Reads sensors and runs the PD motion control. This loop does not send data over BLE but the main loop does. The main loop is responable for the high level thinking around what move the robot will make next.
In testing I have found that a single short test string (less than 200 characters) will take around 5ms to send. So for 5ms the main control loop isn't doing anything else. I would like this time to be down to 1ms.
My 100hz loop takes about 1.5ms to execute. I would like to increase the control loop speed to 200 or 250. In order to do that i need to make sure that my main loop still has some buffer space. at 200 or 250hz i only have 5- 4ms to do all processing. With 1.5 already being used that only give me 3.5 at best. A single telemetry busrt messes with all the timings and lots of weird stuff starts to go wrong.
Again, i don't send telemetry every loop but i do need to make sure anything I run within my main loop still executes within the time remaining between controll loop cycles. Hope that makes sense.
When the robot is running 80% of the time the main loop is waiting for the robot to reach a distance.
Current BLE Code example
Here is my BLE module and the function i use to send string data over BLE.
Another important factor is that I cannot consume heap memory with any dynamic allocations. If the garbage collector runs this causes all sorts of pain. Which I have posted about in the past.
I am hoping someone here has a clever or simple solution to improve the performance. I suspect I am missing some understanding.
I have attempted to use threading to offload the sending of information to core1 but I only got a solution that was slower.
I am sure there is a way to get core1 to do stuff but I am yet to get any practical uses.
Thanks in advance
Beta Was this translation helpful? Give feedback.
All reactions