Jump to content

MB/XB vectors via COM


Recommended Posts

Hey guys,

I'm playing with my V130 and I'm looking for a way to perform a protocol send on a vector of MB's or XB's. I have a long shift register (255 bits), and would like to have the ability to send it out and a long string of 1's and 0's. Unfortunately all I can find is the function to send a vector of MI's, ML's, DW's etc. but not MB's or XB's.

Does anyone have any good ideas on how this could be accomplished?

Thanks,

-Chris

Link to comment
Share on other sites

Hello Emil,

That would work, however even using a Bit to Num won't convert a array of bits greater than 25. I guess I could break the bit array into groups of 25 bits, convert each to a DW, then string together 10 DW's in the message string. Still a lot of work. I'm going to start with this route, but if someone knows of something simpler, please let me know!

I was hoping there was a way to use Protocol Send, send type Stream with a Vector Length 255, then Link the first MB/XB. Unfortunately the Stream function in the send seems to only work on integers. This might be something worth considering in a future release, because it would be very useful and would seem to be a pretty simple add-in.

Thanks,

-Chris

Link to comment
Share on other sites

Hello Emil,

I believe your number representing your 250 bits is incorrect.

If I perform a BIT --> NUM conversion on 250 bits with only my 10th bit set in my shift register my value is 1024.

post-240-025751100 1286476958_thumb.jpg

If I convert with only the 50th bit set in my shift register my value is 1125899906842624 (far exceeding the value of an MI, ML, or DW).

post-240-009885400 1286476964_thumb.jpg

The BIT --> NUM conversion is governed by the following equation: y = 2^(x), where x is the number of bits you wish to convert. This is where I believe you can only convert a maximum of 25 bits, because 2^25 = 33554432 (which is near the maximum value of a DW).

This is where I think being able to send a bit array (vector of MB's or XB's) out as a single stream (1's and 0's) using Protocol Send would be very useful. It would almost the same as the call you would make from the PC side using the Unitronics Active X or .NET DLL, where you have the DLL populate the array with the starting address, and number of bits.

Anyway, just a thought for a future enhancement. Thanks again for your help.

Link to comment
Share on other sites

  • MVP 2014

I would expect a Bit-> Num conversion to use a vector of numerical registeres once the number of bits exceeded the size of the MI, ML or DW. Hence the "number" in those registers would not make sense as a number, but would be a valid bitwise repesentation of the original vector of individual bits. So, if you then converted the vector of numbers back to a vector of bits, you should get what you started with.

Maybe the term BIT->WORD conversion would be a little less confusing?

Link to comment
Share on other sites

A double word is 32 bits, so represents a much larger integer than you have listed. Where did you get 25 bits from? For a reference of datatypes, try

http://en.wikipedia.org/wiki/Integer_(computer_science)

Check the helpfile for the Bit -> Num function. After reading it, I can say the Unitronics team did a good job representing how this function works, particularly in your case.

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

×
×
  • Create New...