Looking for help designing torque-based throttle alternative

cloudcover

10 mW
Joined
Sep 8, 2009
Messages
30
hi folks -

thanks to the great information on this forum, i have an ebike setup that i absolutely love and that's dramatically increased how frequently i ride my bike. it's a surly big dummy bike with the xtracycle cargo kit and i'm coupling that with a bmc v2-t motor, an infineon controller, and a half-twist throttle. the setup is so versatile that i've really reduced how often i drive the car. very happy about that.

but i have to say that the one thing that bugs me quite a bit is the throttle. i know many people out there like the manual control that a throttle provides, but i'd be much happier with an automated pedal-assist-based approach that doesn't require me to regulate throttle manually -- like the one used in kona's (relatively) new electric bikes (for example, http://www.konaworld.com/bike.cfm?content=ticket).

so i'm hoping that some folks here can maybe help me with this project. i'm happy to be the guinea pig and willing to report results and hopefully help out others.

1. torque sensors

someone referred me to a german company called "thun" that makes a bottom bracket sensor that can measure torque (in addition to cadence and rotational direction). it's their x-cell rt sensor and here's a link to it's technical specs: http://www.thun.de/thun_eng/Datenblatt X-CELL_GB.pdf. i'm told that it runs around 100 euro.

and it seems that kona uses a different torque sensor that they call a "Dutch design TMM sensor." a quick online search led to this page: http://www.idbike.com/tmm-powermanagement.htm. don't know if it's available to retail or what the cost would be, but am happy to pursue that. unlike the thun sensor, this seems to be a unit that mounts to the rear dropout of the bike and measures chain force.

any thoughts on which of the two would be better / more reliable / etc?

2. configuration

i wanted to have some way of controlling how much motor assist is provided at maximum torque. so i was imagining some kind of simple circuit that would have an analog knob (potentiometer?) that would take the output from the torque sensor and modify it to a desired range for sending on to the controller.

an example will probably help here. let's say that we're using the thun sensor, which has an output that varies between 0 - 5V depending on the amount of torque. i don't know what the throttle input range is for the controller, but just for discussion let's say it's 0 - 1V. and let's suppose there's a "amount of assist" knob that we're going to use that has markings from 1-10.

so if i wanted to get more of a workout on a particular day and so desired only a moderate amount of electric assist, i might set the knob to 2 (corresponding to 20% of max motor assist). and that would modify the range of the torque sensor output so that instead of a voltage of 0 - 5V reaching the controller, instead that range gets modified to 0 - 0.2V.

3. the electrical wiring

i have a background in engineering, but it's now of minimal use to me because it's been so long since i've used any of that. so i'd love to get any help i could in figuring out how to mate one of the sensors described above to the controller, to achieve the functionality i mentioned. i'm sure there are things that i haven't thought of but hopefully there are some kind folks out there who're willing to help with this conversation / thread.

thanks!
cc
 
I've just made a prototype torque throttle adapter, which uses current feedback from the shunt in the controller to determine motor torque (motor torque is linearly proportional to motor current).

It's not easy to do, as ideally you need a PID controller to make it feel right (a proportional - integral - derivative controller). In simplistic terms, what I've done is measure the 'torque demand' signal (throttle twistgrip position) conventionally by just reading the voltage, the 'actual motor torque' figure by measuring the voltage across the controller shunt and then try to output a throttle signal to the controller that provides closed-loop control to allow the motor torque to track the demanded torque with minimal lag or overshoot.

This is where it gets tricky. The time constants in the loop are wildly variable, as they depend on terrain, inertia, the ability of the controller and battery pack to respond to demands etc, and the controller adapter needs to scale both the amount of throttle applied and the speed with which it's applied quite tightly to make it feel OK.

I've chosen to cheat, but I'm not sure how well it'll work yet - it still needs a lot more testing. What I've done is use a crude 'bang-bang' type approach, where the controller throttle signal is only ever full on or full off. Full on is when the demanded torque is greater than the actual torque, full off is when the demanded torque is less than the actual torque. If the system responds fast enough, and switches between these two states much more quickly than the controller can react to, then, with the addition of some simple filtering it should be able to give reasonably tight control. It works on the bench, with simulated signals, but I need the time to do some road testing before being able to confirm that this simple approach will work OK in practice.

Jeremy
 
It looks like you've got it figured out Jeremy, but if you were hunting for another option to measure phase-torque, maxim makes a pretty slick little bi-directional isolated(isolateable) current shunt A-D, and have a summing D-A they also offer that outputs in a 0-5v.

