
AC drive programming and pedal mapping
- weber
- Site Admin
- Posts: 2799
- Joined: Fri, 23 Jan 2009, 17:27
- Real Name: Dave Keenan
- Location: Brisbane
- Contact:
AC drive programming and pedal mapping
When you put the regen slider down near zero it becomes essentially torque control (but with a square law on the torque and requested speed going to zero at zero pedal). Same formulas.


One of the fathers of MeXy the electric MX-5, along with Coulomb and Newton (Jeff Owen).
- weber
- Site Admin
- Posts: 2799
- Joined: Fri, 23 Jan 2009, 17:27
- Real Name: Dave Keenan
- Location: Brisbane
- Contact:
AC drive programming and pedal mapping
Oh, but I forgot to mention that because torque(really current) requests are unsigned, what you actually have to send to the VF drive is the following.
[Edit: Tritium_James explains later why this is not necessary and the previously posted curves are just fine.]
Note that the speed curve must be very specific to ensure that the drive gets the correct sign for the torque. So you can see why I find unsigned torque strange.

[Edit: Changed chart to show more accurate curves]
[Edit: Tritium_James explains later why this is not necessary and the previously posted curves are just fine.]
Note that the speed curve must be very specific to ensure that the drive gets the correct sign for the torque. So you can see why I find unsigned torque strange.

[Edit: Changed chart to show more accurate curves]
Last edited by weber on Wed, 23 Nov 2011, 11:58, edited 1 time in total.
One of the fathers of MeXy the electric MX-5, along with Coulomb and Newton (Jeff Owen).
AC drive programming and pedal mapping
Will this aproach be for the wavesculpter or an industrial drive.
It is useful for any EV in getting a good mapping of throttle positioning to motor load.
The Propulse (EV focused) controller talks in terms of Power not torque and has a dial to adjust max power output. But could be a translation issue and be torque in the way it controls the motor.
It makes more sense to have throttle controlling torque, with some compensation for speed so adjust regen levels.
It is useful for any EV in getting a good mapping of throttle positioning to motor load.
The Propulse (EV focused) controller talks in terms of Power not torque and has a dial to adjust max power output. But could be a translation issue and be torque in the way it controls the motor.
It makes more sense to have throttle controlling torque, with some compensation for speed so adjust regen levels.
- woody
- Senior Member
- Posts: 1716
- Joined: Sat, 21 Jun 2008, 02:03
- Real Name: Anthony Wood
- Location: Mt Colah
AC drive programming and pedal mapping
One crazy idea I had for ice-like pedal response was to do some rough sums on the ICE - e.g. throttle position X = Y sq cm of throttle opening.
at X rpm = Y litres of air per second
calculate suction on the cylinders => engine braking
air volume ~ power
I didn't get very far with this, obviously
Are you going to try and sync the motor with the gearbox when you push the clutch in? I.E. work out gear ratio by comparing motor and tailshaft speed, then on clutch pedal change motor speed to match next gear (with low torque demand)
at X rpm = Y litres of air per second
calculate suction on the cylinders => engine braking
air volume ~ power
I didn't get very far with this, obviously

