# 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

##### Share on other sites

Simple idea - use function "Bit to NUM" (VisiLogic - vector menu) to copy your bit vector to MI or so. Then - I guess you know the way...

##### 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

##### Share on other sites

Hi Chris,

Why you desided, that you can transfer only 25 bits?! I just transfered 250...

##### Share on other sites

Hello Emil,

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

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).

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.

##### 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?

##### Share on other sites

Well you learn something new everyday!

I'll have no problems sending the array of MI's and just converting back on the PC side.

Thanks Simon

##### 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

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.

## Create an account

Register a new account

×