Throttle Current/phase power control

Hi Gwhy!
I'm still using your current limiting algorithm. But I never saw any evidence that it actually limits phase current, not just battery current.
If phase current limiting worked, I would see the battery current dropping as speed decreases. But the code accurately maintains the battery current at constant until the motor almost stops (brakes applied or very steep uphill).
I would really like to get the phase current limited to some maximum value. This will limit the maximum torque and prevent slippage of my friction drive.
Can you please explain how your algorithm _should_ work?
 
Folken said:
Hi Gwhy!
I'm still using your current limiting algorithm. But I never saw any evidence that it actually limits phase current, not just battery current.
If phase current limiting worked, I would see the battery current dropping as speed decreases. But the code accurately maintains the battery current at constant until the motor almost stops (brakes applied or very steep uphill).
I would really like to get the phase current limited to some maximum value. This will limit the maximum torque and prevent slippage of my friction drive.
Can you please explain how your algorithm _should_ work?


Code:
// this line is what sets the maximum phase limit in this case phase current is set for 2 x battery current
phaseMax = Current_pot*2; 
 
// this routine computes the throttle output required it current control is needed
throttleCurrent = max_throttleOut - currentGain*(SensorRT - Current_pot)/100; 
 // max_throttleOut is the last throttle value sent to the controller
// throttleCurrent now holds the new value of max_throttleOut that may be sent to the controller if battery current needs to be limitied

//-------------------------------------------------------------------------------------------------------------------------------------------
// compute the phase current phase current = shunt current/throttle
phaseCurrent = SensorRT * 1023 /max(max_throttleOut,25); //set last term to be appx 2.5% of throttle max - throttle min
// calculates the approx phase current using  last throttle value sent to the controller which was max_throttleOut 
//--------------------------------------------------------------------------------------------------------------------------------------------

// this routine computes the throttle output required it phase control is needed
throttlePhase = max_throttleOut - phaseGain*(phaseCurrent - phaseMax)/100;
 // max_throttleOut is the last throttle value sent to the controller
// throttlePhase now holds the new value of max_throttleOut that may be sent to the controller if phase current needs to be limitied


throttleCurrent = min(throttleCurrent,throttlePhase); //choose lower value to send to the controller of phase or battery throttle

max_throttleOut = min(Throttle_Pulse,throttleCurrent); // use the lower of current-limited or user requested throttle value

// Now  max_throttleOut is the new value that need to be sent to the controller and this value will then be used for the next phase and battery current limits

if the current limiting starts then the throttle value will come down and its this reduced values that gets used to calculate the phase current .

edit:

this line calculates the phase current
phaseCurrent = SensorRT * 1023 /max(max_throttleOut,25);

so lets put some values into it if SensorRT=900 ( lets assume that your set battery limit is 1023) and the last max_throttleOut=1023 ( no limiting and you are at WOT )

then
phase current = 900 // at this point its the same as battery current

but if software starts to limit the battery current then the max_throttleOut will start to drop

i.e

SensorRT=1023 and max_throttleOut=800 ( system limiting )

then
phase current = 1308 // the phase current is rising

if your phase current setting is 2x battery current ( puts the phase current limiting value at 2046 )then max_throttleOut will need to be 512 before the set phase current will have any effect.
you can use programming to make this more dynamic to suit your needs :wink: .

in the extreme if SensorRT=1023 and max_throttleOut=40 ( system limiting ) // nearly at a standstill but throttle request is still WOT
phase current= 26163

I hope I have explained ok :D

edit2:

you could try using a higher phase current gain value.. this will reduce the max_throttleOut value faster.
or reducing the battery/phase ratio ... lowering the phase current limit

the value 25 in this part.... phaseCurrent = SensorRT * 1023 /max(max_throttleOut,25);
means that the max_throttleOut value will never be 0. it will always be 25 or higher so even if current limiting ( WOT ) and at a standstill there will always be a small throttle signal trying to power the motor this signal still may be enough to give you your max current limit displayed.

what you can do is display the phase current and you should see this value drop when phase limiting is active .. but this dont mean to say that battery current will also drop unless the max_throttleOut value is falling fast enough
 
Folken said:
That’s an excellent explanation, thanks a lot Gwhy! I will try again tweaking my constants, now that I know exactly what I’m doing. :)

no worries.. let us know how you get on..
 
aCeMadMod said:
hi any frimware update this great thing for rc motors. thank you all :D

what sort of update do you want ? :D

I have done lots of firmware and hardware updates on the ones that I use but this is tailored for my requirements and will not be suitable for everyone.

I started this thread to put a basic bit of code up that will work with esc's and ebike controllers so others can have a play to tailor it to there own requirements.
 
What kind of thing did you tailored ? I'm using your piece of code nearl as is and don't know what king of improvement could be made.

Thinking of antislip/wheel speed sync for my friction drive but don't know how to start. I think a "speed follower" control would be great for my usage.
 
Masure said:
What kind of thing did you tailored ? I'm using your piece of code nearl as is and don't know what king of improvement could be made.

Thinking of antislip/wheel speed sync for my friction drive but don't know how to start. I think a "speed follower" control would be great for my usage.

I done a lot of alterations to the clutch/power control parts of the software to make it more predicable and smoother, I changed the hardware a little to make it more fail safe should the throttle signal become stuck on the output pin of the ardunio , I added a temp read out and rpm to my display , cleaned the code up , added more menu options for power control, added a hall sensor switch for menu selection ( activated with a small magnet ) , added menu item selection using the throttle, also add a 3 stage/level lv shutdown routine, there are other bits and pieces but I cant remember the original code to compare.. This is what my display looks like at the moment.
obc_full.jpg


a anti slip may be quite easy to do as when it starts to slip then the current will drop ( maybe ) , or you could measure wheel speed against motor speed .. if motor rpm increase but no increase in wheel speed then its slipping so you back of the throttle signal or turn down the power until the wheel and motor speed match again.
 
Hey gwhy! your work is awesome ! I had the same idea a few years back as well but didn't materialize it. Would you mind sharing your last updated code for this current throttle ? I'd like to build one myself and experiment with it.
 
Back
Top