Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

visa, Data mismatch

Good afternoon.

Im really new in comunications so I will apricate your help.

I have a Vi that sends and recieve data, so it is a constantly changing state machine that changes from "transmit" and "recieve".

This vi Controls  and reads a ptrototype Im working with ardouino.  So i if a button is pressed it will send a  byte to arduino and arduino will interprete it. 
After that arduino should be sending  12 bytes. the i make string subsets to devide them in 4 packages of 3  bytes each and  graph them. Each package is a position of my prototype.

The problem is that I dont get the 12 bytes I need. For example I get 6 bytes from the old transmition and 6 of the new,  or 3 from the last and 9 form the new etc.

I tried to put an identifier character, and read  the buffer. If the first byte is my identifier byte then divide and graph my data.
This solves the problem but is still sloppy and unpractical because a lot of data i getting lost , also the graph is not as smooth as it should be.

My first hypotesis is that  arduino is sending to quickly the data, becouse i made a program that just sends 12 bytes  with a delay of 100ms and it was fine. I cant put a delay in arduino because it will mess the prototype. 

My second hypotesis was that i was flushing the buffer the wrong way, I flush it in the transmit state.

Any suggestion? 

I heard about putting an identifier to the transmition so it will start reading from the desire byte. What dou you think? 
Thank you 

 

 

0 Kudos
Message 1 of 3
(4,066 Views)

Hi

Don't flush in sending or receiving except the first time after opening.

The serial communication is on two wires independently sending and receiving at least on the pc side.

Just write a byte and read later the complete message then write again.

 

greetings from the Netherlands
Message 2 of 3
(4,057 Views)

Thank you very much. 
The real problem was I didnt put a Temintion Character. Once I put one, it syncronize the correct way.  But i will take your advise also. 

Greetings from Mexico!


0 Kudos
Message 3 of 3
(4,040 Views)