Simple closed loop speed script

6 years 10 months ago #29532506 by revz
I am using an SDC 2160 with an AMT102-V modular incremental encoder www.cui.com/product/resource/amt10-v.pdf to drive a brushed NEMA 34 servo motor
. The encoder puts out two quadrature signals and an index pulse 1 per rpm. I need the motor to spin up to 120 rpm over the period of 15 seconds upon power up. I believe this would be a closed loop speed control. It would seem this is possible in the configuration window of the PC software, but maybe I need a script. If so, can you please give me a pointer as to how to go about this?

I am reading the inputs from the encoder in the DIN pins in the PC software. I can manually control the motor from the PC software.

Some more detail about the project:

I am making a 3D zoetrope. Everything else is basically in place, and the motor control is the last element that needs to be worked out. I have a power latching circuit that triggers a 16Hz LED strobe circuit as well as a relay for the motor controller power supply. The controller powers on when this relay is thrown, and accelerates up according to the script.

Thank you,

-r

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

6 years 10 months ago #29532507 by blake
The SDC2160 has inputs for the encoder's quadrature signals (A & B) but not the index so you will not connect the index pulse. You will need to disable Pulse Inputs 1 & 2 in order for the encoder signals to be recognized. Finally you will need to configure the correct PPR value of your encoder to the controller in order to get accurate speed data.

Closed loop speed mode should work for what you are trying to do. Closed Loop Speed Mode is detailed in section 9 of our User Manual . It uses a PID loop so some tuning of the PID gains will likely be required. After the gains are tuned the motor commands will be scaled proportionally to whatever the Max RPM configuration you have set is. The motor command range is -1000 to +1000, where the sign indicates direction and +/-1000 is full speed (Max RPM). Finally, you can adjust the controllers acceleration and deceleration values to adjust the amount of time the motor takes to ramp up to the command speed.
The following user(s) said Thank You: revz

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

6 years 10 months ago #29532508 by revz
Thank you for your response.

The encoder is set at 4096 ppm right now and that is what I put into the PC software.

I have disconnected the index. I get correct feedback when in open loop mode with COUNTER and RPM in the correct direction. But I can not get the motor to start spinning upon power up as per my parameters on the configuration page. Is this self starting possible from the configuration page, or is a script needed?

Thank you,

R

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

6 years 10 months ago #29532509 by blake
I'm sorry I forgot to answer that inquiry from your first post.

In order to have the motor run upon startup a script will be required. You will use the !G command, the microbasic syntax would be setcommand(_G, 1, nn) where nn is the command value.

To have this script take effect upon startup of the controller you will need to enable script auto-start. This is done from the Configuration tab of Roborun+ (Configuration > Startup > Scripting > Script Auto-Start: Enabled).
IMPORTANT: Thoroughly test your script before enabling the script auto start. If a faulty script is loaded and auto start is enabled it can make the controller unresponsive and it may be required to return to us to clear and re-flash the MCU.

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

6 years 10 months ago #29532510 by revz

blake wrote: I'm sorry I forgot to answer that inquiry from your first post.

You will use the !G command, the microbasic syntax would be setcommand(_G, 1, nn) where nn is the command value..


Ok, what is the command value in this case? Whereas I do have programming experience, I an very new to MicroBasic scripting.

Best,

R

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

6 years 10 months ago #29532511 by blake
I would need to know:

It depends on what you have set as your max RPM and what speed you the motor to spin at.

For example, if your max RPM is set to 500RPM, the following commands would yeild the following speeds:

setcommand(_g, 1, 1000) = 500rpm

setcommand(_g, 1, 500) = 250rpm

setcommand(_g, 1, 250) = 125rpm

setcommand(_g, 1, 100) = 50rpm

etc...

So you can see the command is proportional to whatever your max rpm setting is. Additionally, using closed loop speed mode so that the above is relavent will first require some tuning of the gain values. Before even considering a script you need to first make sure that closed loop speed is optimized and working as it should in your system. This is described in the section of our user manual that I mentioned in a previous post.

Additionally I just noticed that you said that your PPR was configured to 4096, according to the datasheet you sent me for your encoder this can't be. It appears to have a max ppr of 2048:

Attachments:

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

6 years 10 months ago #29532512 by revz
Ok. That was a typo, quadrature resolution is infact set at 2048, and I have verified that the PC software feedback represents real life conditions.

I am currently running the motor with no load, and my PID values are 0,1,0, as per the manuals recommendation. I expect these will need some tuning under load.

Once I am sure that closed loop speed works, the script will simply consist of (if I want to go to Max RPM, and I am using motor 1):

setcommand(_g, 1, 1000)

Is that correct?

-R

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

6 years 10 months ago #29532513 by blake
Yes that is correct

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

6 years 10 months ago #29532514 by revz
When I run this script, the motor ramps up to speed, then slows down within a second or so. How do I define length of time at max rpm?

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

6 years 10 months ago #29532515 by blake
Oh this would be the Serial Watchdog, it is a safety feature. This can be disabled from the Configuration tab or by including the following line at the top of your script:

setconfig(_rwd, 0)

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

Time to create page: 0.083 seconds