Hooking up an Arduino to an e-bike

dpe743

10 mW
Joined
Oct 22, 2015
Messages
30
Location
Northern Illinois, USA
I won't be purchasing an e-bike kit until next spring, but want to get started on the general design. One of those pieces is building my own bike computer using either an Arduino or a Raspberry Pi. So on the technical side: what types of components are easily obtainable to interface with the various controller inputs?

1) Throttle input -- if the throttle is a regular potentiometer, I can use one of the A2D pins on the Arduino
2) Throttle output (to controller) -- A digital potentiometer chip (which costs a couple bucks)
3) Reading voltage from battery -- A resistor bridge circuit would allow reading the voltage using one of the 5v A2D pins -- but would I be better off using an external A2D chip that can directly handle higher voltages?
4) Reading current draw -- again, use an A2D pin (or external A2D chip) to measure the voltage drop across a shunt resistor
5) Cadence / speed -- I'm assuming the cadence sensor that hooks on the bottom bracket is just a reed switch. For wheel speed, I could hook up a separate reed switch to the wheel (from a cheap bicycle speedometer).

I've looked through the forums, to see if there are any existing projects I could follow along for ideas, but haven't found anything that has been completed and fully documented. Also, I realize that the Cycle Analyst from Grin (Justin) can do quite a bit, but I like to experiment with some additional functionality, such as:
-- Accelerometer input to measure hill incline, to implement "hill flaten" mode
-- Using speed, and amperage and cadendce measurement to estimate pedal input wattage, to implement proper torque pedelec mode without needing a torque sensor
-- Implement a mode where you enter the miles you need to go on the trip, and have it automatically adjust the assist level so that you won't run out of juice
-- Automatically shut down the system if too high of amperage is drawn for an extended period of time.
-- gps logging
 
I have started [strike]building[/strike] Hacking something together myself.
Some ideas can be found here https://endless-sphere.com/forums/viewtopic.php?f=2&t=61407, https://endless-sphere.com/forums/viewtopic.php?f=2&t=61004, https://endless-sphere.com/forums/viewtopic.php?f=2&t=57747.

My set up
1) I don't use a throttle as I only have 200W, so just a push button for on.
2) Throttle out - I use a PWM output that is filtered with an RC filter
3) Battery voltage - Resistor divider works fine
4) Current draw - I use an Allegro Hall sensor something like this http://www.ebay.com/itm/50A-100A-15...d=100012&rk=1&rkt=10&mehot=pp&sd=111040360152. I have used a bi directional fifty amp one as that is what I had. But it is not ideal as I only draw 18 amps max and don't have regen so I only realy need 20 Amp unidirectional.
5) Cadence - My cadence sensor is more than a reed switch. It has a different output depending on if you are pedaling backwards or forwards. I have done a small write up here http://ideahex.com/. Mind you my plan was to control speed based on cadence which sort of works but what I really wanted was current based on cadence which I will try and get back to one day. I have added a nokia LCD for the read out.
Speed magnet on wheel will be fine.

I'll be interested on how you go.
 
dpe743 said:
I won't be purchasing an e-bike kit until next spring, but want to get started on the general design. One of those pieces is building my own bike computer using either an Arduino or a Raspberry Pi. So on the technical side: what types of components are easily obtainable to interface with the various controller inputs?

1) Throttle input -- if the throttle is a regular potentiometer, I can use one of the A2D pins on the Arduino
2) Throttle output (to controller) -- A digital potentiometer chip (which costs a couple bucks)
3) Reading voltage from battery -- A resistor bridge circuit would allow reading the voltage using one of the 5v A2D pins -- but would I be better off using an external A2D chip that can directly handle higher voltages?
4) Reading current draw -- again, use an A2D pin (or external A2D chip) to measure the voltage drop across a shunt resistor
5) Cadence / speed -- I'm assuming the cadence sensor that hooks on the bottom bracket is just a reed switch. For wheel speed, I could hook up a separate reed switch to the wheel (from a cheap bicycle speedometer).

I've looked through the forums, to see if there are any existing projects I could follow along for ideas, but haven't found anything that has been completed and fully documented. Also, I realize that the Cycle Analyst from Grin (Justin) can do quite a bit, but I like to experiment with some additional functionality, such as:
-- Accelerometer input to measure hill incline, to implement "hill flaten" mode
-- Using speed, and amperage and cadendce measurement to estimate pedal input wattage, to implement proper torque pedelec mode without needing a torque sensor
-- Implement a mode where you enter the miles you need to go on the trip, and have it automatically adjust the assist level so that you won't run out of juice
-- Automatically shut down the system if too high of amperage is drawn for an extended period of time.
-- gps logging


1- Throttles don't use potentiometers, they use hall sensors. The throttle circuit is voltage driven at TTL levels, not current driven. You can drive it directly from a TTL output.
2- That depends on how you want to use it. Are you trying to over ride the throttle to cut it off, or modify the signal. Most controllers have an Ebrake function that would give easier control to cut the throttle.
3- resistive bridge is the easiest way.
4- The controller contains a shunt and a resistive bridge already used for sensing current. Just tap into that.
5- no reed switches. Cadence is sensed by hall effect sensors and a ring of magnets. such things are ready made and cheap.
If you use a direct drive motor, you can get wheel speed directly off the motor's position hall sensors.
 
dpe743 said:
Also, I realize that the Cycle Analyst from Grin (Justin) can do quite a bit, but I like to experiment with some additional functionality, such as:
-- Accelerometer input to measure hill incline, to implement "hill flaten" mode
-- Using speed, and amperage and cadendce measurement to estimate pedal input wattage, to implement proper torque pedelec mode without needing a torque sensor
-- Implement a mode where you enter the miles you need to go on the trip, and have it automatically adjust the assist level so that you won't run out of juice
-- Automatically shut down the system if too high of amperage is drawn for an extended period of time.
-- gps logging

- not sure that this means. Most people moderate their throttle or PAS level for this..
- kinda neat to get the stats I guess.
- Adaptto has a functionality like this... kinda neat idea.
- GPS capable Analogger is capable of this in conjunction with CA.
 
Drunkskunk said:
1- Throttles don't use potentiometers, they use hall sensors. The throttle circuit is voltage driven at TTL levels, not current driven. You can drive it directly from a TTL output.
Ok, so that means instead of measuring resistance, I'd put a 5 volts through the throttle and measure the voltage drop directly on one of the analog pins? Sounds easier.
2- That depends on how you want to use it. Are you trying to over ride the throttle to cut it off, or modify the signal. Most controllers have an Ebrake function that would give easier control to cut the throttle.
I want to intercept the throttle using the arduino, then output my own throttle value to the controller (based on computations). So if the controller is expecting a hall sensor input, can I fake it by feeding in a variable voltage (using a digital potentiometer wired in series with a resistor, to create a variable voltage divider circuit)?
5- no reed switches. Cadence is sensed by hall effect sensors and a ring of magnets. such things are ready made and cheap.
If you use a direct drive motor, you can get wheel speed directly off the motor's position hall sensors.
The motor I was looking at is one of the geared ezee motors from ebikes.ca. But if I can still read the hall sensors from that, it will still work (just need to divide by the gear ratio).

Lurkin said:
- not sure that this means. Most people moderate their throttle or PAS level for this..
Hill flatten mode is where you have the computer increase throttle when going up hill, so to the rider it always feels like flat ground. Ideally, I'd like to have two inputs -- one would be the desired rider-effort (in watts), and the second input would be desired speed. That way, on any given trip, I could be guaranteed of getting at least a specific amount of exercise (at least based on time of ride, not distance ridden).
 
Back
Top