Siemens SCL Addressing Problem

Usireland

Member
Join Date
Mar 2013
Location
Sao Paulo
Posts
169
Hello All,

I am new to programming with Tia Portal and I am having difficulty with something that we have found "easy" in other programming software.

We are using an Array of Dints and we need to access individual bits of those Dints.

So for instance we have:
HMI.Buttons[0].%X0 := 1;

The above syntax works in Tia portal, however what we actually want to do is instead of using [0] and %X0 we would like to replace them with variables kind of like this:
HMI.Buttons[MyPage].MyButton := 1;

In AB we can do this using the syntax:
HMI.Buttons[MyPage].[MyButton] := 1;

In B&R we can do this using the syntax:
HMI.Buttons[MyPage].MyButton := 1;

I have tried both syntaxes, unfortunately without success.

Does anyone know the correct syntax for an S7-1200?

Thanks
Regards
Ian
 
The array of DINTs is in reality a two-dimensional array. Right ?
That is at least how I interpret the AB and B&R code samples.
Then why dont you setup variable as a two-dimensional array ?

If you must view the bits as a DINT, then consider to have an AT-view for the variable.
That is exactly what it is for, to view the same data with two kind of representations.

Disclaimer: I am not sure if this is possible with S7-1200. For S7-1500 it is possible, but require that the DB or FB is not "optimised".
 
In general, in Siemens, DINTS are not also an Array of Bools.

That sort of indirect access is definitely possible if you use an array of bools, however, instead of an array of dints. A 2 dimensional array [1 to number of dints, 0 to 31 bits in each "dint"] probably makes sense.

You may be able to use something called the AT construct to do this, not 100% sure if that's supported in the 1200. It essentially declares the same tag as two different data types, so you can access it either way.

In the newest version of Portal, they have also added instructions (at least for the 1500) called Gather & Scatter that take a number of bits and combine them into a single byte/int/dint or vice versa, if you really need the DINT version for some reason.
 

Similar Topics

Hello, When you want compare values of an array to a range of numbers is it a right way to do that? FUNCTION ADD VAR_IN_OUT A:ARRAY[1..50]...
Replies
5
Views
2,073
Hi All, I need to try and convert some code from Siemens SCL (TIA16) over to Allen Bradley RS5000. I have attached an image of the SCL and what...
Replies
10
Views
4,061
in the scl code written in screenshot Line 1 condition is false but still the program checking the line 2 condition and says it is true i had...
Replies
3
Views
1,762
I am new to PLC programming. Is there a standard way to incorporate alarms / warnings / events such as the exceptions in C++ or Java where you can...
Replies
5
Views
1,985
Could someone help me to convert following from STL to SCL? AN #PV_EXT_S JC MEAS L #PV_EXT L 1.000000e+000...
Replies
9
Views
2,784
Back
Top Bottom