Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Capturing ascii RS232 code from external device

 
0 Kudos
Message 1 of 5
(3,987 Views)
HI all,

I have connected an external light meter to my PC via a RS232->USB converter and have written code to obtain results from the meter.
This works about 75% of the time.

The code performs the following.
1) Open VISA session.
2) Reads in 32 bytes using #$0D as terminator char
3) Closes VISA session.

The meter continually sends data.  Start byte is #$02, end byte is #$0D, all other bytes are ascii.
Problem is, my code does not always 'grab' the bytes.

Can someone show me a working example of code that succeeds in capturing streaming data ?

Thanks,
Bob.
0 Kudos
Message 2 of 5
(3,985 Views)


@Mad_Bob wrote:
[...]
The meter continually sends data.  Start byte is #$02, end byte is #$0D, all other bytes are ascii.
Problem is, my code does not always 'grab' the bytes.
[...]


Open VISA serial port once at the beginning of your program and set the termination character to x0D and the timeout say twice the sending rate of your meter.

In a (while) loop read the data with one serial read and ignore the first string read since you will sometimes start your open VISA during a data transmission. If the meter always send the same amount of data, you can use the bytes read value to check your data.

After you terminate your loop (stop button)  close the VISA port


 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 3 of 5
(3,972 Views)
Hi Henrik,

Thanks for the information.
I now have 100% working code.

Thanks !!  I owe you a weissbier.  🙂

Br,
Bob.
0 Kudos
Message 4 of 5
(3,963 Views)
A good rating will help until I get my liquid bread Smiley Very Happy
Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 5 of 5
(3,957 Views)