Unity-M340 question

Crash+Flash

Member
Join Date
Jun 2004
Location
Magrathea
Posts
36
Is it possible to address an indexed bit of an integer as a BOOL in ladder with Unity Pro?
That is, I want to reference %MW<i>.<j> where "<j>" is an integer variable.

Happy Friday!
🍺
 
Yes
for example %MW12.3 will return the state of the third bit in memory word 12
But you must enable this - it is a project option setting
 
Perhaps I wasn't clear when I said I wanted to use a variable for the bit index meaning I want the bit index to be variable, not a constant.
It is clear that %MW12.3 will evaluate the fourth bit in word 12, but I want, nay, need, to reference say %MW12.[Index] where "Index" is an integer variable that is programmatically manipulated to change which bit in %MW12 is evaluated.
This is not that extravagant of a programming method but heck if I can figure out how to implement it in the Schneider scheme.
 
You can use an indexed addressing for example:
%MW10[index].4
It's the second bit in word 10+(index)
if index= 25
It's the second bit in word 35
 
ERROR:I would say:
You can use an indexed addressing for example:
%MW10[index].2
It's the second bit in word 10+(index)
if index= 25
It's the second bit in word 35
 
Thank you both for the suggestions but you're missing the point; I want to vary the BIT reference, not the WORD address.
For instance, given %MW999.[Index], %MW999.0 would be evaluated when "Index" = 0 and %MW999.15 would be evaluated when "Index" = 15.
 
maybe, if you create array of bools first

Something like testbits / array [0..15] of bools / memory address %MW900

then at program you can use testbits[index] command?
 
Last edited:
There is a function to convert a word to an array of ebools. then just use normal array handling to access the elements of the array
eg BoolArray[2] will access the second bit (when using a zero based count)
Note that bools and ebools are the same for your purposes
 

Similar Topics

Hello. New to Unity and had a couple quick questions. Can a Modicon M340 output to a small multiline LCD screen and not a full HMI?
Replies
4
Views
958
Hello. I'm trying to set up an M340 with a BMX AMO 0410 and a BMX AMI 0410 in Unity Pro XL 13.1. While trying to set up the IODDT for the card...
Replies
8
Views
4,153
Greetings, I'm new at PLC programming, but good a logic - so I thought. I've inherited a PLC system, which is presently operating in the field...
Replies
6
Views
2,480
If I am disconnected from M340, I cant see the Values. Unlike RSLogix when one gets to choose upload state values upon exit, and these state...
Replies
4
Views
2,255
I am trying to create a DFB that moves 16bits to Word, Word to INT, INT to Array of EBOOL. Basically a discrete output map. For the last function...
Replies
5
Views
2,422
Back
Top Bottom