The command works perfectly in that, when encountered in the script, the motor correctly targets and acquires the encoder position requested. However, in my application, I need to restart the loop/script on command, meaning when requested, the motor is to make one(1) forward-direction only rotation from the requested position, and again stop at the "home" position until toggled again. I believe this obviates use of the "Home" command because that will spin the motor backwards, but I digress.
The problem here is because the "Move" command targets an encoder position relative to 0--so in order for the motor to make one(1) forward rotation, from my understanding, the beginning of the script must zero(0) the encoder position. As such, the script must stop, and then be started again, so it reads the first line, which is to zero(0) the encoder position prior to initializing the "Move" command.
Even though there are multiple calls to "End"/"Stop" the script once the motor is correctly positioned, as well as a conditional-position Power 0,0,0 command, the motor continues to receive power to hold position. Accordingly, the script must be manually stopped via the radio-button in Motion Studio and then restarted via the "Play" button. When used like this, the motor behaves as intended.
However when issuing the "stop" command over serial (start-script command works fine) the motor locks up, hits max current draw on the benchtop power supply, and emits a horrid screeching noise. Both indicator lights on the actual controller stay lit, as opposed to toggling on and off when used with the radio buttons in Studio. The device is not mechanically jammed, FWIW.
After the motor controller is power cycled it will resume normal operation for one or two revs before the screeching lockup occurs again. This does NOT happen when connected over the USB--only serial.
Checksum for the serial communication is fine, and the unit is communicating--receiving and sending packets just fine according to our o-scope and serial interface software(DEWE soft).
I am sorry for the long winded post, but I wanted to give everyone the whole picture. Please find the code below:
Code: Select all
main ;puts 0, ["hello world", 13] ;pause 100 motorencpos(0) = 0 mainloop ;pause 100 if(motorencpos(0) < 8168) then move 0,700000,700000,700000,8168,1 endif if(motorencpos(0) >= 8168) then power 0, 0, 16384 ;puts 0, ["hello world", 13] endif stop end ;do ;move 0,500000,500000,500000,8168,1 ;while(motorencpos(0) < 8168); this conferred no advantage over the above loops ;stop goto mainloop