Stopping motor after 750ms
I am having trouble stopping a motor after 750ms of running time in reverse. I am testing in the roborun console but i will be using an r/c remote to control the robot.
Here is my code:
'programme pour arreter le moteur apres 750ms
top:
while(getvalue(_p,1) < -100 )
settimercount (1, 750) 'démarrer timer pour 750ms
wait(10)
if (gettimercount(1) < 1) then
setcommand (_GO,1,0) ' set moteur à 0
wait(500)
end if
end while
goto top
Thanks to all
Carl
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Thanks
Please Log in or Create an account to join the conversation.
You could in a sense trigger the function as a command and disable as a command to get something like this in your timer.
You could query the motor command as getvalue(_M, nn) 'where nn is motor channel.
Please Log in or Create an account to join the conversation.
this works for me. stops after 1000ms because i changed my mind on legnht of time.
settimercount(0,1200) 'set timer
settimerstate(0,1) 'set timer to off
top:
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)
while (getvalue (_pic,1)<-100) 'gets pusle converted input
settimerstate(0,0) 'start timer
print ("timer=",gettimercount(0), "\n")
if (gettimercount(0) <1) then
setcommand (_ex, 1) 'emergency stop
end if
end while
setcommand (_mg, 1) 'release emergency stop
settimercount(0,1200) 'set timer
settimerstate(0,1) 'set timer to off
goto top
Hope this helps someone
Please Log in or Create an account to join the conversation.
So, are the four timers numbered 0-3 or 1-4?SetTimerCount/GetTimerCount
These two functions used to set/get timer count.
SetTimerCount(<index>, <milliseconds>)
GetTimerCount(<index>)
Where, index is the timer index (1-4) and milliseconds is the number of milliseconds to
count.
Ciao,
Lenny
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Carl
Please Log in or Create an account to join the conversation.
First, correct behavior using Timer(0):
Notice that Motor 1 and Motor 2 command curves are superimposed, and that Motor 1 and Motor 2 power curves, also superimposed, smoothly climb to match the commands.
Now, here's what happens if one tries to use Timer(4):
The motor commands are working correctly, but motor power is not. Acceleration is erratic, the two motors do not track each other, and motor output, even for the one that has a smooth power curve, never rises to match what's being commanded.
PLEASE, in the next edition of the user's manual correct all references to indexing of the timers.
Ciao,
Lenny
Please Log in or Create an account to join the conversation.
The only command function i have found that will stop the motor when its commanded to run is emergency stop. The thing is it shuts off the second motor also. The_ex function will not compile without an index but it shuts off both motors. What would be the best command to shut off only one motor when the rc radio commands it to run.
Carl
Please Log in or Create an account to join the conversation.