If you're looking for a simple way to know motor torque, just a shunt in 1 phase leg and this simple pair of chips seems like it would do the trick. :)


The pair of chips is something like $2 if I remember right.
 
I had thought of doing phase current, as it'd give a much better control signal, but it increases the PID problem dramatically, as the loop bandwidth needs to be maybe an order of magnitude wider. I was looking at using one of the LEM current sensors that I used on the power meter project, as they output about 2.5V either side of a mid point depending on current direction and can be had in flavours that just slip over an existing high current wire. Bandwidth is the problem though, mainly in the A-D conversion and the subsequent code. It's one of those areas where an analogue design may actually have the edge, as getting the code to run fast enough in a microcontroller is a challenge, even for the 40MHz clock chips.

I'm back working on the kitchen for now, so probably won't get a chance to play with this till the weekend.

Jeremy
 
Nice find on the thun RT, let me know if you find a supplier and actual cost. I think that would be an easy retrofit. I too have been looking for a torque sensor pedal solution. It would then allow me to focus more on my trail riding. Developing an interface for it wouldn't be too difficult.

Interesting approach Jeremy, if the code is available. I would like to play with it. Sounds like a possible cheap solution for my other ebikes.
 
Jeremy,

Technically, measuring the battery current will give you power-based throttle, not torque (that would require phase currents), but it's pretty close and a lot better than the usual. Measuring the phase currents for torque control probably isn't worth the effort unless you're already measuring them for a more advanced control scheme.

I suspect your bang-bang control will work fine so long as the loop rate is relatively quick. The time constant for all the mechanical parts of the system should be pretty slow relative to the loop rate.
 
Jeremy Harris said:
I've just made a prototype torque throttle adapter, which uses current feedback from the shunt in the controller to determine motor torque (motor torque is linearly proportional to motor current).
Jeremy
that seems like a clever approach; but also, as you mention, it seems pretty involved. if something like the thun unit is available, wouldn't it be an easier solution? and would there be any reason not to go that route? just asking because i'm looking for the simplest solution possible, given my...ahem...technical limitations. :) i'm much more inclined to go the functional route (get as many ready-made off-the-shelf parts as possible and piece them together) rather than what's probably the more interesting route (building more from scratch).
 
Jeremy Harris said:
Bandwidth is the problem though, mainly in the A-D conversion and the subsequent code. It's one of those areas where an analogue design may actually have the edge, as getting the code to run fast enough in a microcontroller is a challenge, even for the 40MHz clock chips.

Out of curiosity... what sort of loop bandwidth are you shooting for? Isn't there an outer loop in this system that involves a human?

From test-riding a BionX setup a while back, I recall a noticeable delay in feeling the motor engage after applying power at the pedals.
 
You still need to find a way to drive the controller in torque/power mode, rather than in speed mode, so whatever sensor you choose to use, you still need to find a way to adapt the controller. Controllers are normally driven by a voltage signal that directly controls the voltage to the motor (by varying the PWM ratio) so are intrinsically speed control devices. What you need is a controller that accepts a torque, or maybe power, input control, and they are rare on ebikes.

I've opted for the simple approach of using a twist grip for the 'torque/power demand' signal, but you could just as easily use a pedal sensor or whatever. Using a pedal torque sensor doesn't remove the need to find a way to drive the controller differently though, you still need some form of current/torque/power feedback from the controller and a way to match that to the demand coming from your sensor. This is still a PID control problem, unfortunately.

busted_bike said:
Out of curiosity... what sort of loop bandwidth are you shooting for? Isn't there an outer loop in this system that involves a human?

The PID loop needs to work fast enough to prevent the torque/power overshooting and undershooting the demand and so probably needs to run at a speed of at least 10Hz to be reasonably free from jerkiness. What I need to avoid is the situation where the rider demands power, the controller applies too much power, then cuts back too quickly. It may be that the loop can run slower than this. At the moment, the time between program cycles on my prototype varies between about 20mS and 30mS, depending on the actual values being processed, so I will be running at around 30 to 50Hz.

Jeremy
 
Jeremy Harris said:
The PID loop needs to work fast enough to prevent the torque/power overshooting and undershooting the demand and so probably needs to run at a speed of at least 10Hz to be reasonably free from jerkiness. What I need to avoid is the situation where the rider demands power, the controller applies too much power, then cuts back too quickly. It may be that the loop can run slower than this. At the moment, the time between program cycles on my prototype varies between about 20mS and 30mS, depending on the actual values being processed, so I will be running at around 30 to 50Hz.
Jeremy

