Stop/Start Script Over Serial Issue +Move Cmd Woes

Questions about using the MCL scripting language.
Post Reply
Cm452
Posts: 1
Joined: Wed Apr 15, 2020 8:20 am

Stop/Start Script Over Serial Issue +Move Cmd Woes

Post by Cm452 » Wed Apr 15, 2020 9:08 am

Hi all---I am new to the Basic Micro controller, as well as to the language, so please bear with me as I come up the learning curve. That said, I have been having problems with the "Move" command, which may or may not be related to a subsequent problem with serial.
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
Thanks in advance,
-Cm

User avatar
Basicmicro Support
Posts: 1441
Joined: Thu Feb 26, 2015 9:45 pm

Re: Stop/Start Script Over Serial Issue +Move Cmd Woes

Post by Basicmicro Support » Fri Apr 17, 2020 9:21 am

Please email this to support@basicmicro.com. I believe I talked with you but we will want to setup a test to see if we can reproduce the problem. We are a little overloaded right now and I don't want this to get lost in the forums.

Post Reply