Closed Loop Count Position Mode: Scripted PR Commands Go Double Input # of Counts, HBL2360

6 years 10 months ago #29532019 by guest0309
Hello,

A few of my !PR commands in a script cause my motor to turn double the requested number of encoder counts. I only have this issue with scripted commands; Serial console commands work just fine. The first !PR always goes double the input counts EXCEPT when the encoder counter is set to 0, but there are a couple other !PR commands later on in my script that are not fixed. Any help would be greatly appreciated.

PS: !PRX commands work fine

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

6 years 10 months ago #29532021 by blake
To clarify the !pr command will send the controller to the specified number of counts relative to its current position. So for example, with count beginning at zero, !pr 1 100 will turn the motor clockwise 100 counts. Following that command with !pr 1 100 again will send the motor clockwise another 100 counts, so count position would read 200.

To send to an absolute position !p should be used. This will send the motor to any count position you specify in the command. So using the above example, from zero sending !p 1 100 would send to count position 100. Sending !p 1 100 a second time would not move the motor at all as it would already be at the commanded position.

By the way, the short commands (the ones that begin with !, ?, ~, ^) should only be used when testing in the console tab of Roborun+, not in an actual Microbasic Script. If you are writing a MicroBasic script that is being uploaded to the controller setcommand() would be used in implementing commands to the controller. See page 147 of the user manual.

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

6 years 10 months ago #29532022 by guest0309
Thanks for the reply.

I used "SetCommand(_PR, 1, 100)" notation in my script. My issue is that some of my PR commands send cause the motor to rotate double the number of requested encoder counts. For example, if I wrote in a script "SetCommand(_PR, 1, 100)" the motor would rotate 200 counts. Not necessarily to absolute position 200, but +200 counts relative to its original position.

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

6 years 10 months ago #29532026 by blake
Okay I understand. Can you please attach your config file and script so I can take a look? Or if you feel more comfortable you can email it to This email address is being protected from spambots. You need JavaScript enabled to view it., just reference in the subject line this forum thread.

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

6 years 10 months ago - 6 years 10 months ago #29532035 by guest0309

File Attachment:

File Name: RoboteqScr...tion.zip
File Size:2 KB

Here they are. If you would like, I can provide more scripts that have this same effect.
Attachments:

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

6 years 9 months ago #29532059 by niko
Hello,

the problem is the following:
Usually in closed loop count position the Integral Gain should not be as high as the proportional gain. Integral gain causes oscillation around the target point (in our case this 414). Since P and I have the same value this oscillation is big and can even reach the double counts. In your script apparently the 5 seconds are not enough in order to reach the tergeted point. If you increase the wait value to e.g. 50 seconds you will see the oscillation in your motor.

A simplistic description if the PID controller can be found here .

What you need to do is to tune the PID system according to your system requirements and needs. I would suggest starting with PID = 1,0,0.

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

Moderators: tonysantoni
Time to create page: 0.109 seconds