Jump to content

signed binary problem.


Recommended Posts

I have 5 signed bits which creating problems. I have to get the below values when i run the VI. it is not converting the five bits to signed.

CAA6--------> 5.3v, DA80-----------> 20,C34D-------->3.3, E367........> 54.43v

You can find some examples from page 74 to 89 in th egiven PPt. Can any one help me.

post-20037-0-17357900-1302079967_thumb.p

pptpm.pdf

Link to comment

The following should do the job ..

post-9410-0-78415500-1302083725_thumb.pn

The Boolen Array to Number nodes need to be setup correctly ...

In the Properties (right click menu) set the Output Configuration to I16

post-9410-0-84958000-1302084094_thumb.pn

And make sure the Sign Extension Mode is set to If Output is Signed (or Always will work here)

post-9410-0-29016100-1302084431_thumb.pn

Link to comment

the given solution also not working and I sloved my problem. I just changed my labview version. Thank a lot for your kind help.

Can you help me in writing write visa. suppose let say, i want to write 3.3V to device to set. I have to convert that into Y=X.2(power of -N) , which gives into two bytes. You can see example in the given PPT (77th slide second model). Can you help me, how can i do that logic in labview.

Edited by sjukheter
Link to comment

I would like write two bytes of information to write visa. Two bytes consisting with 5 bits as signed (exponent) and remaining 11 bits are mantissa. I have done some coding but i need extend that to two bytes. you can find attched vi. At last i have to add those 5 bit and 11 bit to a two byte value. example, 3.3 is written input and output should be ---------> 1100001101001101----> here first fivets represents -8(always signed) and next 11 bits represents(845).

One more doubt, Please say in one sentense. what is difference between 4.x typecast and normal type case. I read the help information and not understand any thing.

i have done some coding and did not got the original output.

post-20037-0-47153500-1302158847_thumb.p

writevalue.vi

Link to comment

Here is how you can convert a voltage to the correct format and send it using visa write.

post-9410-0-95788700-1302170957_thumb.pn

No type casts needed. For what you are trying to do use the Number to Boolean Array

I would like write two bytes of information to write visa. Two bytes consisting with 5 bits as signed (exponent) and remaining 11 bits are mantissa. I have done some coding but i need extend that to two bytes. you can find attched vi. At last i have to add those 5 bit and 11 bit to a two byte value. example, 3.3 is written input and output should be ---------> 1100001101001101----> here first fivets represents -8(always signed) and next 11 bits represents(845).

One more doubt, Please say in one sentense. what is difference between 4.x typecast and normal type case. I read the help information and not understand any thing.

i have done some coding and did not got the original output.

Link to comment

Thank you so much for your help.

I have two small doubts that how Reshape array subset appending five bits as MSB and 11 bits as next to that. I think according to the discription it will append the 5 bits as LSB. I am little confused, can you how and where it is adding.

I don't know exactly when to use 4.x data and normal typecast converstion. can tell in exactly one sentence when to use and what id the difference. I have studied labview discription and not understand.

Link to comment

That is the Replace Array Subset (not Reshape array), and from the help description it "Replaces (not appends) an element or subarray in an array at the point you specify in index."

It our case it replaces a 5 bit subarray in an 16-bit array starting at index 11.

It will replaces:

Y[11] with N[0]

Y[12] with N[1]

Y[13] with N[2]

Y[14] with N[3]

Y[15] with N[4]

So the resultant output array is {N[4],N[3],N[2],N[1],N[0],Y[10],Y[9],Y[8],Y[7],Y[6],Y[5],Y[4],Y[3],Y[2],Y[1],Y[0],}

Probe the wire to see what data is on the inputs and output to see this working

Again you are heading in the wrong direction using Type Cast conversion, use the Number to Boolean Array instead!!

The Number to Boolean Array "Converts an integer number to a Boolean array" which is exactly what we need here, not a type conversion!!

But the Type Cast help clearly states the difference between the 4.x data and normal typecast converstion is how boolean data is handled.

"..... LabVIEW 4.x and earlier stores Boolean data in two bytes unless the data is in an array, in which case LabVIEW stores each Boolean element in a single bit. LabVIEW 5.0 and later stores Boolean values in a single byte, regardless of whether it is in an array. ....."

Link to comment

Really, I am confused and i need to know how it is displaying the binary "1100001101001101" after replace array subset. Before your message i think that it will add the coming 5 bits after 11 bits. On that time, i don't have any answer my self that how it is displaying "1100001101001101" instead of "1011001011000011". I have seen with probe now and I saw the output as "1011001011000011" and not "1100001101001101". Then how i got the real output or am i get going in wrong way.

post-20037-0-93801500-1302258017_thumb.p

Link to comment

The Word indicator whish I set to display numeric data in binary format, shows the binary data with MSB on the left down to the LSB to the right (as you would expected) !

Therefore it shows 1100001101001101 which is equivalent to C34D hex!

When you probe an array, index 0 is on the left with the index increasing to the right. Therefore when you probe a boolean array the LSB will be shown on the left and the MSB on the right.

This is why the probe of the boolean array is the reverse of what is shown in the Word indicator!! But they both represent the value C34D Hex.

Really, I am confused and i need to know how it is displaying the binary "1100001101001101" after replace array subset. Before your message i think that it will add the coming 5 bits after 11 bits. On that time, i don't have any answer my self that how it is displaying "1100001101001101" instead of "1011001011000011". I have seen with probe now and I saw the output as "1011001011000011" and not "1100001101001101". Then how i got the real output or am i get going in wrong way.

Link to comment

thank you somuch for brief explanation. I have one more problem with my event structure that contains 10 event cases. In that event cases are run according to the button press. I would like to run one of the case for every 10 mintus to update the data. is it possible to that with one event case.

Link to comment

You can use the timeout event to run code every 10 minutes

If no other events occur the timeout case will run every 10 minutes..

post-9410-0-39443100-1302260724_thumb.pn

thank you somuch for brief explanation. I have one more problem with my event structure that contains 10 event cases. In that event cases are run according to the button press. I would like to run one of the case for every 10 mintus to update the data. is it possible to that with one event case.

Link to comment

yes, I know that and problem is even i have to wait 10 min first time to see the results. Can i put any button in the timeout case like you can see immediatly or otherwise for every 10 minuts.

An event case can handle multiple events. right click to edit events handled by this case. At the bottom left there is a blue + to add additional events. Another way to do it with two event cases if you are using the producer consumer is to simply have both cases send the same message to the consumer.

Link to comment

What would be wrong with using Boolean logic (NOT, AND, OR) and ROTATE instead? There you have full control of signedness of numbers and that worked as far back as LabVIEW 2.x.And it's most likely magnitudes faster, since it can be all done inplace, translates typically directly into one or two assembly codes, and doesn't use variable size arrays at all.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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...

Important Information

By using this site, you agree to our Terms of Use.