TwinCAT

Cwhitehorne

Member
Join Date
Mar 2012
Location
usa
Posts
3
Hello everyone,

I am programming with ST, which I don't have much experience with. I am looking at four inputs and once all are true I want to monitor the inputs. If one of the inputs goes false I want all inputs to go false. I have a case statement that monitors the true/false condition, that works fine. The issue I am having is waiting until all inputs are true to start monitoring because the inputs don't all turn true at the same time. I will attach the code later today.

Thanks for any suggestions,
 
Welcome to the Forum!
Your ST code aside, one cannot "want all inputs to go false" via programming application.
One will have to go on the floor and either physically remove the "change-of-state" condition for the said Input type devices or disconnect the PLC Input module's field wiring.
Generally "speaking", an Input type device "informs" the CPU controller about the state of the connected system (similarly to the "READ ONLY" digital world attributes).
The user will use the state of the Inputs as they are within the CPU's memory and then develop the application in order to implement the intended functionality.
 
Thanks for your reply you are absolutely correct. I made a typo ... I want the all outputs to go false. Here is the code that i have started. I have just added the "icounter" variable in hopes that i could use it to better identify the condition that looks at the case statement.


IF bIn_1 = TRUE AND bIn_2 = TRUE AND bIn_3 = TRUE AND bIn_4 = TRUE THEN
bCondition := TRUE;
iCounter := 1;
ELSE
bCondition := FALSE;
END_IF

iIn_1 := BOOL_TO_INT(bIn_1);
iIn_2 := BOOL_TO_INT(bIn_2);
iIn_3 := BOOL_TO_INT(bIn_3);
iIn_4 := BOOL_TO_INT(bIn_4);

iMotion := ( iIn_1 + iIn_2 + iIn_3 + iIn_4);

IF (bCondition = TRUE OR iCounter = 1) AND NOT baxisAdj THEN
CASE iMotion OF
0,4:
bOut_1 := 0;
bOut_2 := 0;
bOut_3 := 0;
bOut_4 := 0;
iCounter := 0;
1..3:
bOut_1 := 1;
bOut_2 := 1;
bOut_3 := 1;
bOut_4 := 1;
iCounter := 1;
END_CASE
ELSE
bCondition := FALSE;
iCounter := 0;
END_IF

Thanks again for your comments,
 
Hello everyone-

This is the code that seems to be working well for me, now i really need to test it. If there is anyone who has any pointers on the ST i would love to here them.


iIn_1 := BOOL_TO_INT(bIn_1);
iIn_2 := BOOL_TO_INT(bIn_2);
iIn_3 := BOOL_TO_INT(bIn_3);
iIn_4 := BOOL_TO_INT(bIn_4);

iMotion := ( iIn_1 + iIn_2 + iIn_3 + iIn_4);

IF bIn_1 = TRUE AND bIn_2 = TRUE AND bIn_3 = TRUE AND bIn_4 = TRUE THEN
bCondition := TRUE;
ELSIF bIn_1 = FALSE AND bIn_2 = FALSE AND bIn_3 = FALSE AND bIn_4 = FALSE THEN
iCounter := 0;
ELSE
bCondition := FALSE;
END_IF

IF (bCondition = TRUE OR iCounter = 1) (*AND NOT baxisAdj*) THEN
CASE iMotion OF
0,4:
bOut_1 := 0;
bOut_2 := 0;
bOut_3 := 0;
bOut_4 := 0;
iCounter := 1;
1..3:
bOut_1 := 1;
bOut_2 := 1;
bOut_3 := 1;
bOut_4 := 1;
iCounter := 1;
END_CASE
ELSE
bCondition := FALSE;
iCounter := 0;
bOut_1 := 0;
bOut_2 := 0;
bOut_3 := 0;
bOut_4 := 0;
END_IF

Thanks for all your help
 
testing can be done by setting the simulation mode to on.
then go online and start the program.

a quick look seems to be working.
it looks like you only have two conditions, so do not use this case statement,
so just use this if, you are converting a bool to an INT it does work, however not good practice.
better to keep in boolean
 

Similar Topics

I am using twincat 3 to send some strings over TCP/IP. Where the server is a sensor and my PLC is the client. I noticed that the sensor didnt...
Replies
2
Views
61
I'm trying to control a device via MODBUS RTU and the ModbusRtuMasterV2_PcCOM in Twincat 3. I've configured a device with the right com port and...
Replies
7
Views
221
Hi! I am trying to run the 'SimpleSample' (https://infosys.beckhoff.com/content/1033/TF5100_TC3_NC_I/Resources/3438746891/.zip ) to understand the...
Replies
2
Views
106
I am developing a library in twincat and one of the function uses IID_ITcVnAccess_TcVnPoint2_DINT and the definition of this type is defined in...
Replies
0
Views
71
Sorry if this has been asked before, and apologies if this seems like a trivial issue, but I am new to Beckhoff and have been banging my head...
Replies
2
Views
152
Back
Top Bottom