TwinCAT Structured Text Programing (LOOP)

Sohaib28

Member
Join Date
Aug 2015
Location
Cottbus
Posts
31
Hello Everyone:

I have been able to read value via canopen interface using ADS protocol.
Actually my Structured Text Programming is weak. I can read the value only when I toogle 'Read' in the ADS. I want the READ the value automatically whenever I write a new value. But instead I have to toogle the READ everytime I write the a new value.

Can somebody send me the code in structured text of LOOP that I have to implement to READ so that it goes on automatically whenever I write a new value.

How to perform a loop on 'READ' in structured text? 'READ' is just a toogle bit. Please reply
 
Thanks Shooter.

Do I need to write the physical value here?

What is the value and old value here?
 
Last edited:
Hi Shooter. I have tried these 2 codes. But they are not working. Actually i want that whenever I write a new value the read toogle bit automatically becomes true.
In the first case scVoltage is the scaled voltage that I get after writing the value. But the read toogle bit does not go False and it remains True.

IF scVoltage>=1THEN
fbADSREAD.READ:=TRUE;
ELSE
fbADSREAD.READ:=FALSE;
END_IF

In this case whenever my write goes true my read goes true but the problem is that it reads the previous value.

IF fbADSWRITE.WRITE=TRUE
THEN
fbADSREAD.READ:=TRUE;
ELSE
fbADSREAD.READ:=FALSE;
END_IF

So what will be the code then in such a way that whenever I write a new value I automatically read the value.I dont have to toogle the bit by pressing
cntrl+f7.
Thanks
Regrds
 
IF scVoltage <> oldvoltage THEN
fbADSREAD.READ:=TRUE;
put here also to fill the array with the newvalues.
oldvoltage=scVoltage;
ELSE
fbADSREAD.READ:=FALSE;
END_IF
 

Similar Topics

Hi all, I've inherited someone else's program and can't for the life of me figure out his use of the # symbol in one of his structured text...
Replies
5
Views
1,920
Hello everyone: I have been able to read and write data via canopen interface through ADS read and write functional blocks in Twincat PLC...
Replies
9
Views
4,275
Hi, i'm really struggling to get any decent examples of the above. Can anyone help??
Replies
3
Views
10,457
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
55
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
Back
Top Bottom