I am currently controlling a shift actuator that is also giving me position feedback in PWM signal. It works great by using my PCAN-MIO and an H-Bridge. I can control the shift actuator to turn in one direction and stop until it reaches a specific position based on the reading of the position sensor feedback. Here is the loop that I am using below. The only challenge that I have is that:
1) I also need to stop this loop with respect to time in 200ms in case it does not reach the target position due to gear clash. I want to add that logic so that I do not burn the shift actuator motor.
2) I would also like to set a condition to stop the loop if the current sense feedback exceeds a current limit.
Code: Select all
'Start loop logic
PrintToOutputWindow "Now start LOOP..."
'Safety Condition Shift Range Limit Detector
Var13.Value = 1
PrintToOutputWindow "value set to : " & CStr(CInt(Var13.Value))
Wait(1000)
If Var14.Value > 730 Then
MsgBox "Shift Actuator is out of shift range",,"Error"
Exit Sub
Elseif Var14.Value => 695.1 Then
MsgBox "Shift Actuator is already in 4 Low position",,"Error"
Exit Sub
Elseif Var14.Value <= 220 Then
MsgBox "Shift Actuator is out of shift range",,"Error"
Exit Sub
End If
'------------------------------------------------------------------------------------------------------------------------------------
'Start Shift
If Var14.Value < 695 then
Var15.Value = 1
PrintToOutputWindow "value set to : " & CStr(CInt(Var15.Value))
Var20.Value = 1
PrintToOutputWindow "value set to : " & CStr(CInt(Var20.Value))
Do until Var14.Value > 695
PrintToOutputWindow "value set to : " & CStr(CInt(Var15.Value))
loop
Var15.Value = 0
Wait(10)
Var20.Value = 0
Exit sub
End if

Can you please help?