Scripting Acceleration and deceleration

5 years 4 months ago - 5 years 4 months ago #29531030 by Abaglin
I am trying to use the counting function that was posted on the roboteq website to use as an acceleration, deceleration, and a stopping point. I would like to have 1 right marker be a stop, 2 right markers be an acceleration point and 3 right markers be a deceleration point. I am still a novice at best when it comes to micro basic so the scripting could probably be modified to better suite the needs, but i am not sure on how to do this. as of right now the AGV drives over the tape but does not respond to any of the markers as I would like.

here is the script that I have so far:

if (MarkerLeft) then LineSelect = 1
if (MarkerRight) then LineSelect = 2

PrevMarkerLeft = MarkerLeft
PrevMarkerRight = MarkerRight

if(MarkerLeft = true)' When Left Marker is Present
if(PrevMarkerLeft = false)
MarkerCount = 0'Clear Counter When Left Marker First Appears
elseif(MarkerRight = true and PrevMarkerRight = false)
MarkerCount++
end if

elseif(PrevMarkerLeft = true)' Left Marker is Absent but was present Previously
if(MarkerCount = 1)
SetCommand(_S, 0)
SetTimerCount(1, PauseTime) ' Load stop timer timout value
RunState = false
elseif(MarkerCount = 2)
SetCommand(_S, 1000)
elseif(MarkerCount = 3)
SetCommand(_S, 300)
end if
end if

I have attached the compressed Zip file with the full script if you would like to look at it as well.

thanks for the help
Attachments:

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

5 years 4 months ago #29531031 by TechSupport
The way to check it is to have the script print some data back.

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

5 years 4 months ago #29531032 by Abaglin
Replied by Abaglin on topic Scripting Acceleration and deceleration
I have put a print command into the script,

print("MarkerCount = ", MarkerCount, "MarkerLeft = ", MarkerLeft, "MarkerRight = ", MarkerRight, " _AC = ", _AC)

I am not sure if these values are just going to show me if the controller is recognizing the tape and then modify the code accordingly? My biggest issue is on how to determine the proper coding for the motor control to react accordingly.

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

5 years 4 months ago #29531033 by TechSupport
What about the timers? If the timer runs and nothing changes, then there is a problem. If the timer never starts, then there is a problem.

This is not something I can check right now on my end for you.

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

5 years 4 months ago #29531034 by Abaglin
Replied by Abaglin on topic Scripting Acceleration and deceleration
Thanks for the advise on printing out the information that was relevant to what I was looking to the commands that I was trying to get at.

I have been able to get the counting to work properly as well as the stop function to work smoothly. I am still having some issues with the acceleration and deceleration. The count reaches the values that I am expecting but it just has a very short blip of information on the console page but then proceeds to exit right out of the loop and continue on at its previous rate. would you mind giving this a glance and see if I am referencing anything wrong for the 2nd and 3rd counts.

if(Marker_Left = true)' When Left Marker is Present
if(Marker_Left = false)
MarkerCount = 0'Clear Counter When Left Marker First Appear
elseif(Marker_Right = true and PrevMarkerRight = false)
MarkerCount++
end if

elseif(PrevMarkerLeft = true)
if (MarkerCount = 1)
SetCommand(_EX, 0)
if (GoButton) then SetTimerCount(1, PauseTime) ' Load stop timer value
if (TapeDetect and GetTimerState(1))
Throttle = -DefaultThrottle
end if

elseif(MarkerCount = 2)
SetCommand(_AC, 1, -1000)
if TapeDetect then SetTimerCount(1, 10000)
if GetTimerState(1)
Throttle = - DefaultThrottle ' When pause timer is cleared, AGV is allowed to run
end if

elseif(MarkerCount = 3)
SetCommand(_DC, 1, -500)
if TapeDetect then SetTimerCount(1, 10000)
if GetTimerState(1)
Throttle = - DefaultThrottle ' When pause timer is cleared, AGV is allowed to run
end if
end if
end if

Thanks for the help

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

5 years 4 months ago #29531035 by TechSupport
Not sure where the blip is occurring but I do see there is an E-stop command issued in the loop. I don't however see a release from the estop; setcommand(_MG, 1).

Can you provide a screencapture of this issue?

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

Time to create page: 0.106 seconds