Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial communication with data acquisition device issue

Hello everyone,

 

I am using a DATAQ DI-145 data acquisition device to obtain values that will correspond to voltage amplitude. I have a working code for such using ActiveX controls, however it is a bit slow and dependent on externally provided software, so I am experimenting with serial communication. I read the (attached) device's protocol, and I installed visa drivers for the instrument to communicate in LV. Reading around, I created this code (attached sniplet), however neither the read nor write options seem to properly work. There is a series of basic commands in the protocol, out of which I also get no response (and occasionally the VISA timeout error). The same happens when I try the VISA test interface in MAX (for some reason i also get more ports than the instruments i have in). 

 

Specifically, I quote from the protocol: '' Responses to this set of commands include echoing the command, followed by a space (0x20),
followed by the response, and ending with a carriage return (0x0d). For example, the command "info 1" generates the following response ''info 1 1450(0x0D)'' . Does this mean I need a carriage return termination character to be enabled on read/write? I fiddled with both timeout (2s,10s) and termination character enable/disable in test panel and not much seems to change when trying to send info\s0 sommands etc.

I'm very new to serial communication so I might be missing something obvious (for example, why are transmit and receive buffers on 0? what does it mean?) or doing something wrong. Would appreciate some guidance.

 

Finally, since I am trying to avoid using the visa property bytes at port, does me setting a bytes to be read control make me miss any of the continuous stream? And is the empty string and feedback node sufficient to distinguish between different measurements?

 

Nafsika

0 Kudos
Message 1 of 5
(3,254 Views)

1. You need to set your termination character to be a Carriage Return (\r, 0xD, 13).

2. I recommend using the Send Termination Character Enable.  This will have VISA add the CR for you whenever you do a write.

3. Since the termination character is used (End Read on Termination Character was set to TRUE), just set the Bytes To Read to something really high.  Something like 100 should be more than enough.  The idea is that the VISA Read will stop reading when it reads the termination character, reads the number of bytes it was told, or a timeout happens, whichever happens first.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 5
(3,242 Views)

Hi Crossrulz, thank you for your response. I followed your recommendation, I think I implemented the changes correctly (attached)serialTestModified1.png

 

I assumed that using the TermCharEnable safely removes the case structure since it auto adds CR when writing-thus stopping it).

I set bytes to read to 100 and enabled termination character in FP.

This is what I get in Visa test panel with modified settings:

SettingsModified1.pnginfo1Modifiedsettings1.png

On read operations, it either gives me 'command not found' or \n\r

In Labview, when enabling read and enabling termchar, it times-out, and when enabling write with the same termchar it gives 6 bytes and continues running till manually stopped.

Am I issuing the wrong commands? it is supposed to be the initial handshake according to protocol, and I assumed the responses should be the same as if a hyperterminal was used.

 

Nafsika

 

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

You need sto stay with VISA test panel until you get it working properly then you can go back to LabVIEW.

Do not bounce back and forth.

 

Your VISA test panel is set to terminate reads and writes on 0x13. Is that what you want?

 

You should read the manual!

0 Kudos
Message 4 of 5
(3,190 Views)

@Nafsika wrote:

SettingsModified1.pnginfo1Modifiedsettings1.png

 


Note that during your Write that it did not apply the termination character as it only had 6 characters.  As such, it has no idea what you are trying to read.  Try placing a "\r" or "\n" or both as a suffix to your command.

Help the Community (and future reviewers) by marking posts as follows:
If it helped - KUDOS
If it answers the issue - SOLUTION
0 Kudos
Message 5 of 5
(3,151 Views)