Thanks for the mods and comments.
The instrument can be connected by RS232 or USB. The USB connection creates a virtual Com port, so I thought it was equivalent?
I placed the "close visa" inside the loop because I get a buffer overrun else. But it's logical that this takes time
😕 About the transmission format... As far as I see it I only need 4 bytes per transmitted set of data.
I copy a part from the instrument handbook here:
"
8.3 Data telegram format
The CHRocodile E supports RS232 with extended Data rate (921600/sec)
and USB Full speed (12MBit/sec) interface.
The interface does not use hardware or software handshake. The computer
must therefore be able to receive the incoming data flow at any time in order
to correctly receive the acquired data. The possible Baud rate ranges from
9600/sec to 921600/sec, but the highest possible Baud rate should be
preferred in order to be able to use the high measuring rate of up to 4 kHz
which is provided by the CHRocodile E.
The Baud rate is set via the keyboard ([F4] > [F3]…: serial port baud rate).
During normal operation the CHRocodile E continuously sends data
telegrams. The telegram rate is determined by the CCD-Scan rate divided by
the selected average number.
The telegram consists of up to 16 data words, each 16 bits wide. These
words can be transmitted either as numbers represented in ASCII characters
or binary as 2 bytes with the MSB transmitted first.
(...)
ASCII mode
data 0,data 1,....,data N CR/LF
The enabled data words (selected by $SOD command) are output in ASCII
representation, each 5 characters long, ranging from 00000 to 65535,
separated by commas.
The telegram is concluded with carriage return / linefeed.
It should be noted that the ASCII mode does not enable the transmission of
the results at the full measuring speed of 4 kHz due to the inefficiency of the
coding. For high speed data transfer, the binary mode must be used.
Binary mode
Telegram format: (the values between the <> signs mean one transmitted
byte. The prefix 0x indicates hexadecimal notation.)
<SSByte1>,<SSByte2>,<data 0 MSB>,<data 0 LSB>,...,<data N MSB>,<data N LSB>
Each telegram consists of the selected data words, high byte first, and
begins with the synchronisation sequence SSByte1, SSByte2.
This sequence is equal to 0xFF, 0xFF after power up, but it can be changed
by $SSQ-command.
It must be noted that it is not sufficient to wait simply for the occurrence of
this synchronisation sequence since it can occur also in the binary data
stream (like the stop and start bit in continuous serial transmission can be
ambiguous). It is intended that this sequence is used only to synchronise the
entire data flow, not a single telegram. Since the length of the telegram is
known, a transmission once synchronised will stay synchronous and the
synchronisation sequence is only used to prove the state of
synchronisationThere are two ways to achieve synchronisation:
• stop the data flow by sending a command. After completion of the
command the sequence ”ready CR/LF” will be sent and the CHRocodile E
starts with a new telegram.
• when you don’t receive the synchronisation sequence at the expected
place, wait for the synchronisation sequence. This will synchronise the
data flow in a few cycles since the transmitted data words are usually
changing.
Be careful that the chosen combination of Baud rate, Sample rate, Average,
Data format and selected output data permits full telegrams to be sent.
You should calculate 10/Baud rate+1 μsec per byte sent.
Example
This permits for example
1/1000Hz /(10/115200Bd+0.000 001sec) =11,39 ≈ 10 bytes = 2Bytes (synchronisation
sequence) + 4*2 Bytes (Data)
to be transmitted at 1 kHz Data rate in binary mode.
"
For example one transmitted set of data is (decimal notation) "255 255 077 184".