This widget could not be displayed.

VeriStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Boolean value from VeriStand model to FPGA

Solved!
Go to solution

Hi there,

 

I am quite new to LabVIEW and I have a question regarding FPGA Personality. I am trying to send a boolean value from my model to the FPGA. 

 

Here is a snapshot from my LV-project:

 

Capture.PNG

 

And here is the code from the xml-file:

 

<DMA_Write>

        <Packets>2</Packets>
          <Packet> <!--Packet 1-->
            <U64>
              <Name>Result</Name>
              <Description>Test</Description>
	      <Category>Input</Category>
            </U64>
          </Packet>
		  <Packet> <!--Packet 2-->
            <Boolean>
              <Name>Boolean Value</Name>
              <Description>Test</Description>
              <Category>Input</Category>
            </Boolean>
          </Packet>

 So my question how can I access the one bit boolean value from the U64 sent from VeriStand? If i try to use it in VS the boolean value is not sent to the FPGA. I think it is a very fundamental question but I do not know how to solve it.

 

Thank you!

 

Regards,

 

HScho

0 Kudos
Message 1 of 9
(6,758 Views)

Okay, the code was correct, I did not choose the latest bitfile in the .fpgaconfig XML-file. Smiley Wink So now I can access the boolean value.

 

But another question: If I get the U64 DMA data from VeriStand and want to write these to a local variable which is linked to a I16 control, how can I realize this? 

 

Is it correct in this way?

 

Capture.PNG

 

Thank you.

 

HScho

0 Kudos
Message 2 of 9
(6,751 Views)

Above is the screenshot with the working code:

 

Capture.PNG

 

0 Kudos
Message 3 of 9
(6,724 Views)
Solution
Accepted by topic author HScho

MHoffmann, I see a couple of problems with your implementation.

 

1) You're using "Split Number" too many times.  If you take a U64 and split it 3 times, you're left with a U8, which is not enough bits to properly represent an I16.

2) Using "To Word Integer" ("To I16") will not behave as expected in this case.  NI VeriStand uses the U64 DMA FIFO as a place to store raw bits corresponding to different data types.  Using the "To I16" primitive causes LabVIEW to convert the numeric value of one piece of data into another data type.  However, it does not cause LabVIEW to interpret the raw bits of one data type as another data type.

 

In order to do this, you need to do the following.  First split the U64 twice in order to get a U16.  Then use "Number to Boolean Array" to get a 16-element array, where each element is one bit of data.  Then use "Boolean Array to Number" and configure it to return an I16.  This will cause LabVIEW to interpret the bits in the Boolean array as a signed 16-bit integer.  Finally, you need to define an <I16> in your .fpgaconfig XML.  Here's an example of what it would look like:

 

 

 

Note that in this example I have the I16 and two Booleans inside of the same packet.  Since each packet is 64-bits, we can combine multiple pieces of data inside of one packet (this is known as "bit packing").  In this example, I'm only using 18 bits of the U64 (16 for the I16 and one for each of the Booleans), so I could put even more data in it if I wanted.

 

The XML in the .fpgaconfig defines the data in the packet from least significant bit to most significant bit.  So in this example, you can see "Result" is the least significant bits (since it is the "Lo" output of the Split functions), so it will be defined first in the XML.  The next is "Boolean", and the last is "Boolean 2".  So the XML would look like this:

 

<Packet>
      <I16>
          <Name>Result</Name>
          <Description>Test</Description>
          <Category>Output</Category>
      </I16>
      <Boolean>
          <Name>Boolean</Name>
          <Description>Test1</Description>
          <Category>Output</Category>
      </Boolean>
      <Boolean>
          <Name>Boolean 2</Name>
          <Description>Test2/Description>
          <Category>Output</Category>
      </Boolean>
</Packet>

 

If you need more help with theXML, a good place to start is the Creating a Custom FPGA Configuration File document in the NI VeriStand help.  Hope that helps!

Devin

 

Message 4 of 9
(6,705 Views)

Note that using the boolean array primitives to cast works well:

boolean array cast.png

 

But you can also use one primitive to do the same. the integer to FXP cast:

integer to fxp cast.png

Stephen B
Message 5 of 9
(6,698 Views)

Absolutely.  They are definitely useful, but they only work for FXP numbers.  Unfortunately there's no "integer to other integer cast" in FPGA, so you need to use the Boolean array prims

0 Kudos
Message 6 of 9
(6,695 Views)

Hi, 

 

first thanks for your detailed help. But if I change my code as you showed, there is still a coercion dot at the local variable: 

 

FPGA.PNG

 

The representation of the control is I16 as you can see on the picture. But after the "Boolean Array to number" the data type is U16. I think with the coercion there are not used the correct raw bit, am I right? Is the conversion of my FXP local variable correct?

 

Thanks again for your time and your help!

 

Regards,

 

HScho

0 Kudos
Message 7 of 9
(6,684 Views)

Hi HScho,

 

You're absolutely right, the coercion dot is a problem.  What you need to do is right-click the "Boolean Array to Number" primitive and go to its Properties.  Click on the Output Configuration tab and change the Representation to I16.

 

Regards,

Message 8 of 9
(6,670 Views)

Hi Devin, 

 

thank you very much, should have known that by my own.... 😉

 

I think this problem is solved!

 

Regards,

 

HScho

0 Kudos
Message 9 of 9
(6,666 Views)