Jump to content
Sign in to follow this  
Malcolm

UDFB Limits

Recommended Posts

I am communicating to a remote IO system not from Unitronics.

This IO System has 16,32, and 64 Digital Inputs or Output Modules but will only receive the information in 16bit registers via modbus in holding registers.

 

In order to translate digital values to registers I can use the num to bit or bit to num option of the unistream but I am bound to using an array of bits to use it.

I have my variables declared differently in my program therefore I need to use a lot of programming space and time to do it.

 

For example let's say I have variables named Valve1Open, Valve2Open, Valve3Open, ect.

First I need to create an array of bits ex OutputArray[0..16]

Then for each variable I need to do: 

Valve1Open == InputArray[0]

Valve2Open == InputArray[1]

Valve3Open == InputArray[2]

...

and so on.

Then BitstoNum from OutputArray to get my OutputRegister to use in modbus.

For projects with multiple modules than can take 100-200 IOs or more this can get frustrating. 

I would like to use a UDFB to put in all my variable names and just get 16 bit register as a result and reuse the block to reduce time,space, and variables.

Therefore I need at least 16 inputs/outputs on the UDFB.

But I could find more applications for UDFBs with more that 10 Inputs and Outputs.

 

 

Share this post


Link to post
Share on other sites

Hello,

 

For the inputs, you could collect the bit statuses into a user-defined struct, then pass the collection of this struct into the UDFB.  For instance, I created a struct of 16 bits, then I created 3 tags using this struct as the "type of tag".  This allowed me to pass 48 bits into the UDFB as a test. 

 

You could then collect the statuses of these bits at the end of the UDFB ladder into a number to use with Modbus, as you have mentioned.

 

Please watch the following tutorial on structs for UniLogic.  User-defined structs are covered about 5:30 into the tutorial: https://www.youtube.com/watch?v=98UuQXZC1as&list=PLFBq_OH6_be7snAZAycZzQMvAWjHkX9Pz&index=5

 

Let me know if this helps.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...