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,880
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,206
Hi, i'm really struggling to get any decent examples of the above. Can anyone help??
Replies
3
Views
10,431
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
1
Views
61
Hi everyone, This is my first time posting, so please forgive any omissions or mistakes. I am attempting to control the velocity of a stepper...
Replies
18
Views
753
Back
Top Bottom