LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Fractional String To Number and vice versa for FPGA

Hello,

 

I need a VI, which can do the same functionality as Fractional String To Number and Number To Fractional String in host. Also Number To Decimal String and Decimal String To Number.

I've implemated VI, which does that functionality in a part.

 

Please, help me to implement that conversation for FPGA.

 

Thank you in advance.

0 Kudos
Message 1 of 15
(3,868 Views)

Hi Hayk,

 

why do you need this on a FPGA target?

 

Suggestions/comments:

- Arrays in the FPGA have to be length-defined, so your input string has to be length-defined too. You should avoid strings (in the FPGA) when you want to handle them efficiently - use U8 arrays instead!

- When using length-defined U8 arrays you should use a fixed point in your U8 arrayy too. It greatly simplifies the parsing process.

- When doing math involving divide operations you should use FPX datatypes in the FPGA: don't use U32 to store the power of 10 factors! As your result will be a FXP too this way you can even simplify your VI…

- Use Select nodes instead of those case structures in the TRUE case of the outer case structure, they improve the readability of your VI…

- the "-1" operation in both cases belongs outside the case structure…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 15
(3,850 Views)

FPGA targets do not support the data type "string". Because of this, LV FPGA does not provide a string palette.

 

You can, as a workaround, create/maintain/work on arrays of U8 integers, which can be transfered to the host. Once you do this, you can convert these to strings. Please note that the U8 arrays would reflect the ASCII codes of the characters, so in order to 'write' an 'a', the integer has to have the value '97' (or, as usually presented in hex: '0x61').

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 3 of 15
(3,846 Views)

Thank you for your responses.

 

Yes, I'm agree with you. But this code at first I'm testing in my PC. Then I'll change this string data to memory in FPGA. I'll read U8 data from Memory then convert it to Number, will do some operations with it then return to U8 Array and write in memory the new value.

Why I'm using U8 Array and fixed-point or U32, because I've a display which shows data in U8 Array.

0 Kudos
Message 4 of 15
(3,832 Views)

Hayk wrote:  Then I'll change this string data to memory in FPGA. I'll read U8 data from Memory then convert it to Number, will do some operations with it then return to U8 Array and write in memory the new value.

I recommend you just store your raw numbers in the memory.  It will work a lot better for you.  In short, you should avoid these conversions.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 15
(3,822 Views)

Yes, but then I should change raw numbers to U8 Arrays to show in display.

For example I have -18.869 in fixed point, I can change it to boolean array then to U32 and save that in memory, but Then I need to read it and convert to {-, 1, 8, ., 8, 6, 9} in ASCII.

 

Thank you.

0 Kudos
Message 6 of 15
(3,819 Views)

@Hayk wrote:

Yes, but then I should change raw numbers to U8 Arrays to show in display.

For example I have -18.869 in fixed point, I can change it to boolean array then to U32 and save that in memory, but Then I need to read it and convert to {-, 1, 8, ., 8, 6, 9} in ASCII.


Why can't you just display an array of your fixed point numbers?  That would eliminate all of this mess.

 

And why do you need a boolean array?  You could just use Type Cast to go straight to the U32.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 7 of 15
(3,816 Views)

Because display has its requirements, which is receiving only U8 chars.

 

Thank you.

0 Kudos
Message 8 of 15
(3,800 Views)

Hi Hayk,

 

your display will surely not need the speed of the FPGA, so just do the conversion in the RT host!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 15
(3,796 Views)

Yes, u'r right but I don't want to send data to host then again to FPGA, I've a lot of place in FPGA, and want to do all conversations there. If there is no any solution then I'll send it to host, but it isn't good for my project.

 

Thank you.

0 Kudos
Message 10 of 15
(3,786 Views)