Right, that sounds pretty reasonable. From memory, I'd guess that the latency of the BionX system was well under a second but still enough for me to notice... so maybe 300ms.
 
My guess is that Bionx have come up against the same issues I have - making a proper PID loop (which is almost certainly what they use) run fast enough to avoid lag needs a very fast processor. They've probably just accepted the lag as a trade-off for using a reasonable cheap and simple controller.

Jeremy
 
You're probably right. I also don't recall any noticeable torque ripple once I got going. They might have traded off the latency for low ripple though, via a more complex control algorithm.

If you find that the bang-bang controller produces noticeable torque ripple, you might consider something less than full PID (e.g. integral control only, tuned way down to avoid ringing) to minimize the load on the processor. Maybe you'll find that it's fast enough that a human can't feel the torque ripple... I hope I'll share your results.
 
If I was to build one, I would try fitting a twist throttle to a chain tensioner. This would make it fully asjustable, by simple setting of the tensioner resistance. The more you bind the chain with pedal torque, the more the tensioner opens, so the throttle.

Maybe too simple to work nice, but worth a try.
 
You might want to have a look at the UK pedelec forum for some ideas.
One discussion on DIY sesnsor drive http://www.pedelecs.co.uk/forum/electric-bicycles/1172-home-made-pedelec-pedal-torque-sensor.html

Also both the Giant Lafree and Aprilia have torque and pedal cadence sensors. The Aprilia does not have a throttle but uses a three position switch: economy, normal & hills.

Someone on the Italian forum built their own torque sensor to replace a broken Aprilia one. You can use google translate of the post http://www.jobike.it/forum/topic.asp?TOPIC_ID=702&whichpage=5


Also look at Currie / iZip. The manual here on page 34 shows they use both PTS (pedal torque sensor) and TMM4 frame torque sensor
http://www.izipusa.com/pdf/iZipBikeOM2008-10-02.pdf you can probably buy them as a spare part http://www.currietech.com/currie-technologies-help-and-support.php
 
jateureka said:
You might want to have a look at the UK pedelec forum for some ideas.
One discussion on DIY sesnsor drive http://www.pedelecs.co.uk/forum/electric-bicycles/1172-home-made-pedelec-pedal-torque-sensor.html

Good grief! I started that thread on the pedelecs forum nearly three ago, when I first started playing with ebikes and before the pomposity of the self-appointed chief geek on that forum started to get right up my nose. What I can say is, don't bother trying the indirect chain tension sensing system, via an idler with a strain gauge, that I first came up with in that thread - it doesn't work. The problem is that it's impossible to determine the difference between the chain tension related signal and artefacts caused by vertical accelerations from bumps and dips in the road (the latter bounce the chain up and down and produce false 'tension' signals).

The thread seems to have grown into a useful collection of torque sensing ideas though, so is a good resource.

Jeremy
 
One of the things I originally (still) wanted to do with CrazyBike2 is to have a throttle control based on pedalling load, to keep my assist constant, basically doing exactly what the OP proposes, in terms of how it would affect things.

I was going to use a roller on the top of the pedal chain, with a spring loaded lever pressing it onto the chain to hold tension. At the pivot a magnet would control a throttle sensor, which would be processed by a set of adjustable op-amp circuits. I'm not very good at designing op-amp stuff, though, so I never did end up building it (that plus too many projects/etc. to have time to).

Since it would be realtime analog, there's no processing power to worry about, and no program to write (did I mention I get along with code as well as I do math? ;) ), and while harder to tweak in the design phase would be easier to provide controls for realtime adjustment of things (for me).

The first op-amp would de-offset the output from the hall throttle. The second would scale it. The third would adjust it with feedback from controller current draw and/or motor phase current (relatively simple since I was using brushed motors on CB2, so only one phase to deal with). A fourth would adjust this with feedback from wheel speed.

A fifth could scale and add in extra override voltage from the hand-throttle, which could be used either to just add emergency instant power for avoidance, etc., or for complete control of the motor in the case of a breakdown of the pedal sensor or if not pedalling was desirable for any reason.

A sixth (or more) could monitor *both* wheel speeds front and rear to provide a traction-control, especially if the pedal drivetrain is not running the same wheel as the motor is.


Another thing mine would do is provide a resistive throttle output option, for those controllers (mainly brushed) that require one.

Regarding the problem of bumps and dips causing chain and sensor bounce, I had another plan that would use an accelerometer to determine vertical movements and add in or subtract voltage scaled from that to the throttle control, to help eliminate the bounce problem.
 
