Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Sending out in decimal, reading in hex

Hi, I'm quite a newbie with LabVIEW 11. I have a board a 20 year electrical engineer designed for me to learn LabVIEW with. What I'm trying to do is to create a VI that can send decimal commands to the board and display them in hex. Using Realterm, I can send them out in decimal and I get a response back as expected.

 

For example if I type:

 

170 85 0 8 0 1 0 0 0 0 0 9

 

I get

 

AA55000800008000A0510179 - which reads the version

 

I've been messing with the examples in labview on serial write and read, and according to my oscilloscope it's sending out, but not receiving (probably due to invalid commands being sent out). I just want to be able to send out commands in decimal and read the results. How hard is this going to be for me?

0 Kudos
Message 1 of 47
(4,846 Views)

Can you show us what you have tried?  How are you putting data in (string control, byte array, etc.)?  How are you converting the data to send out the port?  Are you sure you have all of the serial port settings setup correctly (baud rate, bits/word, start and stop bits, etc)?


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 2 of 47
(4,839 Views)

I figured out my error, I was sending out the wrong data.

I modified the example program, and had it send in hex and read in hex and it read back in Labview. It read the version number as it's supposed to.

0 Kudos
Message 3 of 47
(4,836 Views)

Now that I know Labview can send and receive for my board, I need to setup an easier/quicker way to send commands. I was thinking to use an array to build the command. I want to have 5 drop down boxes to select different choices for building the command.

 

My pseudocode for building the array

 

1. Begin with the header which is always constant (elements 0-1)

2. Loop through the data portion of the command (elements 4-?)

3. Calculate the size based on amount of data (elements 2-3)

4. Calculate checksum based on values of data and size (last two elements of the array)

 

I'm coming from more of a text-based programming side and Labview is completely wacky to me at this stage. I've been reading what I can, and also have some books on the way.

0 Kudos
Message 4 of 47
(4,825 Views)

So I would need to take the elements of the array and concatenate them all into a string for the VISA write function to accept. Is this correct?

0 Kudos
Message 5 of 47
(4,823 Views)

Demetri90,

 

Go to the String>Conversion pallette and look for a function called 'Byte Array to String'.  Easier and cleaner than the concatenate.

0 Kudos
Message 6 of 47
(4,813 Views)

@Wayne.C wrote:

Demetri90,

 

Go to the String>Conversion pallette and look for a function called 'Byte Array to String'.  Easier and cleaner than the concatenate.


Thank you for that. My next bit of work is to calculate the size of the data portion. Basically what I've been told is to loop through the array, and use an index to calculate the size. For example, AA 55 00 08 00 01 00 00 00 00 00 09 (00 being the high byte, and 08 being the low byte). It would start at 00 and end at 09, total of 8 elements. How could I do this in Labview?

0 Kudos
Message 7 of 47
(4,804 Views)

Index out the two elements, use the join numbers function (this will give you a U16), and then convert into an I32.  Or if you already have the data array figured out, use the array size.


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 8 of 47
(4,800 Views)

@crossrulz wrote:

Index out the two elements, use the join numbers function (this will give you a U16), and then convert into an I32.  Or if you already have the data array figured out, use the array size.



I'm not sure what you mean by index out the two elements.

0 Kudos
Message 9 of 47
(4,792 Views)

Use the index array to get the two elements you need to get the data size.  I then used array subset to get the data based on the length.

 


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 10 of 47
(4,787 Views)