Simple closed loop speed script
. 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.
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.
Please Log in or Create an account to join the conversation.
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.
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.
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.
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:
Please Log in or Create an account to join the conversation.
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.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
setconfig(_rwd, 0)
Please Log in or Create an account to join the conversation.