Menu

Topic-icon Open Loop Mode with coasting

More
4 years 2 months ago - 4 years 2 months ago #29531269 by Ryan
Hi,

I'd love (desperatly need) to have a Open Loop Mode without active braking, which behaves like eBike controllers.
Its a mystery to me, how cheap eBike controllers do that. I think by shutting down the FET's if accelerated further than the motor command is. Shutting down and re-enable the FET's by script doesn't work properly, while the motor is spinning.

I've already tried implementing it manually , but that can't be the solution, because it needs to get fine tuned for every motor and I can't do that. For example if I have to replace a motor or a controller, reprogramming the controller is unpractical.

I hope you can help me. We've already bought 22 of your sbl1360 controllers because they're doing their job much better than every other controller. (except we can't get it to coast properly)

Hope you can help me.

Thank you!

Please Log in or Create an account to join the conversation.

More
4 years 2 months ago - 4 years 2 months ago #29531271 by TechSupport
*Thread moved*

Coasting is achieved only by means of turning off the fets; E-stop.

To turn off by command it is !EX, and to release from E-stop, is to send !MG.

In script it would be setcommand(_EX, 1) and setcommand(_MG, 1)

For that it would be best to have a switch that dictates this action.

dim d1 as integer
top:
d1 = getvalue(_DI,1)
if d1 = 1 then
setcommand(_EX, 1)
else
setcommand(_MG, 1)
end if
wait(1)
goto top

Please Log in or Create an account to join the conversation.

More
4 years 2 months ago - 4 years 2 months ago #29531272 by Ryan
Replied by Ryan on topic Open Loop Mode with coasting
Thank you for moving the thread.

Your script will also do active braking, if the motor command is still greater than 1.
I've described my use case in my other post . (5kg flywheel directly attached to the motor)
Under normal conditions (disconnecting motor from controller) It takes a bit about 1:30 min to decelerate.

What I want to be able to do is the following:

Scenario:
1. Accelerate to full speed. (Mot cmd = 1000)
2. wait 15 seconds until full speed is archived (5kg flywheel mass now spinning at about 8000 rpm)
3. set the motor command to 500 (half speed), wait for the flywheel to decelerate to half speed naturally and then keep staying at 500.

I also want to be able to accelerate the motor, if it's running at 500 from the outside. There's force which gets applied to the motor and the motor shouldn't brake it down.

If I do this with your script, the motor will brake unless the 500 command is reached, which is not what I want.

This script only enables free wheeling, if there's no motor command.

Please Log in or Create an account to join the conversation.

More
4 years 2 months ago #29531273 by TechSupport
The controller uses progressive regenerative braking. This is applied when the e-stop is not engaged. So when the e-stop is disengaged after being used, it applies the regenerative braking right away if the motor is moving faster than the command.

If you are trying to maintain a speed, then closed loop speed mode is what you want, so no need for e-stop.

If you wrote your script to do what you want it to do then it would possibly work.

Please Log in or Create an account to join the conversation.

More
4 years 2 months ago #29531274 by Ryan
Replied by Ryan on topic Open Loop Mode with coasting
Is there a way to disable this progressive regenerative braking?

If you are trying to maintain a speed, then closed loop speed mode is what you want, so no need for e-stop.

That's the point. We're not trying to maintain anything. (from controllers point of view) That's why we're using open loop mode. We just want the controller to behave like a gas pedal. It should decelerate if we apply motor command 500 and the load gets heavier, for example. We rather need the torque mode, but that also doesn't work since we're then unable get full speed. :(

The script that would do what I want is this:
option explicit

dim RPMat50pct as integer ' Measured RPM at 50% power level during bench test
dim MeasuredSpeed as integer ' Measured MeasuredSpeed
dim NeutralPower as integer ' Level so the motor neither accel or decelerates
dim AppliedPower as integer ' Power that will be applied to the motor
dim ThrottleCommand as integer ' User command
dim ManualCoasting as integer ' Difference to Throttle command for manual coasting
dim FetsOff as boolean
dim FetsOffOld as boolean

' Change these constant to meet your requirements
RPMat50pct = 3690 ' Measured RPM at 50% power level and no load
ManualCoasting = 200

' initializing
setCommand(_ESTOP,0) ' fets off
FetsOff = true
FetsOffOld = true

top:
' ' Read user command from Analog Joystick on in 5
ThrottleCommand = getValue(_CIA,1) 

' Uncomment on of the two following lines depending on motor type and sensor
MeasuredSpeed = getvalue(_BS, 1) ' Measure current speed using Hall sensor
'MeasuredSpeed = getvalue(_S, 1) ' Measure current speed using Encoder

' Compute Power Level needed to maintain current speed
NeutralPower = ((MeasuredSpeed * 500) / RPMat50pct)

if (NeutralPower < 0)
	NeutralPower = 0
end if

AppliedPower = NeutralPower
if (NeutralPower > (ThrottleCommand + ManualCoasting))
	' coasting far over ThrottleCommand
	'print("Off")
	FetsOff = true
elseif ((NeutralPower < ThrottleCommand + ManualCoasting/2) and NeutralPower > ThrottleCommand)
	' manual coasting near over ThrottleCommand
	'print("On1")
	FetsOff = false
elseif (NeutralPower < ThrottleCommand)
	'print("On2")
	FetsOff = false
	AppliedPower = ThrottleCommand ' accelerating
end if

' Only allow positive commands and cap to +1000
if (AppliedPower < 0)
	AppliedPower = 0
elseif (AppliedPower > 1000)
	AppliedPower = 1000
end if

if (ThrottleCommand < 2)
	FetsOff = True ' Always turn Fets off if no command is given
end if

setcommand(_G, 1, AppliedPower) ' Apply power to the motor
if (FetsOff and (not FetsOffOld))
	setCommand(_ESTOP,0) ' turn fets off
	setcommand(_G, 1, AppliedPower) ' Apply power to the motor
	FetsOffOld = true
	'print("Fets OFF\r")
elseif ((not FetsOff) and FetsOffOld)
	setCommand(_MGO,0) ' turn fets on
	setcommand(_G, 1, AppliedPower) ' Apply power to the motor
	FetsOffOld = false
	'print("Fets ON\r")
end if

'setcommand(_G, 1, 500) ' calibration power
' Optional log printed on the console for monitoring or debug
print("C= ", ThrottleCommand,"\tS= ",MeasuredSpeed,"\tF= ", FetsOff)
print("\tN= ", NeutralPower,"\tP= ", AppliedPower,"\r")

wait(10) ' Wait 10ms
goto top ' Repeat loop forever

But that doesn't work because turning on the FETs while the motor is spinning causes braking, too. Is turning on the FETs while the motor is spinning a legal operation?

Please Log in or Create an account to join the conversation.

More
4 years 2 months ago - 4 years 2 months ago #29531275 by TechSupport
Progressive regenerative braking cannot be disabled, except for when the fets are off; therefore it is not something we can have disabled otherwise.

To answer the question about turning on the fets while motor is spinning in free spin is perfectly okay. Just not that it will resume whatever the command is, so there may be a small hickup while motor is under load to pick up speed. It would be like the effect of a car going 50 MPH, you put in Neutral, and hit accelerator when put back into drive. There will be a small delay and possibly a jerk that occurs when the gear gets back in action.

In torque mode, it uses the Integral gain, as it becomes a case of maintaining the torque(Amps) and not speed. Open loop does not have many specifics in it to do exactly what you want it to do. Closed loop modes are made for a specific behavior. Scripts help in creating the behavior you want, but it doesn't always work in some cases.

Edit: Torque mode is based on the motor amps limit. See page 28 and 29 of user manual for how that is calculated. If the motor amps is reached while at a lower command, it prevents the motor from getting any more power due to reaching the motor amps limit, even if battery amps is far less.

Please Log in or Create an account to join the conversation.

More
4 years 2 months ago #29531276 by Ryan
Replied by Ryan on topic Open Loop Mode with coasting
I understand perfeclty what you explained. I'm used to that hiccup. But that hiccup was so strong, it wasn't bearable.

What would happen, if I accelerated my flywheel mass to full speed and then inverse the motor command (1000 to -1000) abruptly? Would the controller be able to handle that without destroying itself? (Use with a battery)

We're currently using it powered by a switching power supply. That doesn't work, since the voltage raises and destroys the fets. My colleague already works on a device which simulates the battery. Prototypes arrive next week...

Is there a way to get the perfect motor command for a specific rpm? So that I accelerate the engine of the car exactly to the power needed for this velocity? So that there wont be a hiccup or a small one?

Other question: What happens if i issue the _G command while the fets are off? Will it be in place if i do _MGO afterwards or do I have to do it the other way round?

Please Log in or Create an account to join the conversation.

More
4 years 2 months ago #29531277 by TechSupport
A switching supply is very well known for the voltage spikes which will damage and destroy the power mos drivers(IC's) long before the fets themselves.

Using the app note is helpful, considering power supplies will not be able to handle back emf caused by the regeneration, so a battery will need to be tied in parallel.

dev.roboteq.com/dev1/index.php/docman/mo...om-regeneration/file

To get to a specific speed, is to use the closed loop speed mode after adjusting your PID gains will allow you to do this. The !S is the command that tells it to go to that speed.

!S 1 600 or !S 600 will tell motor 1 to go to speed 600 RPMs. This is only for the closed loop speed mode, as other modes will not do this. If you use !G 1 600 or !G 600 will tell motor 1 to go to 60% motor output.

If you use the !G while fets are off, will tell the motor output to send the output command, but won't act upon it until the fets are enabled again.

It would be like putting the car in neutral and revving up the accelerator, but the motor does not move until it is put back into the drive gear; only it won't damage the controller unless the motor did not like the results upon coming back on after releasing from the e-stop.

I did try with my motor and controller and did it unloaded at full +1000 command, hit the estop and quickly release from it, and didn't have any issues other than the power supply hitting the amps limit, but didn't really have much impact on my motor.

Please Log in or Create an account to join the conversation.

Moderators: tonysantoni
Time to create page: 0.123 seconds
Go to top