Programming controllers?

Joined
May 22, 2008
Messages
96
Location
Victoria, BC
Hello,

I am curious... is it possible to program or re-program controllers? Is it fairly accessible? Is there special equipment required? Can all controllers be programmed? And what changes can be made? Could variable regenerative braking be implemented?

Please and thanks.

-Colin
 
Not really. While you could technically do it, they're all designed around a specific chip which will vary from controller to controller. You'd basically have to redesign the whole controller to do it. Add to that the fact that some have a habit of scratching off part numbers, and it's virtually impossible.

I don't think you could do regen braking with a controller that wasn't equipped for it. Since the back EMF straight from the motor will exceed the batteries' voltage only if you're going faster than the motor's freewheel speed, you need a way to boost the voltage coming out of it if you want to do regen. You can do this by PWMing the motor (a la Fechter's regen brake thing). The voltage spikes generated would be enough to feed the battery, but you'd basically have to flip the controller around.

After all the work you'd have to put into it, you'd probably be better off going with a controller that was designed to be programmed (like an Alltrax).
 
Ah. Thank you very much. I always wondered why people argue that the speed of the motor would have to exceed the normally attained speed under load in order to charge the batteries - I wondered why one couldn't simply increase the voltage of the power from the motor, at a loss of current. That would be ideal anyway, because you don't want too much current going to batteries!
The kelly controller looks interesting - it would be nice to be able to connect controllers by USB or Firewire, so each controller has updateable firmware to interact with computers (yes, mac and windows) so people could tweak their own controllers. Do most controllers limit current electronically? The brushless controllers I've seen for bikes have a shunt resistor to limit current.

Thanks Hal.
 
carbon.nanotube.capacitor said:
Do most controllers limit current electronically? The brushless controllers I've seen for bikes have a shunt resistor to limit current.

The shunt resistor isn't actually what limits the current. It generates a voltage potential that's proportionate to the current flowing through it. If the controller detects that the voltage produced is going to high, it backs off on the PWM duty cycle.

This is why solder on the shunt bumps up the controller's current limit; it lowers the resistance of the shunt so it outputs a lower voltage for the same amperage. You're effectively "tricking" the controller into thinking it's drawing less current than it really is.
 
carbon.nanotube.capacitor said:
That almost clears things up for me. I thought resistors reduced voltage. Is this not the case?

They do, and it's an inevitable consequence of using a shunt to measure current. However, the shunt's resistance is very low; something similar to having an extra foot of 10ga in the system. It's not much to worry about, as the voltage lost is only on the order of a few mV.

The lost voltage translates to a small voltage potential across the length of the shunt. The controller measures this with what is basically a simple voltmeter built into the main processor attached to either end of the shunt. Then the processor compares it to a memorized value to determine whether and how much it should reduce the PWM duty cycle.
 
okay... I'm a little confused. When current flows through the shunt, what does the shunt do that the controller picks up on to determine how much current is flowing? Does the shunt simply reduce the voltage more the more current flows through it, allowing the controller to detect this small change in voltage and decide how much more / less current to let through?

No, I haven't taken an electrical engineering course - hence the slight confusion. Thanks for your patience.
 
The way most controllers work is there are a bunch of mosfet transistors inside that act as a switch. They are either full on or full off. The switch turns on and off at a very high frequency, called the switching frequency.

The ratio of on time to off time is called the duty cycle. If the switch is on only 1% of the time, then only about 1% of the battery voltage will be seen by the motor. As the duty cycle increases, the effective voltage to the motor increases and the speed increases.

When the shunt sees that the maximum allowable current has been reached, the controller reduces the duty cycle to keep the current at or below the limit. This is just like backing off on the throttle, only it's automatic.

The shunt is only a measurement device. It does not control anything directly.
 
carbon.nanotube.capacitor said:
okay... I'm a little confused. When current flows through the shunt, what does the shunt do that the controller picks up on to determine how much current is flowing?

