Close

Speed control via Bluetooth and Phone App

A project log for Remote Control Differential Drive Robot Car

A remote control differential drive robot car where the linear & angular velocities of the are controlled using a PID control system.

ghani-lawalGhani Lawal 02/26/2022 at 22:450 Comments

Originally intended to send speed command every time the position on the slider changed.  This was giving me wildly inaccurate values.  According to 

https://community.element14.com/members-area/personalblogs/b/blog/posts/app-inventor-bluetooth-and-arduino-part-3-android-slider-controls-led-brightness

as the slider moves "updates occur very rapidly; this has the potential to overflow the Arduino input buffer.

Therefore I decided to use the Clock.timer block to send the speed command at the clock interval, which was either 100 or 50 ms at the time.  The data sent was still 'slightly off'; so I rounded the position of the slider to the closest integer and prepended the value with "\r".  This worked... for the most part, but pretty often the app would send only a subset of the desired speed to the Arduino.  E.g. say Speed = "123" the Arduino would only receive "12" or "23".  To solve this last problem I created a added parity bytes to the speed command.  "a" was appended to the desired speed and "b" was prepended to the desired speed i.e. Speed = "a123b".  If the first byte isn't "a" and the last byte isn't "b" then the desired speed value of the Arduino would not be changed.

***Now have full, stable and consistent control of the speed of the motors using the app created using MIT app Inventor via Bluetooth,

Discussions