Tutorial – How to control motor with The Tactigon – Part III – Tactigon as Remote Controller

In this article we’re going to learn how to connect The Tactigon to a motor control board and communicate with serial interface.
Tracked Rover

Overview

As we saw in the previous articles (Tutorial – How to control motor with The Tactigon – Part I – Hardware and Tutorial – How to control motor with The Tactigon – Part II – Sketch), The Tactigon can be connected and talk to a serial motor control board. In this article we’ll look at how to control the rover using a second Tactigon as controller, using pitch and roll to compute tracks’ speeds (called wheels speeds from now on), as shown in the video above.

Sketch

The sketch running on the rover is the same one of the previous article. We will look at the one in the controller, since it’s the one that does the math.

BLE Transmission

The Tactigon used as controller needs to run as BLE Central Mode. It will search for a BLE device with targetMAC as MAC Address and targetUUID as available UUID. In this way the controller can write in this characteristic computed tracks’ speed.

ble

Transmission happens 10 times per second:

ble transmission

Euler’s Angles

Since we’re going to use pitch and roll to drive the rover, we need euler’s angles.

qMeter.getQs() contains theese angles in rad, but we prefer degrees:

euler angles

We defined thrasholds for roll and pitch, in degrees:

thresholds
thresholds

The logic of the controller uses “speedWheel” as a common track speed, and “deltaWheel”, as the value to be added or subtracted to each wheel when turning.

 

There is also a “spin” position to let the rover turn in place.

deltawheel
speedwheel

Now, we have to compute this values for our motor control board, as seen in previous article, it uses 1 to 127 for motor 1 and 128 to 255 for motor 2.

sabertooth values

Buffer is filled with computed data, and sent 10 times at second (every 5 loop, and the seen code is executed at 50 Hz).

how to run at a frequency (50hz)
data

Conclusion

We can use The Tactigon as a controller, in this case for a rover, but other models can be controlled.  Remember to download the source code below and subscribe to our YouTube channel! 

Download Code:

Related Posts