Are you going to try and sync the motor with the gearbox when you push the clutch in? I.E. work out gear ratio by comparing motor and tailshaft speed, then on clutch pedal change motor speed to match next gear (with low torque demand)
Planned EV: '63 Cortina using AC and LiFePO4 Battery Pack
- coulomb
- Site Admin
- Posts: 4420
- Joined: Thu, 22 Jan 2009, 20:32
- Real Name: Mike Van Emmerik
- Location: Brisbane
- Contact:
AC drive programming and pedal mapping
weber wrote: Oh, but I forgot to mention that because torque(really current) requests are unsigned, what you actually have to send to the VF drive is the following...
I wonder if you can add a term in there linear with pedal position such that the inflections occur along a line starting at 0,0 and sloping slightly down, so that when you do the calculation and reject negative values (oops, but having reflected the left part of the line already), you end up with short "dead spots" on the pedal graph, which allow for coasting if desired.
Or really, I guess what is wanted is to pull the curve apart at the reflection point, and add a short dead zone there. So you would shorten the graph along the x-axis by say 5%, and insert 5% of zero torque/current where the inflection hits the y-axis (where it previously just touched zero torque at a single point).
I don't know if this dead zone would ruin the cool feeling that TJ describes. If so, maybe the dead spot also needs to be adjustable or at least switchable. It starts to get difficult to present these options to the user in a reasonable way. What English-free "international" symbols would you put on the maximum regen slider and the dead zone switch?
Nissan Leaf 2012 with new battery May 2019.
5650 W solar, 2xPIP-4048MS inverters, 16 kWh battery.
1.4 kW solar with 1.2 kW Latronics inverter and FIT.
160 W solar, 2.5 kWh 24 V battery for lights.
Patching PIP-4048/5048 inverter-chargers.
5650 W solar, 2xPIP-4048MS inverters, 16 kWh battery.
1.4 kW solar with 1.2 kW Latronics inverter and FIT.
160 W solar, 2.5 kWh 24 V battery for lights.
Patching PIP-4048/5048 inverter-chargers.
- weber
- Site Admin
- Posts: 2799
- Joined: Fri, 23 Jan 2009, 17:27
- Real Name: Dave Keenan
- Location: Brisbane
- Contact:
AC drive programming and pedal mapping
We are currently using the WaveSculptor, but it is equally applicable to industrial drives (like the Control Techniques drive we still have, which would be great for a van or ute, and can overvoltage a motor twice a much as a WaveSculptor can. Hint. Hint.7circle wrote: Will this aproach be for the wavesculpter or an industrial drive.

I suppose that means we've departed a little from the title of this thread. But I started it, and I'm quite happy that it has become the "Pedal Mapping" thread.
I'm glad you think so. The more I look at it, the more obviously right it seems, but the real test will only come with the driving. I'm afraid that may yet be some months away. Tritium James could try it much sooner in the Civic.It is useful for any EV in getting a good mapping of throttle positioning to motor load.
Could be a translation problem, but if it's really power and not torque, then just take my requested torque function and multiply it by actual speed to get requested power.The Propulse (EV focused) controller talks in terms of Power not torque and has a dial to adjust max power output. But could be a translation issue and be torque in the way it controls the motor.
T = p^2 + (p^2-1)*k*s
P = T * s
= p^2*s + (p^2-1)*k*s^2
where T is requested torque, P is requested power, p is pedal position, k is max regen and s is actual speed.
Yes. That is a minimum requirement for anything resembling ICE response, and I believe the above curves do it as smoothly and simply as possible. Although I note that there is also an equivalent formulation where the accelerator pedal (there is no throttle any more) controls speed, with some compensation for actual torque to adjust regen levels. That's how Ross Pink did it. I may have a go at plotting a smoothed version of that scenario later.It makes more sense to have throttle controlling torque, with some compensation for speed so adjust regen levels.
And of course, the pedal controlling requested power with compensation for actual speed, can be made equivalent as above.
Last edited by weber on Sun, 02 Jan 2011, 07:31, edited 1 time in total.
One of the fathers of MeXy the electric MX-5, along with Coulomb and Newton (Jeff Owen).
- weber
- Site Admin
- Posts: 2799
- Joined: Fri, 23 Jan 2009, 17:27
- Real Name: Dave Keenan
- Location: Brisbane
- Contact:
AC drive programming and pedal mapping
I can help you with the first part. A sketch and a bit of trig shows that (normalised) throttle opening cross-section is just 1-cos(pi/2*p). It's possible that the other factors are approximately linear (until they hit their limits).woody wrote: One crazy idea I had for ice-like pedal response was to do some rough sums on the ICE - e.g. throttle position X = Y sq cm of throttle opening.
at X rpm = Y litres of air per second
calculate suction on the cylinders => engine braking
air volume ~ power
I didn't get very far with this, obviously
There is no significant difference between a 1-cos(pi/2*p) pedal response and an x^2 pedal response, in the range 0 to 1. But x^2 is a lot easier to program on a microcontroller. Not so easy for an analog circuit. Easiest nonlinear functions for analog are log and exponential, using diodes. The following scaled and offset exponential function is very close: (8^p-1)/7. Or else it can be done piecewise-linear.

No. We just plan to have pedal response close enough to ICE response that you will change gears in exactly the same way as with an ICE. I believe that the requested-speed curve shows exactly what speed you will get for your pedal position when the clutch pedal is in (or you're in neutral), except that there will also be maximum ramp rates that simulate an ICE flywheel to the minimum degree necessary.Are you going to try and sync the motor with the gearbox when you push the clutch in? I.E. work out gear ratio by comparing motor and tailshaft speed, then on clutch pedal change motor speed to match next gear (with low torque demand)
There will also need to be a modification to the mapping to include an idle speed at zero pedal in the case where the aircon is on and the gearbox is in neutral or the clutch pedal is in.
[Edit: Added chart]
Last edited by weber on Sun, 02 Jan 2011, 06:52, edited 1 time in total.
One of the fathers of MeXy the electric MX-5, along with Coulomb and Newton (Jeff Owen).
- weber
- Site Admin
- Posts: 2799
- Joined: Fri, 23 Jan 2009, 17:27
- Real Name: Dave Keenan
- Location: Brisbane
- Contact:
AC drive programming and pedal mapping
I edited a chart into my previous post in this thread, showing how three different mathematical formulae give very similar curves.
I've also changed the thread title from "Industrial AC drive programming" to "AC drive programming and pedal mapping" at coulomb's suggestion. Thanks coulomb, for telling me how (just edit the first message).
In our case you can always coast by taking your foot off the accelerator and holding the clutch pedal in, or putting it in neutral, as with any ICE car.
I can however see the need for a small amount of hysteresis in the pedal response, which is a very different thing. It would prevent small bumps and jiggles from changing the set points, at any pedal position, and break possible nasty destabilising feedback loops between vehicle accelleration, your foot and the pedal position parameter.

[Edit: Added part about coasting in neutral]
I've also changed the thread title from "Industrial AC drive programming" to "AC drive programming and pedal mapping" at coulomb's suggestion. Thanks coulomb, for telling me how (just edit the first message).
I don't understand the desire for such dead zones at zero torque at all. I don't experience them in an ICE. If coasting is good, regen is even better. I think they would ruin the "cool feeling".coulomb wrote:I wonder if you can add a term in there ... [so] you end up with short "dead spots" on the pedal graph, which allow for coasting if desired.
...
I don't know if this dead zone would ruin the cool feeling that TJ describes. If so, maybe the dead spot also needs to be adjustable or at least switchable.
In our case you can always coast by taking your foot off the accelerator and holding the clutch pedal in, or putting it in neutral, as with any ICE car.
I can however see the need for a small amount of hysteresis in the pedal response, which is a very different thing. It would prevent small bumps and jiggles from changing the set points, at any pedal position, and break possible nasty destabilising feedback loops between vehicle accelleration, your foot and the pedal position parameter.
No dead zone switch required, but max regen slider could be:It starts to get difficult to present these options to the user in a reasonable way. What English-free "international" symbols would you put on the maximum regen slider and the dead zone switch?

[Edit: Added part about coasting in neutral]
Last edited by weber on Sun, 02 Jan 2011, 07:30, edited 1 time in total.
One of the fathers of MeXy the electric MX-5, along with Coulomb and Newton (Jeff Owen).
-
- Senior Member
- Posts: 683
- Joined: Wed, 04 Mar 2009, 17:15
- Real Name: James Kennedy
- Contact:
AC drive programming and pedal mapping
Weber, I reckon that mapping would be quite nice. It gives a similar effect to what the setup with an ACP system is, where the 'zero' point of the pedal moves along the range of travel as speed increases. This means no dead pedal travel when moving off from a stop, but regen controllable by the same pedal once you're moving.
FYI, the ACP system had a linear movement of the 'zero' point between pedal fully up at 0km/h and about 1/3 of the way down at 10-15km/h. So your proposed movement of 0 to full regen over 40% travel is slightly more physical travel, and up to 100% speed (compared to 10-15km/h) is a much bigger band. I think the only way to know if this is better or worse is to try it and see!
FYI, the ACP system had a linear movement of the 'zero' point between pedal fully up at 0km/h and about 1/3 of the way down at 10-15km/h. So your proposed movement of 0 to full regen over 40% travel is slightly more physical travel, and up to 100% speed (compared to 10-15km/h) is a much bigger band. I think the only way to know if this is better or worse is to try it and see!
- coulomb
- Site Admin
- Posts: 4420
- Joined: Thu, 22 Jan 2009, 20:32
- Real Name: Mike Van Emmerik
- Location: Brisbane
- Contact:
AC drive programming and pedal mapping
Right. But an ICE doesn't have extreme regen either (well, I suppose that first gear is an exception, but that can get annoying too, with those waves of decompression that sometimes happen).weber wrote: I don't understand the desire for such dead zones at zero torque at all. I don't experience them in an ICE.
Are you considering a clutch switch then? Surely by putting in the clutch, the motor will go to zero speed (yes, the vehicle will coast), but then changing down a gear would be more difficult. Even changing up a gear might be more difficult than of the motor and vehicle could both coast. Then again, the low inertia of the motor may negate that problem.In our case you can always coast by taking your foot off the accelerator
With an ICE, the engine has a fair bit more inertia, and won't go to zero speed unless something goes wrong (stalled engine). I suspect that having the motor go almost instantaneously to zero RPM when the pedal is released will feel unnatural.and holding the clutch pedal in, or putting it in neutral, as with any ICE car.
Simulating slack in the pedal cable and/or throttle linkages, perhaps. Or perhaps our pedal cable will provide natural hysteresis as it isI can however see the need for a small amount of hysteresis in the pedal response,

Granted, but I'm not sure that hysteresis would feel familiar or desirable either.which is a very different thing.
Well, it will prevent bumps from changing the set points in one direction, but not the other. If I understand what you want to do correctly (I probably don't).It would prevent small bumps and jiggles from changing the set points, at any pedal position,
Yes, those would be bad.and break possible nasty destabilising feedback loops between vehicle acceleration, your foot and the pedal position parameter.
The letter B is English; not allowed. Though I notice that some symbols have "ABS" in them.max regen slider could be:
I suggest something like

The red colour isn't necessary or probably even desirable; it's just the first brake symbol I found, and I added the lightning bolt to suggest electricity.
Nissan Leaf 2012 with new battery May 2019.
5650 W solar, 2xPIP-4048MS inverters, 16 kWh battery.
1.4 kW solar with 1.2 kW Latronics inverter and FIT.
160 W solar, 2.5 kWh 24 V battery for lights.
Patching PIP-4048/5048 inverter-chargers.
5650 W solar, 2xPIP-4048MS inverters, 16 kWh battery.
1.4 kW solar with 1.2 kW Latronics inverter and FIT.
160 W solar, 2.5 kWh 24 V battery for lights.
Patching PIP-4048/5048 inverter-chargers.
-
- Senior Member
- Posts: 683
- Joined: Wed, 04 Mar 2009, 17:15
- Real Name: James Kennedy
- Contact:
AC drive programming and pedal mapping
'B' is used in plenty of mainstream EVs (Leaf, iMiev, etc) to indicate the drive mode that has increased regen (compared to 'D' mode).
Weber, the Wavesculptor uses the absolute value of the incoming command torque, so no need to reflect your torque commands in the Y axis. You're still only going to get regen if command rpm is less than actual rpm, though.
Weber, the Wavesculptor uses the absolute value of the incoming command torque, so no need to reflect your torque commands in the Y axis. You're still only going to get regen if command rpm is less than actual rpm, though.
- weber
- Site Admin
- Posts: 2799
- Joined: Fri, 23 Jan 2009, 17:27
- Real Name: Dave Keenan
- Location: Brisbane
- Contact:
AC drive programming and pedal mapping
But don't forget, that with my mapping (as with Ross Pink's and AC Propulsion's but not Azure Dynamics'), at zero "throttle" as the speed decreases so does the torque, so the speed will decrease at an ever-decreasing rate. If it wasn't for losses it might be like Zeno's paradox and never actually get to zero.coulomb wrote:Right. But an ICE doesn't have extreme regen either.weber wrote: I don't understand the desire for such dead zones at zero torque at all. I don't experience them in an ICE.

As mentioned in reply to Woody, a clutch switch would be good for aircon idle. We already have a neutral switch and a reverse switch on the standard MX-5 manual gearbox. But it might be a good idea to use the clutch switch also to reduce the max regen to something small when the clutch pedal is in.Are you considering a clutch switch then?
Right. The low inertia may work to your advantage as well. With your foot off the accelerator and the motor stopped, the torque is zero, so the synchro-mesh may spin it up again more easily. I'll worry about it after we've tried it.Surely by putting in the clutch, the motor will go to zero speed (yes, the vehicle will coast), but then changing down a gear would be more difficult. Even changing up a gear might be more difficult than of the motor and vehicle could both coast. Then again, the low inertia of the motor may negate that problem.
You must have missed my post in reply to Woody above. I mentioned setting maximum ramp rates to simulate a light flywheel. Then again, we do actually have a light flywheel.With an ICE, the engine has a fair bit more inertia, and won't go to zero speed unless something goes wrong (stalled engine). I suspect that having the motor go almost instantaneously to zero RPM when the pedal is released will feel unnatural.
It's also German and a few other European languages and Japanese(phonetically). What's next to the "gear lever" position for increased regen braking in your Prius?The letter B is English; not allowed. Though I notice that some symbols have "ABS" in them.
Last edited by weber on Sun, 02 Jan 2011, 18:22, edited 1 time in total.
One of the fathers of MeXy the electric MX-5, along with Coulomb and Newton (Jeff Owen).
- weber
- Site Admin
- Posts: 2799
- Joined: Fri, 23 Jan 2009, 17:27
- Real Name: Dave Keenan
- Location: Brisbane
- Contact:
AC drive programming and pedal mapping
Here's a chart showing the mapping when the max regen slider is in an intermediate position. This time 10% max regen. Possibly more like a real ICE.


One of the fathers of MeXy the electric MX-5, along with Coulomb and Newton (Jeff Owen).
- weber
- Site Admin
- Posts: 2799
- Joined: Fri, 23 Jan 2009, 17:27
- Real Name: Dave Keenan
- Location: Brisbane
- Contact:
AC drive programming and pedal mapping
Here's another way of looking at the same data. Instead of putting pedal position on the horizontal axis and showing torque curves for various actual speeds, we put actual speed on the horizontal axis and show torque curves for various pedal positions.




Last edited by weber on Mon, 03 Jan 2011, 06:26, edited 1 time in total.
One of the fathers of MeXy the electric MX-5, along with Coulomb and Newton (Jeff Owen).
- weber
- Site Admin
- Posts: 2799
- Joined: Fri, 23 Jan 2009, 17:27
- Real Name: Dave Keenan
- Location: Brisbane
- Contact:
AC drive programming and pedal mapping
Here's the C source-code for the parts of "process_pedal()" we changed in Tritium's Driver Controls unit:
void process_pedal( unsigned int analog_a, unsigned int analog_b, unsigned int analog_c, float motor_rpm)
...
// Scale pedal input
pedal = pedal / PEDAL_TRAVEL;
// Check pedal limit and clip upper travel region
if(pedal > 1.0) pedal = 1.0;
...
// Dave Keenan's quadratic accelerator-pedal regen algorithm
// See viewtopic.php?p=30613&t=1859#p30613
float normalised_rpm = motor_rpm / RPM_FWD_MAX;
float p2 = pedal*pedal; // p2 is pedal squared
command.current = (CURRENT_MAX * (p2 + (p2-1)*regen*normalised_rpm));
if (p2 >= ((1-p2)*regen))
command.rpm = RPM_FWD_MAX;
else
command.rpm = RPM_FWD_MAX * p2/((1-p2)*regen);
I note that the above avoids divide-by-zero and floating-point-overflow problems that a literal implementation of the previously given algebraic equations would have.
However there are some minor jerky artifacts at present when driving the MX-5 with this code. These are apparently due to the fact that drive commands are sent to the WaveSculptor every 100 ms but the WaveScupltor only sends motor_rpm every 200 ms. James is working on a solution.
[Edit: URL font change]
[Edit: Fixed broken link to Tritium. Corrected spelling.]
void process_pedal( unsigned int analog_a, unsigned int analog_b, unsigned int analog_c, float motor_rpm)
...
// Scale pedal input
pedal = pedal / PEDAL_TRAVEL;
// Check pedal limit and clip upper travel region
if(pedal > 1.0) pedal = 1.0;
...
// Dave Keenan's quadratic accelerator-pedal regen algorithm
// See viewtopic.php?p=30613&t=1859#p30613
float normalised_rpm = motor_rpm / RPM_FWD_MAX;
float p2 = pedal*pedal; // p2 is pedal squared
command.current = (CURRENT_MAX * (p2 + (p2-1)*regen*normalised_rpm));
if (p2 >= ((1-p2)*regen))
command.rpm = RPM_FWD_MAX;
else
command.rpm = RPM_FWD_MAX * p2/((1-p2)*regen);
I note that the above avoids divide-by-zero and floating-point-overflow problems that a literal implementation of the previously given algebraic equations would have.
However there are some minor jerky artifacts at present when driving the MX-5 with this code. These are apparently due to the fact that drive commands are sent to the WaveSculptor every 100 ms but the WaveScupltor only sends motor_rpm every 200 ms. James is working on a solution.
[Edit: URL font change]
[Edit: Fixed broken link to Tritium. Corrected spelling.]
Last edited by weber on Wed, 20 Mar 2013, 09:24, edited 1 time in total.
One of the fathers of MeXy the electric MX-5, along with Coulomb and Newton (Jeff Owen).
-
- Groupie
- Posts: 219
- Joined: Sun, 29 Aug 2010, 18:55
- Real Name: Robert Fox
- Location: Cobargo NSW
AC drive programming and pedal mapping
Weber has kindly made the re-writes of the code for me to load into my Tritium Driver Controls Unit.
After some hiccups, I have got the code compiled and into the DCU.
I can report that according to Tritium's DCtest program it seems to be working as it should. For example:

shows that the requested speed at about 10% pedal position is 1880rpm as predicted by the formula for a speed of zero. That is, 1880rpm is the speed at which the request for torque (current) is zero. At higher speeds the requested current is negative.
At zero speed, [Edit No, I mean zero pedal.] the program shows requested current is linearly negative up to a maximum of 25% of maximum current at 4000rpm. (Thus verifying the relation T = - k*s when p=0.)
Now 4000 rpm is about 150km/hr for my car, but if I need more regen at any given speed, I can always shift down a gear thereby increasing the speed as seen by the motor.
In relation to the comment of Weber's about 5Hz speed reports from the controller, I checked with Tritium whether anything had been done about the problem Weber mentions. Apparently not.
After some hiccups, I have got the code compiled and into the DCU.
I can report that according to Tritium's DCtest program it seems to be working as it should. For example:

shows that the requested speed at about 10% pedal position is 1880rpm as predicted by the formula for a speed of zero. That is, 1880rpm is the speed at which the request for torque (current) is zero. At higher speeds the requested current is negative.
At zero speed, [Edit No, I mean zero pedal.] the program shows requested current is linearly negative up to a maximum of 25% of maximum current at 4000rpm. (Thus verifying the relation T = - k*s when p=0.)
Now 4000 rpm is about 150km/hr for my car, but if I need more regen at any given speed, I can always shift down a gear thereby increasing the speed as seen by the motor.
In relation to the comment of Weber's about 5Hz speed reports from the controller, I checked with Tritium whether anything had been done about the problem Weber mentions. Apparently not.
Last edited by Renard on Fri, 05 Apr 2013, 04:20, edited 1 time in total.
Renard
- weber
- Site Admin
- Posts: 2799
- Joined: Fri, 23 Jan 2009, 17:27
- Real Name: Dave Keenan
- Location: Brisbane
- Contact:
AC drive programming and pedal mapping
Renard, on 4-Apr-2013, wrote:In relation to the comment of Weber's about 5Hz speed reports from the controller, I checked with Tritium whether anything had been done about the problem Weber mentions. Apparently not.
Tritium have recently increased the telemetry rate for "velocity" (rpm) to 25 Hz in our WaveSculptor. This has given us a significant reduction in the magnitude of oscillations due to drive-train springiness during low-speed low-gear parking manoeuvres, when using our quadratic regen pedal mapping.
After further testing and documentation, this should eventually make its way into a WaveSculptor200 DSP firmware update, with a version number greater than 1.11, on the Tritium website.
http://tritium.com.au/products/wavescul ... -inverter/
[Edit: Removed whitespace]
Last edited by weber on Sun, 16 Feb 2014, 20:47, edited 1 time in total.
One of the fathers of MeXy the electric MX-5, along with Coulomb and Newton (Jeff Owen).