Reading in a digital input
- dmkroeber
- Topic Author
8 years 9 months ago #29529939
by dmkroeber
Reading in a digital input was created by dmkroeber
I am writing a script to take a 5v level digital input to turn a motor. When digital pin 1 is high I want the motor to move forward when it is low I want it to stop. When digital pin 2 is high I want the motor to run in reverse when low I want it to stop. The controller I am using is a Sbl 1360. With the current code below I am getting Unexpected end of file error.
Top:
Forward = Getvalue(_DI,1)
Backwards = Getvalue(_DI,2)
if Forward = 1 Then
SetCommand(_GO,1,250);
Else
SetCommand(_GO,1,0)
if Backwards = 1 Then
SetCommand(_GO,1,-250)
Else
Setcommand(_GO,1,0)
goto Top:
Top:
Forward = Getvalue(_DI,1)
Backwards = Getvalue(_DI,2)
if Forward = 1 Then
SetCommand(_GO,1,250);
Else
SetCommand(_GO,1,0)
if Backwards = 1 Then
SetCommand(_GO,1,-250)
Else
Setcommand(_GO,1,0)
goto Top:
Please Log in or Create an account to join the conversation.
8 years 9 months ago #29529940
by TechSupport
Replied by TechSupport on topic Reading in a digital input
You need "end if" after the if then statements.
Top:
Forward = Getvalue(_DI,1)
Backwards = Getvalue(_DI,2)
if Forward = 1 Then
SetCommand(_GO,1,250);
Else
SetCommand(_GO,1,0)
end if
if Backwards = 1 Then
SetCommand(_GO,1,-250)
Else
Setcommand(_GO,1,0)
end if
goto Top:
Top:
Forward = Getvalue(_DI,1)
Backwards = Getvalue(_DI,2)
if Forward = 1 Then
SetCommand(_GO,1,250);
Else
SetCommand(_GO,1,0)
end if
if Backwards = 1 Then
SetCommand(_GO,1,-250)
Else
Setcommand(_GO,1,0)
end if
goto Top:
The following user(s) said Thank You: dmkroeber
Please Log in or Create an account to join the conversation.
- dmkroeber
- Topic Author
8 years 9 months ago #29529950
by dmkroeber
Replied by dmkroeber on topic Reading in a digital input
Also is that the correct way to read in digital inputs 1 and 2 on the SBL 1360 using pins 4 and 8 on the 15 pin connector.
Please Log in or Create an account to join the conversation.
8 years 9 months ago #29529953
by TechSupport
Replied by TechSupport on topic Reading in a digital input
The syntax code is correct. It is a matter of whether or not you are wired on the correct pins if the controller will get the actual readings.
Please Log in or Create an account to join the conversation.
Time to create page: 0.073 seconds