Things used in this project
I attended a Intel Arduino 101 Hack Night on 12/16/2016 at fat cat Fab Lab in NYC. Teams of participants assembled Robot Rover's as described here. The method for controlling the Robot Rover is tedious and requires a laptop keyboard. For demonstration purposes and to test the rover to insure it is functioning it is a useful set-up and thanks to the author for a great write-up.
I decided to buy parts to build my own rover. There are a wide variety to kits available. I chose one with a metal frame and big tires. I decided to power the motors initially with alkaline batteries and the Arduino with a Anker Powercore Mini lipstick recharger. After getting it assembled and running I began to search for other ways to remotely operate it. I came across a couple of descriptions such as this one featuring nRF Connect application from Nordic Semiconductor , this one describing a phone app called Blynk and this one from Electron Hacks . After exploring these possibilities I decided to pursue using Blynk as it seemed to be a more straight forward (easier) approach.
To begin Blynking head to the app store and install Blynk on your mobile phone device. The website has all of the instructions for setting it up in the documents section. After installing the app on your phone Blynk will issue an Auth Token that will give your device a unique address. This token needs to be inserted into the sketch on line 39. You also need to install the Blynk library as well as the Adafruit Motor/Stepper/Servo Shield Library in your Arduino folder. You may also need to install the CurieBLE library if this is the first time you are using the Arduino 101 controller (Arduino>Sketch>Include Library>Manage Libraries>CurieBLE).
I initially set up the app using push-buttons for rover directional movement and a slider for motor speed for motor speed. (this solution was inspired by Intel Arduino 101 BLE Blynk Tank posted on Electron Hacks-Thanks!) The sketch for this version is here.
While setting this up I noticed a joystick widget and decided to try and code a solution to it. After getting frustrated I decided to look around for some help. SparkFun provides a code example for its hardware joystick that is very clever and straightforward.
It assumes there are eight directions of travel for the joystick to designate. It translates the joystick movement into a Rover direction as follows. The Blynk joystick widget travels along an x and y axis that are 255 units in length, making the midpoints 128. The direction of the joystick movement can be determined by comparing the joystick x and y value to 128. If x is less than 128 (left relative to the center) it is assigned a value of -1. If it is greater than 128 (right relative to the center) it is assigned a value of +1. If equal to 128 (centered) it is assigned a value of 0. The same is done for the joystick y axis values. For example when x>218 and y>218 the x-direction is 1 and the y-direction is 1 making the joystick in the forward right area. The sketch takes the x and y direction combinations listed in the Fig. 2 Joystick Direction Table powers the appropriate motors to steer the Rover. Note that the Rover steers in the direction of the unpowered motors.
The SparkFun example employs another clever strategy. Apparently the SparkFun joystick does not always return to its exact center. To correct for this a "threshold" area around the center point is created. This comes in handy for the Blynk joystick as well. While the Blynk joystick always returns to the center (see the Auto-Return switch in the joystick set-up) the joystick creates thousands of x,y combinations. This can make the Rover motion erratic if the x,y values are compared to 128 to determine a direction. I found that creating a threshold area around the center of +/- 20 for the x and y values works well.
The sketch powers all four motors in the same direction for forward and in the opposite direction for reverse. For a left turn the left front and rear motors are unpowered (RELEASE). For a right turn the right front and rear motors are released. for a hard left turn the left side motors are run FORWARD and the right side motors are run BACKWARD. This causes the Rover to spin in circles. You can experiment with powering or un-powering particular motors to yield the optimal turning results.
The Blynk joystick and motor speed slider switch operating and set-up screens are shown above.
The sketch powers all four motors in the same direction for forward and in the opposite direction for reverse. For a left turn the left front and rear motors are unpowered (RELEASE). For a right turn the right front and rear motors are released. for a hard left turn the left side motors are run FORWARD and the right side motors are run BACKWARD. This causes the Rover to pirouette or spin in circles. You can experiment with powering or un-powering particular motors to yield the optimal turning results.
I elected to power the Arduino 101 and Rover motors with separate power supplies. I bought an Anker PowerCore+mini to power the Arduino. Apparently the Arduino does not draw enough power to keep the Anker turned on (it shuts off after about 10 seconds). This seems to be a problem with many USB power sources. To prevent it from shutting off I was ready to build a load circuit for it as described here. Since the Anker has only one USB port I got out an IOGEAR 4-Port USB 2.0 Hub that I had laying around since another USB port is required to plug in the load circuit. It turns out that the USB hub places a large enough load on the Anker battery to keep it on. I am currently powering the motors with 8 x 1.5 volt alkaline batteries. At some point I will invest in a LiPo battery to power the motors.
I hope you find this write-up useful in getting your Rover to run.
The sketch has been updated to provide improved steering performance. The sketch can be found here. It requires the addition of two switches to the Blynk phone interface.
In the revision a pushbutton widget labelled Right Pirouette on virtual pin V3 and a pushbutton widget labelled Left Pirouette on virtual pin V1 are added. The SliderL (long slider) widget is on V4 and is labelled Motor Speed. The joystick widget is on virtual pin V0.
The revised code now performs the diagonal joystick position (soft) turns by reducing the turning side wheel speeds to 60% of the opposing side wheels. You may want to adjust this ratio for your particular chassis and tire setup. The hard right turns are performed by un-powering (RELEASE) the turning side wheels. The spin or pirouette maneuver is now performed with the pushbuttons.
I am thinking about adding some ultrasonic sensors to send distance to object data to the Blynk interface and possibly override the joystick to automatically avoid objects. I'll post the code whenever I have it ready.
Did you replicate this project? Share it!I made one
Love this project? Think it could be improved? Tell us what you think!