TwinCAT comparision function problem

Join Date
Nov 2011
Location
Ireland
Posts
182
Hello

i am using TwinCAT and am having trouble creating a function that i want.


basically this is what i want:

i have two conditions that when fulfilled i want to create a digital output.


i have a digital output signal and an encoder speed signal. i want a digital signal to be created in the plc program when the digital output signal is active and the speed signal is greater or equal to 5 RPM


is there some function block i can use to do this or some threshold block?


thanks
 
let´s se.

Is it in TwinCAT2/CoDeSys environment?

If that´s the case:

The function GE should do the trick. (Greater or Equal)
EQ = (EQual)
LE = (Less or Equal)
 
I'm not using that language to program therefore I can be wrong, but I guess you should put in the GE block the rMotorRPM and substitute the SCADAonoff for the 5.

After having done that you could use the output (which will be TRUE or FALSE) depending on the input to add it to a AND box wich will have also another input: SCADAonoff.

At the end you should put the output.

That should make it.

Good luck!


PS:
in ST:
Output := ((rMotorRPM >= 5) AND (SCADAonoff));
 
thanks Joan, i think i may have got it now. i can test it until tuesday

just one quick question regarding your code.

PS:
in ST:
Output := ((rMotorRPM >= 5) AND (SCADAonoff));

dose this bit of code only give a "1" output for the conditions that the speed is greater or equal to 5 rpm and the SCADAonoff signal is "1"?

i.e. in the picture i attached earlier that the code satisfies only one of these two conditions i gave?
 
actually dose anyone know if there is some function block or signal that is on whenever the plc is in run mode.

i remember when working with some other plc's that there was always some signal reserved as an "on" indicaiton

basically i am looking for a signal that is always "1" when the PLC is running
 
Last edited:
i think i have it wrong but is it something like this?

i am still not sure how to define "greater than or equal to"

thanks for the suggestion

On the lower leg of GE, remove the scadaonoff and write a 5.
On the output leg of GE, attach an AND -block.
On the spare leg of the AND-block, use the scadaonoff.
Play with the signal inverter (right click on the leg's root) until you get it right.

Kalle
 
actually dose anyone know if there is some function block or signal that is on whenever the plc is in run mode.

i remember when working with some other plc's that there was always some signal reserved as an "on" indicaiton

basically i am looking for a signal that is always "1" when the PLC is running

You could assign such a signal yourself, but if you tell the purpose of it, there might be a more pinpoint solution.

K
 
thanks yes this is what i have come up with for the two signals i need (see picture)


wel i have an "OPC OK" and a "PLC OK" indicator lamp on my SCADA screen. i want these to stay on as long as my OPC server is active and the PLC is running.

i was looking at the OPC server to see if there was any tag that i can use. but i am not sure if there is one.

i am using the two signals mentioned in the picture for two other indicator lamps

delete.PNG
 
Regarding your question, yes, my code assigns the logic value of the right side of the equal sign, therefore,

Output := TRUE only if rpm >= 5 and scada is on.
 
The plc oke light is tricky, as it means you must be sure there is communication, this must be done by a watchdog in the HMI.
 
and for this GE i saw you found it.
when you click this ADD (default) and press F2 you will get a list with all posibilities you have.

If not enough get yourself oscat.de (it is english)
 
Forcing can be a little misleading in TwinCAT. If you force a variable, it gets set at the beginning of a scan. If something in the program then changes the value, it will take on the new value and no longer have the forced value.

You can see this in a very simple program like this:

Code:
PROGRAM MAIN
VAR
	v1 : INT;
	v2 : INT;
	v3 : INT;
END_VAR


V1:=10;
V3:=V2+V1;

When you run the program V3 will be set to 10. Now try to force V1 to 1 and you would expect V3 to become 1, but it doesn't. V1's force is overridden by the V1:=10 and V3 continues to be 10. Now if you force V2 to be 1, then V3 will go to 11 that is because there is no program code to over write the forced value.

Now swap the 2 lines of code like this and try to force V1 again. You will now see that V3 will change its value because it uses the forced value of V1.

Code:
V3:=V2+V1;
V1:=10;
 

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
73
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
72
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