From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabView and 3rd party USB

Hello,

 

As I am reading the input voltage of my "measurement board" in Labview,

 

1)- when I read the input voltage of 6 volts (app) of my board in "LabView" i got the value in two bytes e.g. when I give the 5.8 volts to my board and try to measure the input voltage in LabView I got the values in two bytes which are , on byte zero 202, and on byte one 251, so when I do some calculations on this then I got the value 5.8 volts,

 

QUESTION:

 

1)- How can I plot this voltage on a graph in LabView, as I have the value in two bytes?

 

2)- As in output in LabView, I got other values including these voltage output values as well. How can I filter just these two parameters relating to voltage and then plot it on the graph as 5.8 volts (or the exact input/output voltage I measure )

 

I shall appreciate if some one can give me some guideline in order to do this.

 

Regards.

0 Kudos
Message 31 of 49
(1,134 Views)

Mubi wrote:

1)- How can I plot this voltage on a graph in LabView, as I have the value in two bytes?


You would convert your 2 bytes to a floating point in the same way as you did the hand calculations. The value FBCA (your 2 bytes of 251 and 202) are 64485 in decimal, so that tells me you're getting a scaled value. What's the scale? Is it linear? A Type Cast function can be used to convert a 2-byte array to an integer and then you can use the numeric functions to get a float.

 


2)- As in output in LabView, I got other values including these voltage output values as well. How can I filter just these two parameters relating to voltage and then plot it on the graph as 5.8 volts (or the exact input/output voltage I measure )

This question is too vague. How are you collecting the data? Are you getting a continuous byte stream in which the voltage is 2 of those bytes, or are you separately querying for different values? 

 

0 Kudos
Message 32 of 49
(1,126 Views)

Hello ,

 

I dont understand why you invert the bytes which I told you in my question. according to my calculation that is CAFB for 5.8 volts. In decimal this is 51963.

 

As in order to read the input/output voltage from the "measurement board" I am using, I have to give some inputs in LabView inorder to get the inputvoltage, I do it in the following way,

 

input coloum                                 output coloum

 

transfertype          [7]                 transfertype          [7]        

address                [30]                address                [30]

cmdLength           [2 ]                 cmdLength           [2 ]

parameter length  [1 ]                 parameter length  [1]

parameter byte 0   []                 parameter byte    [251]

parameter byte 1  []                  parameter byte    [202]

 

(I already switched the values of byte 0 and 1 in order to find the actual value of voltage because the labview stores values in "bigendian" and my device do that in "Little endian".)

 

so when I give these inputs i am suppose to get the out put on the parameterbyte [0], parameter byte [1]. so in my out put fields in LabView I got the out put in two bytes byte [0], byte[1]. but what I gave on the input like transfertype etc, these values come on the output coloum again with the voltage reading in two bytes.

that means my PMBus give me all the values which I am giving as input INCLUDING the voltage parameters in two extra bytes.

 

Question:

 

I just want to plot these two bytes on a graph. how can I exclude these unwanted values on put and just plot the desire bytes?

 

and about scale is "I adjust the scale my self". I know the 3.3 volts is equal to 0x6A3D , so i converted it into decimal "6A3D" and find the value for one volt. which was in decimal "8191.8674" so what I do is what ever I got for voltage in my Labview frontpannel I convert that value into decimal and divide it by the  "8191.8674" then I get the voltage which is on the input or output.

example: I gave the input to the board that was 6volts app, I got the two byte value on output in labview, when i read the input voltage on the board that was FBCA, I switched the position to solve the Little Endian problem , so the decimal value was 51963 for the hexadecimal value CAFB , I devided this value by 8191.8674. I got 6.3 app , that was the voltage I gave on the input to the board. how can I do this in Labview?

 

QUESTION:

 

How can I do this Calculation in LabView?

 

I tried to explain my question more so I hope you will understand it better now. 🙂

0 Kudos
Message 33 of 49
(1,120 Views)

I shall be greatfull if some one can help me or quide me "How to do this math in the labview which I explained in my last question".

 

Best Regards,

0 Kudos
Message 34 of 49
(1,092 Views)

Mubi wrote:

Hello ,

 

I dont understand why you invert the bytes which I told you in my question. according to my calculation that is CAFB for 5.8 volts. In decimal this is 51963.


You said byte zero was 202 (0xCA) and byte one was 251 (0xFB). This is normally written as FBCA (byte 0 on the right, going up towards the left). This has nothing to do with LabVIEW. 

 

I honestly don't understand what you're saying when you're referring to "inputs" and "outputs" since I don't know if you're talking about inputs and outputs to VIs, or inputs and outputs to something else. I also don't understand what those columns are supposed to represent. 

 


and about scale is "I adjust the scale my self". I know the 3.3 volts is equal to 0x6A3D , so i converted it into decimal "6A3D" and find the value for one volt. which was in decimal "8191.8674" so what I do is what ever I got for voltage in my Labview frontpannel I convert that value into decimal and divide it by the  "8191.8674" then I get the voltage which is on the input or output.

