Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

How to start serial communication?

Hi ! This issue has been up so many times, but as a newbie I can´t fully relate earlier threads to my problem!

It is pretty basic I guess;

I would like to send some data seriel to a PC using labview. The labview interface should consist of 8 different fields where I can display my "read" data. So there must be some kind of function for separating the datastream coming in in high speed. Also, sending data back to the microcontroll from the interface in labview, not with so much dataspeed requirements.

I will be sending the 16-bits of data from a microcontroller in 2 8-bit pieces to one text field, then 2 more 8-bit pieces to next field etc. until I have done 8 fields. I will be receiving data on a USB unit but the computer looks at this one as a COM port, so I guess serial comm. is the way to go??

So I am wondering; can this be done using something like bytecounter or something? How about little and big endian?
Any examples in labview that one can look at? Do I have to write DLL´s?? Is it okay to send it binary in 2 complements form?? Many questions...

Greatly appreciate any advice and how to start this little project. I need this fairly quickly for displaying my values and verifying it. The only way I have been displaying this data so far is in a terminal program and it comes out right but with a printf function which is way to slow.

Many kind regards
B
0 Kudos
Message 1 of 2
(2,925 Views)
Beagle,

your Qs are quite unspecific. So my answers will be similar. Here it goes:
> ... the datastream coming in in high speed ...
What does this mean? LabVIEW and VISa can handle baud rates with up to 230 kbaud or even more. These high baud rates are not too easy to handle in the pure cabling point of view. I mean, you need short cables of good quality.
230 kbaud results in about 23kB/s or 0,68ms for your 16 bytes to receive.

I just imagined you might need a more basic explanation of what happens when LabVIEW does serial communication.
Serial comm in LV is basically a call to the VISA API that provides - amoung others - an API to some drivers. Fianlly the kernel driver has to run as an interrupt service, which can not be done with LabVIEW directly, at least on a PC running a 'normal' OS like Windows or Linux or so.
The direct serial comm is done on a chip called UART, which has some buffer for the communication data. When this buffer fills up or runs empty, depending on the communication direction, it sets an interrupt. This causes the kernel driver to copy the received data to a buffer in the RAM of the computer or to fill up the UART buffer with new data to be transferred. Afterwards the drived notifies VISA which can use the received data if necessary.

So long words meaning, You do not have to care about the comm speed as long as the UART in your machine and the VISA version you are using does support the required speed.

> So I am wondering; can this be done using something like bytecounter or something? How about little and big endian?
I would write your commands to the serial port, than wait a period until your µC will have sent its results and than enter a while loop:
While (16 bytes_at_serial_port OR 100 times tried) Do Wait 1 ms WhEnd
Read bytes_at_serial_port Bytes; String_to_Byte_array; Cut the byte array into your fields; exchange the byte order if necessary; create an error if less than 16 bytes have been received.

> Is it okay to send it binary in 2 complements form??
Yes, but your LV program must handle your data.

You may want to search some serial examples. Look at /Help/Find_examples in your LV.

Hope this helps.
Greetings from Germany!
--
Uwe
0 Kudos
Message 2 of 2
(2,910 Views)