DIY Current Limiter

johnamon

10 W
Joined
Jun 20, 2011
Messages
68
Location
Aberdeen, Scotland
Hey Guys,

Last year I put together an bike with a 350w motor, but I only bought a 10A continuous discharge battery, which BMS cuts out when I am too heavy on the throttle :(

I plan to create a diy current limiter by sensing the current using this sensor: http://www.ebay.co.uk/itm/30A-ACS71...upplies_ET&hash=item4603399319#ht_4283wt_1144

Which talks to an arduino that runs at 5v : http://www.ebay.co.uk/itm/Arduino-N...Networking&hash=item3a71db6022#ht_4507wt_1144

I currently plan to hook my 5v arduino straight into the unused PAS 5V supply, leaving the 5v supply to the throttle alone to try and spread the load. The problem I'm worried about is will the PAS lines likely supply enough current to run an arduino?

If not, does anyone know how I should reduce the battery's 36v to a more arduino friendly 5V?

Thank you :D
 
Why don't you just program the controller for lower amps or shave the shunt down?

Seems a lot easier.
 
Dremel. Sand the shunt a bit thinner. Try and see if you're at less than 10amps. If still too high, grind shunt a bit thinner again until you get there. Your controller all ready has a battery current limiter built into it. You just need to set it to work for you.

Or, if your batteries aren't getting warm, slathering a bit of solder over the shunt on the BMS would also fix the problem without reducing power.
 
Totally agree on trying to modifying the controller first.

But if you do want to go the Arduino route, they don't take a lot of current so the PAS 5V should be fine. If it is a problem something like this can take you battery voltage down to create a seperate 5V line for you.
http://www.hobbyking.com/hobbyking/store/__18521__Turnigy_HV_SBEC_5A_Switch_Regulator_8_42V_input_.html
 
Thank you for the advise guys. I want to create a software driven current limiter rather than modify my controller because in the future I may want to just say 'to hell with it' and get a bigger battery! :twisted:

I guess I'll try and run the arduino off the 5v PAS supply lines first, and if it doesn't work order one of the hobbyking regulators shown above.

Thanks again for the advise :D
 
The Arduino PID library is pretty good, so you might want to look into that to smooth out the response.

Here is a link to a post that contains some useful links to few other things you can do with your arduino.
http://endless-sphere.com/forums/viewtopic.php?f=2&t=29561&start=15#p447908

- Adrian
 
To be fair, if you mod your controller to decrease current you can still pretty easily mod it in the other direction.

In some ways, that's easier. JohninCR proselytized for a clever way of modding the shunt to decrease the resistance. He just winds some non-insulated copper tightly around the shunt for whatever portion he wants to decrease it. So you want to double your current? cover 50% of the controller shunt with copper wire. It's more accurate than slathering solder.
 
johnamon said:
Thank you for the advise guys. I want to create a software driven current limiter rather than modify my controller because in the future I may want to just say 'to hell with it' and get a bigger battery! :twisted:

I guess I'll try and run the arduino off the 5v PAS supply lines first, and if it doesn't work order one of the hobbyking regulators shown above.

Thanks again for the advise :D


By what mechanism do you plan to reduce the battery current? If you PWM the battery voltage, so you decrease what the controller sees as pack input voltage to limit it's current, it's going to trip the controller off.
 
I plan to mirror (erhem...) the way the cycle analyst reduces throttle voltage to the motor controller.

The arduino pins can act as voltage sources AND sinks - so I can connect an arduino pin via a diode to the throttle signal line and reduce the throttle voltage in a controlled manner through the arduino pin when the current sensor reads too high a reading 8)

I'm just producing a very cheap & cheerful clone of the single function of the cycle analyst that I want.......
 
johnamon said:
I plan to mirror (erhem...) the way the cycle analyst reduces throttle voltage to the motor controller.

The arduino pins can act as voltage sources AND sinks - so I can connect an arduino pin via a diode to the throttle signal line and reduce the throttle voltage in a controlled manner through the arduino pin when the current sensor reads too high a reading 8)

I'm just producing a very cheap & cheerful clone of the single function of the cycle analyst that I want.......

You just don't realize you want all the functions of the CA yet. ;)
 