G'day Carbon, Apologies if this is suck eggs.

One of the fundamental equations that goes with all electrical circuitry is V = I.R . Voltage = Current * Resistance

As with any mathematical equation, it can be re-arranged to find the value you are looking for. In the case of the shunt in a speed controller it is basically a high power and very low resistance, resistor. The controller 'knows' what the resistance of the shunt is and it measures the voltage that is produced across the shunt. From these two values (one fixed and the other variable) the controller can calculate the current flowing through the shunt.

Remember that the voltage being measured is the voltage being developed across the shunt its self as a result of the slight resistance to the current flowing through the shunt. This voltage is not referenced to ground or the battery positive. It is purely across the shunt its self.

As a rough idea of the numbers involved, most commercial shunts are designed to develop something like 50 millivolts ( 0.05 Volts ) across the shunt when the current flow is at the designed 100% value for that shunt.

In the case of a 40A controller (assuming the shunt is designed to produce 50 mv full scale) ,
V = I.R or in this case R = V/I
R = 40A / 0.05V
R = 2 ohms

If there was only 20A's flowing, the voltage across the shunt would be 25 mv (0.025v)

Hope this helps ?
 
I second Fechter's description. The shunt serves as only a way to sense the current; the actual current limiting is done by changing the duty cycle of the FETs' PWM waveform, lowing the amount of time they are on and, hence, the amount of current flowing into the motor.
 
Thank you all - this clears things up a lot for me! so the PWM cycle is just like an ordinary household dimmer switch, in that the variation of output voltage is done by increasing or decreasing the frequency of turning on and off the MOSFET - and it's for this reason that the output of a typical dimmer switch can't be used by dimmable compact fluorescent bulbs - it's too choppy.
Anyway, the duty cycle is like changing the voltage to the motor, and the current drawn by the motor is dependant on: A - the voltage to the motor and B - the mechanical load on the motor (physical resistance). The shunt produces higher voltages the more current flows through them, and the controller reads this, compares it to the known resistance of the shunt to determine how much current is flowing, then decides whether to adjust the duty cycle of the pwm.
In the event that the motor encounters mechanical resistance, for example from a hill, the controller also knows the speed of the motor and adjusts the pwm to compensate for loss of rpm, up to the current limit. Bypassing some of the shunt will make the voltage lower, making the controller think that the current hasn't reached the limit even when it has. Theoretically bypassing half the shunt will reduce the voltage to half the original, making the controller think it's using half the current it actually is, making the controller allow up to double the current than before.
Am I correct so far?
 
Correct on all points, save for the fact that most controllers do not know/pay attention to the RPM of the motor. The motor will draw more current on it's own without the controller having to vary the duty cycle; up to the controller's current limit. Even brushless controllers don't usually pay attention to the speed of the motor.

There are controllers out there that check the RPM of the motor and will throw more power at it in an attempt to keep it at what the throttle dictates, but that's a whole other can of fishbait...
 
carbon.nanotube.capacitor said:
Thank you all - this clears things up a lot for me! so the PWM cycle is just like an ordinary household dimmer switch, in that the variation of output voltage is done by increasing or decreasing the frequency of turning on and off the MOSFET - and it's for this reason that the output of a typical dimmer switch can't be used by dimmable compact fluorescent bulbs - it's too choppy.
Anyway, the duty cycle is like changing the voltage to the motor, and the current drawn by the motor is dependant on: A - the voltage to the motor and B - the mechanical load on the motor (physical resistance). The shunt produces higher voltages the more current flows through them, and the controller reads this, compares it to the known resistance of the shunt to determine how much current is flowing, then decides whether to adjust the duty cycle of the pwm.
In the event that the motor encounters mechanical resistance, for example from a hill, the controller also knows the speed of the motor and adjusts the pwm to compensate for loss of rpm, up to the current limit. Bypassing some of the shunt will make the voltage lower, making the controller think that the current hasn't reached the limit even when it has. Theoretically bypassing half the shunt will reduce the voltage to half the original, making the controller think it's using half the current it actually is, making the controller allow up to double the current than before.
Am I correct so far?

