How do you pack bits into word in Unity Pro?

Welcome to the forum.

I'm not super familiar with Unity Pro, especially with some of the other languages, but in LL984 language you use MBIT to set a bit in a word, and SENS to read the state of a bit in a word.

Hope that helps.
 
Thanks for welcome.
Have already got some Modicon answers from this site by Googling, so joined.

New to Modicon, but plenty familiar with AB and GE.

Unfortunately I don't find any Mask functions in the Unity Pro 4.1 libset, except MASKEVT, "global event mask".

Guess I'll just give SCADA the Booleans as words, not my preference.
 
Couple ways:

On variable editor:

(bits0..15/%MW0)

Name___________address____type______Comment

Word_bit0______%MW0.0_____bool______1st bit of word
Word_bit1______%MW0.1_____bool______2nd bit of word
...
Word_bit15_____%MW0.15____bool______15th bit of word


On %MW0 address you can see integer value of bits.


Or you can use alternative: bit_to_word + word_to_int conversion and int_to_word + word_to_bit conversion blocks, if you want use unlocated addresses


Welcome to the forum
 
Last edited:
So, to set individual bits in a word, in order to optimize transmitting them from PLC to SCADA, I use 16 BYTE_TO_BIT blocks, each using only BYTE_TO_BIT output BIT0:

Byte_0 to BYTE_TO_BIT IN, resulting BYTE_TO_BIT BIT0 to %MW500.0
Byte_1 to BYTE_TO_BIT IN, resulting BYTE_TO_BIT BIT0 to %MW500.1
Byte_2 to BYTE_TO_BIT IN, resulting BYTE_TO_BIT BIT0 to %MW500.2
etc.

lengthy but seems workable, and couldn't use the direct addressing in a DFB.
(Need direct addressing to ensure contiguous addresses sent to SCADA)
Am assuming this will not write to the non-specified %MW500. bits.
Would love to test it but haven't got Simulator past "This isn't a valid PLC Address..." message yet; shutdown all AB RSlinx processes, set Windows Simple TCPIP to enabled.
 
Can you post screenshot or zipped program of this?

ps.

Do you have 16 different integers with values 0 and 1 and you wan't change them to 16 bools?

Or only 1 integer and you wan't change it to individual bits?
 
I have 16 Booleans (16 bytes in Unity)
that I want to compress into one Integer %M500

I want to put the state of Boolean 0 into %M500.0
Boolean 1 into %M500.1
Boolean 2 into %M500.2
 
Is fault_bit ebool or bool type variable.

If it is boolean type you can give %M500.0 address directly for it on varable editor window.

If fault bit is ebool and have allready %Mx address, then copy variable with move block to bool type variable (ex. fault_bit_hmi, then give address %M500.0 directly for this new variable on varable editor.)

And if fault_bit is ebool type variale, but don't have address, easiest way is change variale type to bool and give %M500.0 address directly for it. No need to use conversion blocks for this.
 
Last edited:
Just use the Bit_to_Word instruction. This is a function block with 16 Boolean inputs to 1 word output. Or to go the other way use the Word_to_bit instruction.

I note you said in a a dfb, if this word is an input to the dfb you can directly reference the individual bits, right click on the variable definition of the word (within the dfb) and select bit assign.
 
New to Modicon, but plenty familiar with AB and GE.

Good luck with Modicon Dan.

I'm finally getting out of the Modicon world. Retired my last 984 in November. I can't tell you how happy that made me.

Hopefully we'll see you around the forum a lot more, lots of expertise and experience here.


Troy.
 
Troy
Modicon has changed significantly from 984 days. It would be nearly 15 years since the 984 days.
The current range is all IEC1131 programming (all languages), tag based, etc etc.
The new M580 is one powerful little beast
 

Similar Topics

Programming RS Logix 5000 for Compact logix how to pack 8 bits to a byte. Ii IEC... there is a PACK instruction suited for this
Replies
8
Views
2,055
I am using Schneider elau pack drive servo motor ISH-100. I am facing the problem that On the ISH -100 red light is blinking and pack drive C-600...
Replies
0
Views
33
Has anyone already worked with ALTOPACK equipment, model AVE-PC (VFFS). Year 2009, I need to do a retrofit for this equipment, has anyone already...
Replies
0
Views
60
Hi All, If i have the original project for TIA Portal V13sp1. the SoftPLC is running in V13sp1 in a 1515sp Win7 industrial PC. I was not able to...
Replies
6
Views
1,498
Hi People, I have a ScadaPack 330E that has been sitting on a shelf for a few years (previously working), and have recently re-installed...
Replies
4
Views
1,788
Back
Top Bottom