Tank Robot: Drive a Tank With Motors and Controllers Powered by the Kinoma Create
by Kinoma in Circuits > Robots
4983 Views, 79 Favorites, 0 Comments
Tank Robot: Drive a Tank With Motors and Controllers Powered by the Kinoma Create
We built a mini tank and controllers using two Kinoma Create devices that communicate over CoAP (Constrained Application Protocol). The handles rotate potentiometers which effect the voltage outputted. The changes in voltage are translated to varying speeds and direction of the robot.
Parts List:
We used a Kinoma Create to interpret varying voltage values and send motor commands to another Kinoma Create hooked up to a mini tank. These values are then written serially to a Sabertooth Motor Driver to control the robot.
Setting Up the Robot
After assembling the robot treads using the Tri-Track Chassis Kit, mount a Kinoma Create on the base.
Using the Kinoma Create’s back pins, attach jumpers from the 3.3 V, ground, and UART TX pins to the voltage level shifter.
Use jumpers from the shifted voltage pins to inputs labeled 5 V, GND, and S1 on the Sabertooth motor driver. Connect appropriate motor leads to the Sabertooth motor driver and power it with a 12 V battery pack. Make sure you set the switches on the board to simplified serial mode.
Setting Up the Tank Controls
Our design uses potentiometers that rotate when attached to handles. The varying voltage values outputted are fed into pins that are configured to receive analog input through software and then interpreted by the Kinoma Create to indicate speed and direction. Feel free to design supports with this input/output structure in mind. Sliding potentiometers work well, or you can build a 3D printed unit that houses both potentiometers and handles.
When your design outputs appropriate voltage values, feed them to the Kinoma Create using the front pins or pins 37 - 48 on the back (excluding pins labeled ground). Keep in mind that the maximum voltage seen at any input pin should be 3.3 V. After choosing any of these pins, go tomain.js located in the file labeled 'src' in tank-control and change the value of variables labeled: rightMotorPin and leftMotorPin to their respective pin numbers.
To see if your Kinoma Create is correctly reading these values, go to the Pin Explorer application located on the home screen of every Kinoma Create to check the values your pins are seeing. An example of the wiring is included above.
Now that everything is wired up, we’re ready to calibrate the robot's speed to your design's voltage output range. Setup is easy. Run tank-robot on the Kinoma Create hooked up to your robot and tank-control on the Kinoma Create that’s reading your voltage values. Remember: both Kinoma Create devices need to be on the same wifi network to communicate. The software assumes that higher voltage values mean forward movement. So on a scale from 0 to 1, 1 would be full forward and 0 would be full reverse. Once both applications are running, you should see two buttons: “Drive” and “Set up motors”, on your robot's Kinoma Create screen. Tap the “Set up motors” button.
Set whatever analog input you're using to each listed position (i.e. right max forward, left min reverse, etc) and simply tap the corresponding button to set the value. The program knows to store these values for future runs and recalibration is only needed when the cache on the Kinoma Create is cleared.
You may choose to return to the main menu and select the “Drive” button to display a message on the tank. This message can be changed by changing the variable “tankMessage” located inmain.js within the src folder of tank-robot.
Assuming you've wired everything correctly and are running tank-robot and tank-control on appropriate Kinoma Create devices, you should be able to drive your tank!
Optional - Building a Chair for Your Controls
We chose to make our driving experience a little more interesting by building a chair complete with a 3D printed unit that houses both the potentiometers and handles.
Optional - Adding LEDs
As a fun addition to our chair, we lined both sides with LED strips using the 60 LED/m NeoPixel strips from Adafruit and connected them to the 3V Trinket Pro microcontroller so we could use the NeoPixel Arduino Library. You can find the Arduino code HERE5. It's been optimized for 30 LEDs per strip.
Power your 3V Trinket Pro with at least 3.5 V. We chose to supply it 5 V. Keep in mind that other pins should never be supplied more than 3 V. Doing so risks damaging the board entirely. If you choose to use the NeoPixel strips, consider using an external 5 V energy source, especially if you are powering more than a 1m strip. In addition, the NeoPixel lights are fairly bright. You can counter this by using the setBrightness method in the NeoPixel Library or diffusing the strips by placing a diffuser across the LEDs. Blinking sequences and patterns are cool but keep in mind that adding a delay may prevent accurate response times from the potentiometers to the lights.
Optional - Adding an Emergency Stop Button
You may also choose to wire up an emergency stop button. The code currently implements a 'latching' button. This means that when pressed, the button remains in a pressed state and outputs a low value till pressed again. If you choose to implement a 'momentary' button, make necessary changes to the the button BLL (digital-button.js) found in the device folder of tank-control. Change the function exports.wasPressed to return true when a button is pressed according to your specific button. This will automatically trigger a emergency stop sequence for the LED strips if you use them as well. Wire your button output to any digital pin, front pin, or pins 38 - 47 (excluding ground pins). After doing so, change the variable labeled 'emergencyStopPin' in main.js located in the src file of tank-control to the pin you've selected.
Congratulations!
You’ve done it! Or if you got stuck along with way, we’re here to help — come visit us at our forum and let us know how we can help.