Very close :) . The frequency of the PWM circuitry is fixed. What changes is the % of on time vs off time. This is the duty cycle and defines the average output voltage. There are three sets of PWM switching going on, one for each phase in the motor. The controllers processor has to synchronise the timing of when to power each phase, based on where the rotor is in relation to the stator windings. It also has to control the duty cycle during each 'on' period for each phase.

WRT the shunt, most controllers I have seen use a number of links of solid wire as the shunt. Each wire is a low value, high power resistor and there is usually two to four in parallel. Not sure exactly what you meant by bypass part of the shunt? If you mean to remove one of the links then you are comming at the problem backwards. Parallel is the key word. Three of, one ohm resistors in parallel have a resistance of 0.33 ohm, not 3 ohms. Vice versa, remove one of the resistors and the combined resistance increases to 0.5 ohm. Increasing the resistance will increase the voltage dropped across the shunt for the same current flow.

If you want to reduce the voltage drop per amp of current you need to reduce the shunt resistance by either add another heavy gauge link to the shunt or basically filling the space between the links and increasing the cross sectional area.
 
Wow, I need to read more carefully. That and stop posting between 11:pM and 4:00AM. >_<

Yeah, the frequency of the PWM is fixed. The waveform is typically a biased square wave. The width of the squares is determined by the duty cycle. The higher the duty cycle, the wider the squares will be. At 100% duty cycle, it ceases to be a square wave and is a pure DC signal.

When you said "bypassing", for some reason I was thinking something like adding more solder to it. Don't know how I managed that. Adding more to the shunt will decrease its resistance, which in turn will decrease the potential across it.
 
Now I understand PWM! Although I'm not sure why it's more efficient than varied DC voltage. No matter.
What I did with the shunt, which in this case was two bars in parallel, is I connected the negative cable from the battery to a relay. (On the circuit board this cable feeds the shunt). The other terminal of this relay, normally open, I connected to a wire which I soldered to the midway point on the shunt. Thus when the relay is activated (by a 12v switch) the negative cable from the battery is connected to the middle of the shunt instead of the beginning where it normally is. The result is the delivery of substantially more current, which results in more torque.
Sooo... The reason the controller delivers more current is because when it compares the voltage from the battery to the voltage after the shunt, it effectively has a similar difference in voltage to when there is less current - thus the shunt is resisting less and the voltage after the shunt is higher. Either that or I'm completely wrong :p
Have I misunderstood?
 
carbon.nanotube.capacitor said:
Now I understand PWM! Although I'm not sure why it's more efficient than varied DC voltage.

It's not. The lack of efficiency comes from how you vary the DC voltage. PWM ends up being far more efficient (around 95-98%) when you account for the losses of whatever sort of converter you are using.

carbon.nanotube.capacitor said:
Sooo... The reason the controller delivers more current is because when it compares the voltage from the battery to the voltage after the shunt, it effectively has a similar difference in voltage to when there is less current - thus the shunt is resisting less and the voltage after the shunt is higher. Either that or I'm completely wrong :p
Have I misunderstood?

Close, but not quite. The batteries' voltage varies far too much to be used as a comparison for the millivolts of difference that a shunt makes. I believe the voltage measured is the voltage difference across the shunt itself. I.E. if you were to put the probes of a multimeter across the shunt you would get a small voltage reading; this voltage is what the controller uses to determine the amount of current traveling through the shunt.

Your method works because the current only has to travel through half the shunt. In fact, I'd be careful with that, if I were you. Because a significant portion of the current is now going straight to the middle of the shunt, there is very little voltage being produced across the length of the shunt. Might blow up your controller if you're not careful. :?
 
Not sure if it has been asked yet, but what controller are you running ? All of my direct experience is with the Cyclone controller which does not have a shunt. So I am not quite sure exactly where the shunt is in the system. Though from your explanation the shunt is the first component after the negative battery lead meets the controller ?