You are assuming that (a) the volts to decimal value (i.e., your transfer function) is linear, and (b) there is no offset. Are you sure this is correct? Also, 0x6A3D = 27197 decimal. If your transfer function is linear, and there is no offset, and that 0x6A3D corresponds to 3.3V, then 1V would be 8241.5 (27197/3.3), not 8191.8674.

 

 


example: I gave the input to the board that was 6volts app, I got the two byte value on output in labview, when i read the input voltage on the board that was FBCA, I switched the position to solve the Little Endian problem , so the decimal value was 51963 for the hexadecimal value CAFB , I devided this value by 8191.8674. I got 6.3 app , that was the voltage I gave on the input to the board. how can I do this in Labview?

I thought you said earlier that CAFB was 51963, which was 5.8V. In fact, in your first sentence you said "according to my calculation that is CAFB for 5.8 volts. In decimal this is 51963.". So, is 51963 supposed to be 5.8V or 6.3V?

 


How can I do this Calculation in LabView?

As I indicated, in the same way that you would do it by hand. First convert your 2 bytes to a decimal value. Then apply the scale. 

 

 

0 Kudos
Message 35 of 49
(1,073 Views)

  • Proven Zealous Veteran
  •  

     You said byte zero was 202 (0xCA) and byte one was 251 (0xFB). This is normally written as FBCA (byte 0 on the right, going up towards the left). This has nothing to do with LabVIEW.

     

    ___________________________________________________________________________________________

     

    Yes that is true that we normally write byte zero on the right and byte one on the left. I my case I invert these bytes because LabView stores and send data in "BigEndian Format" and the hard ware I am dealing with stores and send data in "Little Endian Format". so in order to read the real data I have to invert the byte positions

     

     

    I honestly don't understand what you're saying when you're referring to "inputs" and "outputs" since I don't know if you're talking about inputs and outputs to VIs, or inputs and outputs to something else. I also don't understand what those columns are supposed to represent. 

     

    ___________________________________________________________________________________________

     

    As I mentioned before these inputs and out puts are to the VI's of the LabView, e.g. Inorder to read the input voltage I have to give some inputs to the/ in the LabView to get the required out put like I have to give the address of the hardware etc (I am attaching the picture of the front pannel [Input, Output] of the VI of the LabView)

     

     

    I thought you said earlier that CAFB was 51963, which was 5.8V. In fact, in your first sentence you said "according to my calculation that is CAFB for 5.8 volts. In decimal this is 51963.". So, is 51963 supposed to be 5.8V or 6.3V

     

    ___________________________________________________________________________________________

     

    5.8 Volts

     

     

     

    and thanks you so much for your guidence  I will try to do it in the way you show me , still I am thinking how can I filter just these two bytes of voltage from output coloum (as shown in the output figure) in LabView and show it on a graph?

     

    Thanks Again.

    Download All
    0 Kudos
    Message 36 of 49
    (1,052 Views)
    in the output coloum of the front pannel the 2 is the byte number I am recieving and on "parmByte[0]" and "parmByte[1]" I am recieving the output which is the Input voltage to the board. and I am attaching a picture of the bolck diagram of this front pannel . please have a look.
    0 Kudos
    Message 37 of 49
    (1,048 Views)

    You need to have the function call inside the loop. Otherwise, it will happen only once, and the only thing that will be graphed is the same value over and over again. Actually, given that you're wiring the cluster to the chart, what's shown on the chart is pretty much meaningless. As far "filtering", you're not going to filter it. You're going to unbundle the cluster. All you need to do is to unbundle those 2 bytes and use the snippet of code I showed you in reply#35 to get the voltage (assuming you put in the correct scaling value). Then feed this to the chart.

     

    I am assuming that those two cluster elements are U8?

    0 Kudos
    Message 38 of 49
    (1,036 Views)

    Thanks you so much, that will really help and can you please explain a little that what do you mean with "You need to have the function call inside the loop." Which Loop? and the example you sent me on the "Reply 35" you think it will work even if I will change the input voltage on the board and read it on the LabView?

    I shall be very thanks full if you will send me the same example (Example_VI.png) as a LabView File.

    0 Kudos
    Message 39 of 49
    (1,033 Views)

    The code you posted only shows one loop, unless you're only showing part of the program. Thus, it goes inside that loop. Think about it - if the function is not inside the loop then you're not continuously reading the data, right?

     

    The code that I showed you in reply #35 was based on what you've said so far. If the transfer function between the data you read and the actual voltage is linear then it will calculate the voltage. Assuming you use the correct scaling value.

     


    Mubi wrote:

     

    I shall be very thanks full if you will send me the same example (Example_VI.png) as a LabView File.


    It's just a couple of functions! You've already coded up a while loop - surely you can find the Join Numbers and Divide functions.

     

     

    0 Kudos
    Message 40 of 49
    (1,016 Views)