# Controlling speed of Razor Cart XL with DS3502 digital potentiometer



## plotti (Nov 11, 2020)

Goal: I want to be able to control the max speed of a small electric gocart by a raspberry pi, to kinda rebuild the effect like in mario cart where you can get a boost up or drive over a banana to slow you down.

My problem:
I have a "pedal" that controlls the speed of a gocart. If i push it the motor goes faster if i release it the motor goes to 0 rpm. Easy peasy  Now for the tricky part:

I figured out that if i put a analog potentiometer on the "green wire" coming from the pedal going to the speed controller i can adjust how much total speed the gocart can have. The voltage of it is 0.5 V when the pedal is not pressed and 2.5 v when fully pressed. In fact these "kits" exist Throttle Top Speed Adjustable Limiter for Razor Electric Scooters, Go Karts, Quads, Dirt Bikes, Pocket Bikes, Sports Bikes, and Crazy Carts I bought one of these experimented with the analog poti and it worked in they way you would expect it. You the more you increase the 10k ohm resitance the slower the total max speed of the cart is up to the point where you push the pedal and it doesn't move at all.

So now I wanted to controll the potentiometer digitally with the ds3502 on a raspberry pi. So i wired it up like this https://cdn-learn.adafruit.com/assets/assets/000/078/833/original/adafruit_products_rpi_fritz.png


Pi 3V3 to sensor VIN
Pi GND to sensor GND
Pi SCL to sensor SCL
Pi SDA to sensor SDA

I followed the tutorial and all works fine, the software works, and the wiper changes the voltage just fine. 

But now i want to connect the green pedal wire to it. I tried all combinations of it between RL/RH/RW and the only that kinda works is connecting it to RL and RW. But then i realized even then the ds3502.wiper is set to 127 the motor only goes like 60% of its total power. I don't understand why?

Here is a video of the setup: WhatsApp Video 2020-10-20 at 17.47.42.mp4 

I am puzzled why it doesn't work like the analogue potentiometer. It works just fine with the analogue potentiometer. I am puzzled and need your help. I tried googling all sorts of things but I don't know what to look for.

-------------------

I even connected the ds3502 directly to the controller to measure how it works:

RL -- black
RW --- green
RH -- red


Now I tried changing the values on the digital poti from 0 to 127. but in none of the cases i got the motor to work/turn. 

I measured these voltages when the poti was set to 0: 

RH-to-RW: 5V
RL-to-RW: 0V
RL-to-RH: 5V

When set to 127 i got:

RH-to-RW 3.5 V
RL-to-RW 1.5 V
RL-to-RH: 5V

Here is where I am puzzled shouldn't the 127 setting result in RL-to-RW being 5V and RH-to-RW 0V. Is this an explanation why the motor only gives me 60% when i open the poti 100%, in a sense its not able to get the voltage to 5V? 

------

Here is a wireing of the cart:


http://imgur.com/9rTv7oC

Here is the controller I assume is in the cart acc to my goole research: TNC Scooters - HB3650-TYD-HCH Product Specification
And here is a link to the digital potentiometer from adafruit ds3502 Adafruit DS3502 I2C Digital Potentiometer 

-------

I am thankfull for any help!


----------