Link said:
Close, but not quite. The batteries' voltage varies far too much to be used as a comparison for the millivolts of difference that a shunt makes. I believe the voltage measured is the voltage difference across the shunt itself. I.E. if you were to put the probes of a multimeter across the shunt you would get a small voltage reading; this voltage is what the controller uses to determine the amount of current traveling through the shunt.

Correct. The voltage is in the order of millivolts.


Link said:
Your method works because the current only has to travel through half the shunt. In fact, I'd be careful with that, if I were you. Because a significant portion of the current is now going straight to the middle of the shunt, there is very little voltage being produced across the length of the shunt. Might blow up your controller if you're not careful. :?

By soldering a pickoff into the middle of the shunt you have halved the effective resistance of the shunt. All the current will go through the pickoff and because the shunt is now half the resistance it will now require twice the amps to flow before the controller thinks it has reached its max amps. You need to have a close look at the specifications of your fets, and be very careful. Plenty of guys are over volting their controllers but I don't know how many are playing with over amps.

Being 100% over the specified amps, you are flirting badly with the smoke angel. I agree with Link, be VERY careful.
 
Pete said:
Link said:
Your method works because the current only has to travel through half the shunt. In fact, I'd be careful with that, if I were you. Because a significant portion of the current is now going straight to the middle of the shunt, there is very little voltage being produced across the length of the shunt. Might blow up your controller if you're not careful. :?

By soldering a pickoff into the middle of the shunt you have halved the effective resistance of the shunt. All the current will go through the pickoff and because the shunt is now half the resistance it will now require twice the amps to flow before the controller thinks it has reached its max amps. You need to have a close look at the specifications of your fets, and be very careful. Plenty of guys are over volting their controllers but I don't know how many are playing with over amps.

Being 100% over the specified amps, you are flirting badly with the smoke angel. I agree with Link, be VERY careful.

I'm guessing he's actually over double the specified amps for this reason: Since the current doesn't have to travel from the beginning of the shunt to the end of the shunt, it's not creating near the potential at the ends of the shunt it should. The sensor isn't able to pick up ANY of the current traveling through the second half of the shunt, because the voltage it produces will be past the first probe of the sensor. It's only able to measure the current traveling the length of the shunt, so it's only seeing the current flowing from the original connection, which will only be about a THIRD of what it originally was. And that's not counting the reduction in resistance the extra solder makes. So, if I didn't screw something up, that means that the controller has about THRICE the current limit it did before. :shock: I'm amazed that the FETs of the controller haven't blown up. They must have been way oversized for the stock controller.
 
Three times the current?! Yikes. I had assumed by halving the amount of shunt used, I would be doubling the current. The controller (as described in the manual for the bike) is 15amps, so I assumed it had become 30. I do notice that when the relay to connect this shunt bypass is off, the extra solder to connect the wire to the shunt gives the controller a small increase in current as it is. I do have pictures of the inside of the controller at work, I will try to get copies posted. What I do know about the mosfets is that there are 4 for each phase of the motor; 12 in total. So far the controller has been relatively cool on long hill climbs with the air temperature above 25ËšC. However the motor was warmer, and the small three-prong AC-style cord that connects to the battery get's too warm - it was designed to handle only 10 amps continuous, although at 250 volts. I will continue to try the controller in "high amp mode"... Probably the best course of action would be to only use it for short periods.
 
See if you can get the part numbers off of the FETs. Looking up their specs should tell you how much headroom you have (if any). :?
 
