RC Drift Car Hardware Part 1


In this project, I and Arturo Paras hacked into an RC car to automatically detect and turn and drift in the direction of an arrow with CV.
Supplies
Here's the list of all the materials we used:
RC car used:
Control Related:
CV Related:
Camera x1
(consider buying more than one order of the potentiometers/cameras, as they may come broken)
Collecting Values Before You Break It
First, a brief explanation of our approach: Instead of trying to talk directly to tap into the ESC already hardwired into the motors and other parts of the car, we decided to take a less invasive approach, at least for the car itself. The hand-held controller on the other hand, we took apart quite liberally.
Before we rip everything apart, it is much easier to perform some data collection now that is necessary later. We will still need to open up the controller for this step, just don't remove any pieces yet.
When opening the hand-held controller, we see that the user input actually just boils down to two potentiometers. The first is for the trigger, and controls movement forwards and backwards. The second controls steering.
Note that when you are not touching the controller at all, the potentiometers are in a position that divides the voltage roughly equally. Using a voltmeter, get the value of this "base state" for your controller. You will use this to calculate at what step your digital potentiometers should reset themselves to to start (since it won't trivially be zero). As an example, my potentiometer has a wiper to ground value of 1.23 in its resting state, and goes up to 2.8 when directing the car to go forward, and 0 when directing the car to go backward. The steering potentiometer had 1.63 resting (straight), 2.8 right, and 0 left for it's respective values. Your highest values should be close to the full voltage across the potentiometer (high to ground), which may vary between RC cars you choose.
If you don't want to do all that, honestly, I'm pretty sure you don't need to be this precise with the values, so it should be fine. In retrospect, it seems the steering is just straight if the ratio is about a half, then gets gradually turned more right or left as the ratio goes up or down. The trigger is a little more complicated. Since the motor can't do anything below a certain threshold of voltage, the car uses the values below a certain threshold to tell the car to go backwards, instead of it being just a low value of forwards. For our car, if it was going forwards, then you push the trigger out to tell it to go backwards, it will just break. You need to re-center the trigger, then push it out to go backwards again, and then it will actually go backwards. Note any similar oddities in your own car's controller as you try to automate it.
Repurposing the Controller
(ADD IN VIDEO FROM SLIDE 8 IN THE FINAL PRESENTATION)
Remember, as far as the controller is concerned, there are only the two potentiometers for input. So, all we have to do to insert our own inputs is to swap out the physical potentiometers with our own digital ones that we can control automatically. That is our end goal.
To get there, first test all your connections by breadboarding in a different pair of potentiometers, which should result in something like the above video. I personally made the connections by first fully removing the old potentiometers and soldering on pin headers in their place. Then, I simply used jumper wires from the pins onto a breadboard, where I placed some other 10K potentiometers I had lying around (what resistance value the potentiometers are doesn't really matter, the controller only cares about the resulting voltage ratio that is produced by them)
Going Digital
Now that you have easy access to the controllers input system, we can easily swap out the potentiometers you used for testing with digital potentiometers!
For the ones we used (listed in the materials section), the corresponding data sheet applies.
Detailed in the data sheet is how we need to interface with the chip to get it to do what we want, that being control the car. Note the number of steps whatever digital potentiometer you choose is capable of. You may want to test that it behaves as expected. For our project, we had to use two different digital potentiometers, which is why our variables in code may be a little weird for you looking through them. The potentiometer we used for the steering only had 34 steps (STEERING_MAX), while the motor had a finer number of 100 steps (MOTOR_MAX). Whatever you change those variables to, you should also change their corresponding resting variables: STATIC_MOTOR_STEP should be about 55-60% of the max number of steps. STATIC_STEERING_STEP should be as close to half of STEERING_MAX as possible.
On your end, I don't think any other modifications to the code will be necessary other than those variables. (if you use a digital potentiometer at least within the same family as the ones we did) See the last steps for all the Arduino code.
Raspberry Pi Integration
Will be added by partner
CV Implementation
Will be added by partner
All Arduino Code
Below is all the Arduino code that we used for the final project. It won't let me zip it up for you, so this is the next best I can do:
Raspberry Pi Code
Will be added by partner.