Jump to content

UDFB Limits


Malcolm

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.

 

 

Link to comment
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.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

This site uses cookies. By clicking I accept, you agree to their use.