Somewhere I may still have the datafile from the logger made during the tests on the idler roller sensing unit I made. The noise was maybe five to ten times greater than the wanted signal, unfortunately, which is what put me off the idea. The sensor I made was just a rigid alloy arm with strain gauges on it, with a standard idler fitted to the end. It replaced the idler wheel that sat under the seat of my recumbent and did the same job in leading the tension side of the chain around the slight bend at the front of the seat.

I was really quite surprised at how low the chain tension signal was when compared to the noise from bumps. With the bike stationary, the sensor worked fine, giving a really good signal that was proportional to chain tension and I was very hopeful of getting a decent pedal controlled assist system from it. The first road test of the sensor made it clear that it wasn't going to be easy to either filter out, or cancel out, the vertical acceleration induced artefacts.

Your idea sounds reasonable, but having spent a lot of time fitting accelerometers to things I think you may find it hard to get the same accelerations at the cancellation accelerometer as you get at the chain sensor. There will probably be appreciable phase differences, enough to make cancellation over a wide frequency range challenging. We used to find that moving an accelerometer just a few mm on a bit of structure could completely change the signal, particularly for shock type inputs.

Jeremy
 
I suspected it would not have been as easy as I'd hoped. I wonder if the spring tension I'd be using would be significant enough to help smooth out some of the vertical accelerations? Also, since I would be using a hall and magnet on a pivot, would it make much difference to the signal output compared to a strain gauge on a fixed bar?
 
Jeremy Harris said:
I've just made a prototype torque throttle adapter, which uses current feedback from the shunt in the controller to determine motor torque (motor torque is linearly proportional to motor current).

It's not easy to do, as ideally you need a PID controller to make it feel right (a proportional - integral - derivative controller). In simplistic terms, what I've done is measure the 'torque demand' signal (throttle twistgrip position) conventionally by just reading the voltage, the 'actual motor torque' figure by measuring the voltage across the controller shunt and then try to output a throttle signal to the controller that provides closed-loop control to allow the motor torque to track the demanded torque with minimal lag or overshoot.

This is where it gets tricky. The time constants in the loop are wildly variable, as they depend on terrain, inertia, the ability of the controller and battery pack to respond to demands etc, and the controller adapter needs to scale both the amount of throttle applied and the speed with which it's applied quite tightly to make it feel OK.

I've chosen to cheat, but I'm not sure how well it'll work yet - it still needs a lot more testing. What I've done is use a crude 'bang-bang' type approach, where the controller throttle signal is only ever full on or full off. Full on is when the demanded torque is greater than the actual torque, full off is when the demanded torque is less than the actual torque. If the system responds fast enough, and switches between these two states much more quickly than the controller can react to, then, with the addition of some simple filtering it should be able to give reasonably tight control. It works on the bench, with simulated signals, but I need the time to do some road testing before being able to confirm that this simple approach will work OK in practice.

Jeremy

Hi Jeremy, I've been thinking about a Torque based throttle as this would suit electric bikes better than speed based throttle. I live pretty close to you and would be more than happy to test out any of your inventions on my bike.
 
Cant you do that with a CA? it has the PID loop ,-- would you need to shunt one of the phase wires for true torque sensing?

I also am very intereseted in a tourque based throttle.

Mike
 
If the CA limiter does do PID type control, then the answer is probably a reserved yes. Justin might be able to shed more light on how the CA limiter works and whether or not it does use anything as relatively sophisticated as a true PID loop when holding to a preset limit.

If it does, then my guess is that all that's needed is to find a way to get the CA to accept a throttle input to provide a variable current limit. As it stands, the CA monitors battery current, so as has already been pointed out, this would be power control, rather than true torque control, but I reckon this would still feel better than speed control.

Phase current measurement would be good, but it isn't that easy to do. The best way to do it would probably be with a Hall-type current sensor, followed by some filtering to get the average phase current, in order to ease the task of A/D conversion and reduce the impact of aliasing artefacts.

Jeremy
 
Jeremy Harris said:
You still need to find a way to drive the controller in torque/power mode, rather than in speed mode, so whatever sensor you choose to use, you still need to find a way to adapt the controller. Controllers are normally driven by a voltage signal that directly controls the voltage to the motor (by varying the PWM ratio) so are intrinsically speed control devices. What you need is a controller that accepts a torque, or maybe power, input control, and they are rare on ebikes.
Jeremy
sorry for being dense about this, but i'm afraid i still don't quite understand. :? i was thinking something simple like this:

