07-06-2012 11:35 AM
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?
07-06-2012 12:02 PM
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)?
07-06-2012 12:26 PM
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.
07-06-2012 02:39 PM
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.
07-06-2012 03:00 PM
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?
07-09-2012 06:55 AM
Demetri90,
Go to the String>Conversion pallette and look for a function called 'Byte Array to String'. Easier and cleaner than the concatenate.
07-09-2012 10:12 AM
@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?
07-09-2012 10:42 AM - edited 07-09-2012 10:44 AM
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.
07-09-2012 10:57 AM
@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.
07-09-2012 11:12 AM - edited 07-09-2012 11:14 AM
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.