S7-SCL single bit of one WORD

cagliostro

Member
Join Date
Feb 2007
Location
vi
Posts
106
Hi all,

someone knows if is possible in SCL extract the single bit of a WORD or DOUBLE WORD defined as VAR_TEMP??

In other word I'd like to know how to realize in SCL the example in STL of the image attacched.

Thanks a lot

immagineeh.png
 
Something like this (not tested):
Not sure if you have to be careful of byteswapping.

Code:
Function extract_bit : VOID
VAR_OUTPUT
    bit_on : BOOL ;
END_VAR ;
 
VAR_TEMP
    test_word : WORD ;
    test_bit AT test_word : ARRAY[0..15] OF BOOL ;
END_VAR ;
 
test_word := W#16#00FF ;
bit_ON := test_bit[0] ;
 
END_FUNCTION ;
 
Thanks a lot Jesper for your post.

I confirmed you that the byte are swapping, but it's no problem I used the ROL and ROR instruction to bring as before all.
 

Similar Topics

HI i would like to know how to get a variable that will store the amount of times a program has been executed. The issue is I have 3 DBs for 1 FB...
Replies
2
Views
59
Hi, I have an intermediate-advance knowledge of programming with TIA Porta in Ladder, would you recommend me to start learning SCL for it to...
Replies
11
Views
550
Hello nice to meet you, im new in here, I'm currently trying to convert code written in STL for a S7-400 to SCL for an S7-1500, because when i run...
Replies
5
Views
314
Hi everyone, I am new to this amazing world of PLC, well... I mean, in practice, since I already knew electronics, programming languages, IT, and...
Replies
7
Views
649
Hi all, This is my first post; I am new to PLC Controls stuff and English is not my native language, so I apologize in advance if something is...
Replies
4
Views
509
Back
Top Bottom