I guess this is step 6 of the Joustbot epic assembly adventure. At the end of step 5 I was waiting for some 9.6V batteries to arrive and was a little concerned about how the 12V motors would behave at less than 12V. It turns out that that they run just fine, and the robots are fun to drive at this lower voltage. Unfortunately, I did run into a problem that scuttled my grand plans of finishing this project last Friday.
In the past I had implemented skid steering using the radio control signal operating mode in our Motor Mind C dual motor controller. This was done using a 2-channel joystick RC transmitter/receiver pairs (the Futaba Attack II, photo right,for example). With skid steering one joystick controls one motor’s speed and direction, and a second joystick controls a second motor. You see something similar on tracked vehicles like bulldozers and tanks. It takes a little practice but usually works just fine. To implement this I picked up a couple of cheap 2-channel RC transmitters for cars and boats online. The Venom VR2T was priced right and in stock (photo left).
It turns out that the different transmitters create a different kind of problem for skid steering. The electrical signals they send out are the same, but the way the user produces those signals is different. On the Futaba model (right) you have to train your mind to deal with the fact that one motor is controlled with an up-down thumb movement, and the other with a left-right movement. This is pretty easy to do. On the Venom you have a trigger controlled by your index finger. Pulling and pushing the trigger controls one motor forward and reverse. This other motor is controlled by rotating the wheel on the side of the controller. After about 10 minutes of trying to get the hang of it I decided it was too much like patting your head and rubbing your tummy. I could do it, barely, and with a lot of practice. Somebody walking in cold would fare less well and suffer frustration. They would probably want to kick the Joustbot after a minute of wild spinning and random crashing into of things. I was suffering the implications of a bad user interface, the bane of all electronic design.
The Venom transmitter is obviously set up so the trigger is forward-reverse speed, and the wheel is left-right control. To accomplish this I would need for the two RC signals to be “mixed”, and the motor speeds sent serially to the Motor Mind C. Luckily we have the Parallax BASIC Stamp 2 on the carrier board we’re using. So I re-routed the RC signals to the Stamp, and did the mixing in firmware.
1. Use PULSIN in the Stamp2 to read the RC signals. You need to make sure to measure them in the sequence they arrive (channel 1 before channel 2)
2. Convert the 2uS measurement in the stamp to 1uS per bit by multiplying by 2, and also check to see if the transmitter is turned off, if so we make sure motors are off.
3. Mix the signals, I came up with these equations using a spreadsheet. They’re not perfect but do the trick. I multiply the results by two to make sure all 10 bits of the motor speed can be used. The Motor Mind C will limit values sent to it to +/-1023.
4. Death Blossom: Skid steering allows robots to spin in place. The mixed signals don’t do this. So I check to see if the “wheel” control is at either extreme, and if it is I force a spin in the appropriate direction. And of course Death Blossom is from the movie The Last Starfighter.
5. The motor speed derived from the mixed RC signals are sent to the Motor Mind C via a serial interface.
This is not all of the code, but shows the heart of the RC channel mixing.
START_UP: PULSIN CH1,1,RC1 'Read RC channel 1 pulse PULSIN CH2,1,RC2 'Read RC channel 2 pulse RC1 = (RC1*2) 'Stamp reads 2uS intervals, convert to uS RC2 = (RC2*2) 'Convert to uS ‘check to see if the transmitter is turned off, if so, configure so motors stop GOSUB RC_OFF M1 = (RC1-1500)+(RC2-1500) 'Mix signals CH1 = speed CH2 = direction M2 = -((RC1-1500)-(RC2-1500)) 'Motor 2 mixed differently and reversed M1 = M1*2 'Expand motor speed to use all 10-bits M2 = M2*2 'Expand motor speed to use all 10-bits GOSUB DEATH_BLOSSOM 'Homage to Last Starfighter movie GOSUB SETDC 'Send serial motor speed commands 'Comment in to display pulse measurement registers and motor registers DEBUG "CH1=", DEC5 RC1," CH2=", DEC5 RC2," M1=", SDEC5 M1," M2=", SDEC5 M2,CR
This new method of converting the RC signals to motor drive signals greatly simplified control of the Joustbots. My kids (4 and 11) were able to drive them and do a little jousting on Easter.
Schematics and BASIC Stamp code will be added in an upcoming post.