1. based on a quick search, it seems that the throttle input on the infineon controller that i have ranges from 1-4V.
2. it looks like the thun sensor's torque sensor outputs a voltage that varies in proportion to the torque and ranges from 1-5V.
3. given that, couldn't i just build a simple analog circuit that reduces the torque sensor's voltage output by 20% and feed that resulting votage into the throttle input of the controller?

in other words: controller throttle input (V) = k * torque sensor output (V).

or maybe what you're saying is that, although simple, this wouldn't yield the "effect" i'm looking for, which is a system that automatically varies the amount of motor assist to keep my physical pedaling contribution remain constant -- i.e., so that my level of exertion remains (relatively) constant.
 
The problem is that the controller has a speed throttle input. Typically, 4V gives max rpm, 1V gives zero rpm so 2.5V gives around half maximum rpm. Now, if the motor is loaded down, then the controller will try and provide enough current to get the motor back to the commanded rpm. What you're after is a controller where the throttle signal provides a commanded torque.

Fitting a torque sensor and using it to drive a speed input may have the following sort of effect:

Say you have a motor capable of 20mph at full throttle and you want to cruise on the flat at 15mph with no wind. This needs a motor rpm of 75%, so the controller throttle input needs to be 75% of maximum in order to drive the motor fast enough. This means that you need 75% of the maximum output from your torque sensor, when in reality the pedal torque might be as low as 10% - 20% for this condition; not anywhere near enough to drive the controller to the required motor rpm. The only way around this would be to fit very tall gears so that you could pedal at a very low cadence with a high torque, which isn't really practical and doesn't really fit with what I think you're looking for.

What you need is a way to control the torque (or perhaps power) delivered by the controller, rather than the motor rpm. To do this means measuring the delivered motor torque (or power) and comparing this to the demanded torque (or power) from the input command (be it a throttle or pedal sensor). In effect, you want to be able to control the current that the controller allows the motor to draw, rather than control the voltage that the controller applies to the motor.

The proper way to do this would be to have a controller that has a variable phase current limit, with the control for that phase current limit provided by the throttle signal. Unfortunately, typical ebike controllers don't have this form of control, so we need to spoof them into working this way by adding some external circuitry to give variable current limiting. Because phase current is relatively difficult to measure, we can 'cheat' and measure battery current and get, in effect, motor power control, which is probably good enough.

There may be a way to hack the current limiting circuit in the controller to do this, I think. The controller already senses battery current, so breaking that link and modifying the current feedback signal, whilst providing a full throttle signal as a speed input, might allow reasonably effective power control. If I get time I may have a look to see how easy (or otherwise) this may be to do.

Jeremy
 
Jeremy Harris said:
Say you have a motor capable of 20mph at full throttle and you want to cruise on the flat at 15mph with no wind. This needs a motor rpm of 75%, so the controller throttle input needs to be 75% of maximum in order to drive the motor fast enough. This means that you need 75% of the maximum output from your torque sensor, when in reality the pedal torque might be as low as 10% - 20% for this condition; not anywhere near enough to drive the controller to the required motor rpm. The only way around this would be to fit very tall gears so that you could pedal at a very low cadence with a high torque, which isn't really practical and doesn't really fit with what I think you're looking for.Jeremy
hmmm...probably pays to make sure we're on the same page in terms of what i was trying to achieve. :) what i'm really looking for is a system that will ensure that the pedaling force that i'm expending (i.e., my muscle contribution) does not exceed a predefined amount. i don't really care much about what speed i'm going...i'm mostly concerned about getting some motor assist on hills to take away some of the required effort. another way to think of it is that i'm looking for a system that will serve as an "effective slope of the road" controller: something that will make sure that no hill feels greater than an x% incline.

so given that description of the objective, it still seems to me that a simple proportional voltage from the torque sensor to the throttle input of the controller should work. after all, that's basically what i'm doing with my throttle, manually. when i'm on a flat road, i'm using no throttle. and as i start up a hill, i gradually increase the throttle as the pedaling gets harder, until i've increased it enough so the pedaling effort is a comfortable (greater than zero) level.

so, in your example, if i want to cruise on the flat where my pedal torque is quite low, i'm happy to do so with no (or very minimal) motor input -- mainly under my own power at whatever speed that gets me. i won't be seeking something like a constant 15mph. i just don't want my pedal torque (i.e., maximum muscle input) to exceed some pre-defined amount (say 25%). so whenever the pedal torque started to exceed that amount (say as i'm starting up a hill), i'd want the motor to keep adding power (i.e., analogous to increasing throttle) so that my pedal torque remained no more than 25%.

hope that clarifies what i was trying to achieve and maybe it alters your view of what's needed.

thanks again!
 
Back
Top