Sorry to ask another daft question, but does anyone know what standard the throttle and pas plugs/sockets are on the ku-93 controllers?

If all else fails and i can't get additional plugs / sockets I'll replace both types of connector with servo connectors, but I'd like to avoid hauling the bike up 4 flights of stairs to perform a solder operation on the controller leads!!

Thanks again
 
johnamon said:
Sorry to ask another daft question, but does anyone know what standard the throttle and pas plugs/sockets are on the ku-93 controllers?

If all else fails and i can't get additional plugs / sockets I'll replace both types of connector with servo connectors, but I'd like to avoid hauling the bike up 4 flights of stairs to perform a solder operation on the controller leads!!

Thanks again

pictures?....
 
For future reference the connectors in question are:

PAS Sensor plug / socket is a JST SM 2.5 Connector = JST 2.5 Connector.jpg

Throttle plug / socket is a Motorcycle Electrical Mini Connector (2.8mm) = Motorcycle Mini Connector.jpg

I got the current limiter wired up over the weekend and it works perfectly, although my simple feedback loop results in jerky throttle reductions... I'll upgrade the software this week with the arduino PID library, which I kinda suspect the Cycle Analyst uses due to the use of similar feedback loop variable names 8)
 
Start of with just using the P & I terms, with a derivative of zero.

Here is a short tutorial in tuning the PID loop, that is aimed at beginners I found useful.

http://wwwdsa.uqac.ca/~rbeguena/Systemes_Asservis/PID.pdf
 
Last night I altered my controller's code to run the arduino PID library. Wow, what a great ability to limit output, the PID library makes it so simple.

I wrote code to turn on the PID control when the current goes above my desired limit of 10A, and wrote a counter to turn it back off again when the current drops below 9A for more than 5 seconds. The response is very smooth, if a little 'dulled', but I'll take a dulled response over having to stop, turn the ignition key to off and on again when I over-do it on the throttle.....

I set Kp to 0.2 (4x the value used in the CA factory default - which at 0.05 still allowed the battery's BMS to cut in)
I set Ki and Kd to 0 (on adrian_sm's good advise)

Happy happy happy 8)
 
Awesome. Great to hear it is working for you.

Sounds like you already have it switching response based on the current, but you might be interested in the code the PID library author created to do similar stuff. I may have some advantages, so might be worth a look. It basically lets you switch PID parameters on the fly. And it is already part of the PID library you are using.

http://arduino.cc/playground/Code/PIDLibraryAdaptiveTuningsExample
Code:
/********************************************************
 * PID Adaptive Tuning Example
 * One of the benefits of the PID library is that you can
 * change the tuning parameters at any time.  this can be
 * helpful if we want the controller to be agressive at some
 * times, and conservative at others.   in the example below
 * we set the controller to use Conservative Tuning Parameters
 * when we're near setpoint and more agressive Tuning
 * Parameters when we're farther away.
 ********************************************************/

#include <PID_v1.h>

//Define Variables we'll be connecting to
double Setpoint, Input, Output;

//Define the aggressive and conservative Tuning Parameters
double aggKp=4, aggKi=0.2, aggKd=1;
double consKp=1, consKi=0.05, consKd=0.25;

//Specify the links and initial tuning parameters
PID myPID(&Input, &Output, &Setpoint, consKp, consKi, consKd, DIRECT);

void setup()
{
  //initialize the variables we're linked to
  Input = analogRead(0);
  Setpoint = 100;

  //turn the PID on
  myPID.SetMode(AUTOMATIC);
}

void loop()
{
  Input = analogRead(0);

  double gap = abs(Setpoint-Input); //distance away from setpoint
  if(gap<10)
  {  //we're close to setpoint, use conservative tuning parameters
    myPID.SetTunings(consKp, consKi, consKd);
  }
  else
  {
     //we're far from setpoint, use aggressive tuning parameters
     myPID.SetTunings(aggKp, aggKi, aggKd);
  }

  myPID.Compute();
  analogWrite(3,Output);
}
 
The code is on my other computer - so I'll follow up with the code later on, the most important component was this current sensor, from which the arduino measures current.

I don't have schematics either - I never plan ahead that much!! But here is a photo of the finished article...
throttle limiter.JPG
 
Back
Top