INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Need Help! Modicon M340 w/Unity Pro XL v10

Need Help! Modicon M340 w/Unity Pro XL v10

(OP)
I am trying to convert an Allen Bradley RSL5k program and am stuck on an addressing issue. In AB I have a UDT with a DINT member. I step through the bits of the DINT programatically with the following code

UDT_NAME.MemberDINT.[StepVar] and then I simply cycle through the applicable bits of the DINT by incrementing StepVar.

I need to do the same thing in Unity Pro, but cannot figure out how. Is this possible, if so, how? Please, and thank you very much!

"To be or not to be, that is the question" - William Shakespeare via Hamlet

RE: Need Help! Modicon M340 w/Unity Pro XL v10

Can't really do that with a DINT. However you can do something similar with a type word. I believe that there are functions which can convert from DINT to WORD and then access the state of a given bit within the word type. A pain in the you know what but that is the price you pay for strong data typing.

RE: Need Help! Modicon M340 w/Unity Pro XL v10

(OP)
djs. You are right - changed the type from a DINT to a WORD and if I write this: UDT_NAME.MemberDINT.1 where 1 could be 0-15 and Unity accepts it no problem. However, I need to step through the indexes programatically - and I cannot figure out how I do that based on the number contained in StepVar. Please, advise is much needed...?

"To be or not to be, that is the question" - William Shakespeare via Hamlet

RE: Need Help! Modicon M340 w/Unity Pro XL v10

Look at the MUX instruction

RE: Need Help! Modicon M340 w/Unity Pro XL v10

(OP)
The MUX instruction seems like it only selects between 2 inputs - I need 12, and possibly more in the future. Not only that, but I also, typically have 2-3 conditions that at least one is dependent on the index and others are simple logic. Thank you for the suggestion though. Maybe it will help.

"To be or not to be, that is the question" - William Shakespeare via Hamlet

RE: Need Help! Modicon M340 w/Unity Pro XL v10

If you have defined UDT_Name as type WORD, then you can access the individual bits with an integer variable Step_Var by using UDT_Name.Step_Var and Unity should resolve this OK.
Which is to say that it does in my code. I have arrays of words defined : Stationregs => ARRAY[1..3] of WORD, and address these with two integer indexes : Stationregs[Index1].Index2. Unity knows exactly what to do with these.

RE: Need Help! Modicon M340 w/Unity Pro XL v10

(OP)
Paulusgnome: I have constructed an array of type WORD but am receiving still receiving the error shown in the attached graphic. What you are describing is exactly the functionality I really need - any help will be very much appreciated!

I am using Unity Pro version 10, but am happy to upgrade if a later version will get me said functionality...

"To be or not to be, that is the question" - William Shakespeare via Hamlet

RE: Need Help! Modicon M340 w/Unity Pro XL v10

Oops, I fear I spoke too hastily. That bit index doesn't work, does it? Sorry about that.
I fear that you will have to write yourself a wee function block to do this. Translate your DINT into an array of bits which you will be able to index.

RE: Need Help! Modicon M340 w/Unity Pro XL v10

Attached is a screen shot of the use of the MUX instruction

RE: Need Help! Modicon M340 w/Unity Pro XL v10

(OP)
djs... That looks like it could work, but... I need it in reverse too. Is there such a creature, and can it work in Ladder with all 16 bits? This is getting close, but there are still some gaps and this last 'reversal' may be the trick. THANKS!!

"To be or not to be, that is the question" - William Shakespeare via Hamlet

RE: Need Help! Modicon M340 w/Unity Pro XL v10

Perhaps Paul has the right idea. Convert your input into an array of Booleans, work on it and then convert back to word etc. Look up conversion functions in the help.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close