Stopping motor after 750ms

5 years 3 months ago #29530289 by TechSupport
Try the motor stop.

Setcommand(_MS, cc) where cc is the motor channel. You have to send the e-stop release to resume for this command.
setcommand(_MG, 1)

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

5 years 3 months ago #29530296 by ccsgtech
Replied by ccsgtech on topic Stopping motor after 750ms
When you say setcommand(_ms,cc) if i want to use channel 1 for the motor stop, i would write it like this: setcommand(_ms, 1) is it the right way. Its confusing because you wrote cc, does thaht mean 2 indexes?

so far the setcommand_ms did not work good for me.

Also, i have been able to stop the motor with the setcommand (_go,1, 0) but using a rc remote and mixes up my command priorities. for this to work i need to set serial as first and pulse second.
If i use a while statement, nothing will happen until i flip the switch back on with bolth channels.
and when i use a if statement it only works until the watchdog timer runs out (250ms) and in this 250ms period, the second channel stops working because serial takes priority.

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

5 years 3 months ago #29530297 by TechSupport
Some controllers are dual channel so you need to specify which motor channel you are telling it to stop. If a single channel controller, then the default cc value is 1.

Then perhaps you can engage another pulse input value to do the same instead.

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

5 years 3 months ago #29530298 by ccsgtech
Replied by ccsgtech on topic Stopping motor after 750ms
I think my problem is pulse vs serial priorities.
If i completely disable pulse and let serial as only active command.
could i do something like:


pulse = Getvalue(_pic,1)

Setcommand(_go, 1, pulse)

pulse2 = Getvalue(_pic,2)

Setcommand(_go, 2, pulse2)

And then i would be able to play in the script like i want without priorities of input stepping over eachother?


Then i colud simply do:

while pulse <-100 and timer is timed out

setcommand(_go, 1, 0)

end while

reset timer
settimerstate off


and the other channel would still work?

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

5 years 3 months ago #29530301 by ccsgtech
Replied by ccsgtech on topic Stopping motor after 750ms
After setting command priorities to 1,serial and all others to none, this code finally did it for me.


settimercount(0,750) 'set timer
settimerstate(0,1) 'set timer to off

top:
pulse= getvalue(_pic,1) 'put pulse ch1 in variable
setcommand(_go,1, pulse) 'serial control of motor command with pulse input
pulse2= getvalue(_pic,2) 'put pulse ch2 in variable
setcommand(_go,2, pulse2)'serial control of motor command with pulse input


print ("moteur=",getvalue(_m,1), "\n")
wait (10)
print ("timer=",gettimerstate(0), "\n")
wait (10)
Print("pulse=", getvalue (_pic,1), "\n")
wait (10)
print ("timer=",gettimercount(0), "\n")
wait (100)

if (getvalue (_pic,1)<-100)then 'gets pusle converted input
settimerstate(0,0) 'start timer

print ("timer=",gettimercount(0), "\n")
end if

while (gettimercount(0) <1) and getvalue (_pic,1)<-100 'stops motor 1 and makes shure motor2 runs and sets timer state
setcommand (_go, 1,0)
pulse2= getvalue(_pic,2)
setcommand(_go,2, pulse2)
settimerstate(0,1)
end while




if (gettimerstate(0) >=1 and gettimercount(0)<2)
settimercount(0,750) 'set timer
settimerstate(0,1) 'set timer to off
end if

goto top

Carl

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

Time to create page: 0.089 seconds