Questions about the Smart Motor Library

Hello, this is me David again. I have a question
How may I implement the smart motor library for a single flywheel with 4 ime encoders. I have a ratcheting mechanism but I want to make it more efficient. How do I use it to control the acceleration and prevent the motrs from overheating because they even with a ratchet and pawl. Also how can I ramp up the acceleration and when the ball is shot and the speed slows. Finally how can I make a toggle for the flywheel so when. I push a button it runs and when I push it again it stops. Also I want to be able to move the robot x drive while the flywheel is running. And also some toggle codes in the past have confused me so could you explain how I can do it.
Many thanks

Hi David

The smart motor library is not really suited for use with flywheels.

You had asked me the same questions privately and I have not had time to answer, lets break these out one at a time.

I will say right upfront, the smart motor library is not optimized for use with flywheels.

There are three fundamental features that the smart motor library has.
It implements slew rate (acceleration/deceleration) control.
It monitors motor current based on requested motor speed and actual motor speed.
It estimates the PTC temperature based on time and motor current.

It will (optionally) remove power if either current or PTC temperature is above a preset threshold.

My observations of flywheels so far are as follows.
The motor uses a lot of current when the flywheel is being accelerated.
The current used when in a stable running (without game objects) should be quite low.

If the smart motor current limit mode is used then the flywheel acceleration period is a problem, current is reduced and the flywheel does not reach the desired speed. The PTC temperature limit mode may be useful, but if you are really overheating the PTCs then the flywheel has some other fundamental issues. The PTC overheat mode was really designed for a robot drive system, it will limit the current when the robot is in a pushing match or something like that.

If you do try and use the library you will only really need one encoder if the motors are all geared together.

This function is used to control how fast the motors accelerate.

void SmartMotorSetSlewRate( tMotor index, int slew_rate = 10 )

Smaller numbers mean longer acceleration time.

The smart motor library is not trying to implement any sort of speed control, it’s for monitoring current and PTC temperature.

Unrelated question that has been asked and answered many times on the forum.

Unrelated question to the smart motor library. Put the drive code and flywheel control in different tasks.

Many thanks.
Have a great season

Oh one more thing how do you calculate the time that it will funny accelerate based on the number you plug in. And does this also control deceleration.

The task that does slew rate runs once every 15mS. The number you give to the SmartMotorSetSlewRate function is the amount that the motor value is adjusted every time the task runs. For example, lets say you currently have a speed of 0 (ie. motor is stopped), the slew rate is 10 and you ask the motor to run at a speed of 120. Each time the task runs 10 will be added to the current motor value, after 12 increments the desired speed will be reached, in this case 1215mS = 180mS (about 1/5 of a second). The slowest would be to set the slew rate at 1, this will then take 12015mS or 1.8 seconds to reach full speed.

Thank you and one more thing.

What do you put in tMotor index.
sorry for the trouble

The motor port/ motor name.

So would this be right for setting the flywheel to 159 power on port 2

void SmartMotorSetSlewRate( tMotor index, int slew_rate = 10 )
task main
SmartMotorSetSlewRate(motor[port2]=159, into slew_rate =10)


Would that be right and forgive any syntax errors as I am typing from a cell phone

If my understanding is correct that is not right it would be this

task main(){
SmartMotorSetSlewRate(2, 10);
motorSet(2 159);
//it could also be setMotor, not totally sure which one it is

Thanks Collin. I anyone has anything to add feel free to respond.
The more the merrier.

Have you read the documentation?

Thanks for all of your help. We are many steps closer to engineering a killer robot.
Thanks for everything