I’ve been rewriting the remote control code for my Dagu Rover 5. I wanted to integrate my encoder code in to my remote control sketch. In my old code I would directly scale the joystick values to a pwm value. Now I scale the joystick values to the time between encoder pulses. This is the “target pulse”. I then measure the time between pulses and and adjust the pwm accordingly. This gives the motors more torque and allows me to run them much slower. Which is very handy to accurately control the Rover.
I also recently modified the gripper, I’ve added another servo so that the gripper can rotate. The gripper now has 4 servos. The servos are powered by an 8A UBEC.
I’m still using a pair of nRF24L01 modules to remote control it with my self built Arduino remote. I used this fork of the RF24 library for the nRF24L01 modules.
You can download the code used in the above video here:
Sketch for remote
Rover 5 sketch
The Rover sketch starts with the radio code for the nRF24L01 module. I run this code once every 20ms. Running it faster gave me a lot of dropped packets. When the radio module hasn’t received a packet in more then 200ms the motors are stopped. I then read 5 analog inputs, the first one is the battery voltage. The Rover is powered by a 2S 3000mAh Lipo battery. The next 4 analog inputs are the current measurements of the 4 motors. If the battery voltage is high enough and the motors aren’t stalled the values from the joystick are processed to control the Rover and gripper. By pressing the joystick I can switch between controlling the motors and controlling the gripper. The remote has a 4×20 character LCD. The battery voltage of the Rover and the current of the motors are sent to the remote and displayed on the LCD.