carbon.nanotube.capacitor said:
Now I understand PWM! Although I'm not sure why it's more efficient than varied DC voltage. No matter.
What I did with the shunt, which in this case was two bars in parallel, is I connected the negative cable from the battery to a relay. (On the circuit board this cable feeds the shunt). The other terminal of this relay, normally open, I connected to a wire which I soldered to the midway point on the shunt. Thus when the relay is activated (by a 12v switch) the negative cable from the battery is connected to the middle of the shunt instead of the beginning where it normally is. The result is the delivery of substantially more current, which results in more torque.
Sooo... The reason the controller delivers more current is because when it compares the voltage from the battery to the voltage after the shunt, it effectively has a similar difference in voltage to when there is less current - thus the shunt is resisting less and the voltage after the shunt is higher. Either that or I'm completely wrong :p
Have I misunderstood?

circuits that vary a DC voltage directly are very wasteful of energy. the only direct way to vary DC voltage directly is to put a variable resistance in series with the load. the voltage used by the variable resistance would be wasted.

the shunt is a resistor pure and simple. it is in series with the battery and the load. Kirchoff's voltage and current law states that at any point in a series circuit the current is the same. ohms law states that the voltage is the resistance multiplied by the current.

now if i feed an unknown current through a known resistance i can measure the voltage and calculate the current. the shunt resistor has a known value. usually between .001 ohm and .010 ohm. a very small value so that even at high currents the parasitic voltage lost through it will be small and not affect the power available to the motor very much. if i put enough current through the system so that the voltage developed across a 0.001 ohm shunt is 1V then i can calculate the current as I = V/R = 1V/0.001R = 1000A! if the Voltage drop is 0.1V than the current will be i = 0.10V/0.001R = 100A. since the current through the shunt is the same as the current through the rest of the circuit we have succeeded in measuring the current. but the shunt is always resisting the same it's resistance does not change.

if we want to set the current limit at 100A and we know that with our shunt that would be a voltage of 0.1V we can use that knowledge to turn things on or off. we use another circuit to give us a reference voltage of our trigger voltage of 0.1V. we compare this reference to our measured voltage across the shunt. as long as the current through the circuit and the shunt is less than 100A the voltage across the shunt will be less than 0.1V. the comparator will stay off. as soon as the voltage across the shunt is equal too the 0.1V reference the comparator turns on. this will trigger the circuitry to turn down the power until the voltage across the shunt drops below 0.1V and the comparator turns off again.

this is a simplified explanation but it is how the shunt is used to measure and limit the current.

rick
 
Thank you all - and thank you Rick for pulling together all the information; now I understand. I opened a controller from our box of dead controllers - it's one from another Kaishan like the one I'm experimenting with. The mosfets numbers are:
P75NF75@
CC17Q 6
MAR 616

I believe this might be a data sheet on this model mosfet: http://pdf1.alldatasheet.com/datasheet-pdf/view/23977/STMICROELECTRONICS/STP75NF75.html
And yeah, there really is an 'at' sign after P75NF75. I'm not sure that is the right data sheet though, seeing as how it rates the mosfet for 80 amps - that's a lot!

What do you think?
 
Here are pictures of an identical controller to mine. they are not in focus because the camera I was using couldn't quite manage it.IMG_3127.JPGIMG_3128.JPGIMG_3132.JPG
You can see where the controller failed - the first mosfet cooked, and you can see why: Someone added solder to the shunt resistors! Uh-oh...
 
carbon.nanotube.capacitor said:
I opened a controller from our box of dead controllers - it's one from another Kaishan like the one I'm experimenting with. The mosfets numbers are:
P75NF75@
CC17Q 6
MAR 616

I believe this might be a data sheet on this model mosfet: http://pdf1.alldatasheet.com/datasheet-pdf/view/23977/STMICROELECTRONICS/STP75NF75.html
And yeah, there really is an 'at' sign after P75NF75. I'm not sure that is the right data sheet though, seeing as how it rates the mosfet for 80 amps - that's a lot!

Yeah, I think that's the right sheet. It's pretty much the only way it could be surviving a 45A+ current limit.

And that's not really all that many amps. The 4110s we all love so much are rated for 180A continuously, though we can't actually go this high because of the current multiplication effect of PWM.
 
Back
Top