Hi together,
A motor is meant to turn into one direction when a button is pushed. The motor is mean to turn into the other direction when another button is pushed.
Here is my CODE:
VAR_INPUT button_left: BOOL; button_right: BOOL; END_VAR
VAR turn_left: R_TRIG; turn_right: R_TRIG; signal: REAL; position_left: REAL; position_right: REAL; END_VAR
turn_left.Q(CLK:=button_left) IF turn_left.Q THEN signal:= position_left; END_IF;
turn_right.Q(CLK:=button_right) If turn_right.Q THEN signal:= position_right; END_IF;
I hope the code is understandable. If not, please write it, I will then further explain it. Thanx
yes your code is good
however i am missing a set command as now the signal will be on only one cycle. and this way you will not see it on.
and i am missing the reset when motor is on a side.
i am also missing a stop signal when the other direction is pressed. and a stop button would be nice too.
work on it. have also a look at the oscat library at w www.oscat.de w you will learn a lot from it.
Log in to post a comment.
Hi together,
A motor is meant to turn into one direction when a button is pushed.
The motor is mean to turn into the other direction when another button is pushed.
Here is my CODE:
VAR_INPUT
button_left: BOOL;
button_right: BOOL;
END_VAR
VAR
turn_left: R_TRIG;
turn_right: R_TRIG;
signal: REAL;
position_left: REAL;
position_right: REAL;
END_VAR
turn_left.Q(CLK:=button_left)
IF turn_left.Q THEN
signal:= position_left;
END_IF;
turn_right.Q(CLK:=button_right)
If turn_right.Q THEN
signal:= position_right;
END_IF;
I hope the code is understandable. If not, please write it, I will then further explain it.
Thanx
yes your code is good
however i am missing a set command as now the signal will be on only one cycle. and this way you will not see it on.
and i am missing the reset when motor is on a side.
i am also missing a stop signal when the other direction is pressed.
and a stop button would be nice too.
work on it.
have also a look at the oscat library at w www.oscat.de w you will learn a lot from it.