LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial communication with thermometer

Hi, I am trying to communicate via serial with a thermometer. After building my VI (attached) I always have this error which I do not know where it comes from:

Captura1.JPG

It shows up here:

Captura.JPG

It is strange that it only happens with the Read, while Write is ok. I will be very grateful if anyone can help. After spending a lot of time on it I am blocked.

Thanks.

0 Kudos
Message 1 of 34
(3,024 Views)

The error for the VISA Read you are showing is actually a Timeout error.  That just means that your device is not echoing the 8 bytes you sent and/or it is taking more than 10 seconds to get a response from it.

 

Generally speaking, you should not be forking the VISA Reference wire.  If you expect the read to be after the write, then wire the reference from the write to the read.


GCentral
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 34
(3,012 Views)

Another problem.

 

You need to do a block diagram cleanup.  It is hard to tell which wires are running where because they are hidden behind the icons.

 

It looks like you have written the output of "Bytes Written" in the Write, to the "Bytes to Read" of the read.  Why?

 

The length of the response almost never has anything to do with the length of the command written.

 

Read your manual so you know how many bytes you need to read.

 

Also, your picture of your error message dialog is a for a completely different error of an invalid reference as compared to the timeout error showing in the highlight execution of the block diagram. That would be a completely different problem causing that error message.

0 Kudos
Message 3 of 34
(3,004 Views)

Are you trying to write a command to the thermometer and then read back the response?  You need to properly sequence the read and write commands, not try to do them in parallel.

 

As others mentioned, your code needs some work in some areas.  I'll point out you don't need the sequence structures, perhaps just a short delay between your write command and your read command.  Your code could be simplified to something like this.

 

Thermometer_4_channels_CDS.png

 

Craig

0 Kudos
Message 4 of 34
(2,966 Views)

Well, one major correction to cstorey's snippet...The data appears to being using a binary/hex/raw data format.  So we need to throw anything ASCII related out the window.  The first thing is the Enable Termination needs to be set to FALSE (0x0A could be in the data and you terminate early OR you will get a timeout error).  Because we are turning off the termination character, we need to know the data protocol before we can progress any further (varying number of bytes in a message?  need to make sure we parse the right message, etc).


GCentral
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 5 of 34
(2,923 Views)

Thanks to everyone for your inputs. I can only open Labview 2018 files or earlier, but I have made the code from cstorey (see attachment) and I still have errors:

Error.JPG

I attach the manual where the code is in the first pages if this helps. I guess the VISA configuration is ok. I am trying to send the code to read T1, and it seems that there is no error there, but the timeout error occurs when I am trying to extract T1 from the 8 bytes code.

Download All
0 Kudos
Message 6 of 34
(2,916 Views)

I'm not seeing anything in that manual that remotely resembles the command you are trying to send it.  Does the device just spit out the data every so often?  Or maybe you need to use the "W" command to tell it to perform a read?  Might be worth trying to get a hold of the manufacturer and see if they can clear up the protocol for you (it seems overly complicated).


GCentral
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 7 of 34
(2,903 Views)

😉 Yup as crossrulz said I didn't set up communication properly.  How could I you didn't post any details.  But I left it the same as in your code, and just showed the options you were likely going to need to play with.

 

Page 2 of the documentation you posted points out more details about communication protocol.  Serial settings - 19200,N,8,1 (These match the VISA Config Serial Port defaults, but you need to disable the termination character.)

 

Then you need to change max read bytes from 256 to 8 bytes of data to PC. 

 

Edit: Read command is not obvious.  Looks like you send A, then R??  R is more than 8 bytes though.  I'm not understanding that manual well.

 

Try that and see what you get.

Craig

0 Kudos
Message 8 of 34
(2,902 Views)

Hi again, I have finally set the connection, but communication is in 12 bytes instead of 8 bytes that indicates the manual. By reading 48 bytes (12 bytes per temperature input) I can extract the temperatures I am looking for by processing the 48 bytes string. However, the temperature values (T1, T2, T3 and T4) appear disorganised, which makes difficult to asign the corresponding values.   

capture.png

The byte that indicates which Tx is, is the next one to 02, being 10 or 00=T1, 11 or 01=T2, 12 or 02=T3, and 13 or 03=T4. I have tried to extract the byte that indicates the corresponding Tx in order to set it as entry value in a case structure, but I think the case does not recognise the string I indicate and thus do not change it (this is what I understand). The current VI attached is only configured for the case to associate the TA value to the corresponding Tx, and TB to the corresponding Tx. The others (TC and TD) are not implemented yet.

Any feedback?

0 Kudos
Message 9 of 34
(2,837 Views)

I am guessing you are sending Q command which is to read manually recorded data

If that is the case, you should expect 25 bytes total in response.

It is always 0x02 as the first byte and 0x03 as the last byte.

The second bytes is the number of records which should be 0x04

The temperatures are byte 20, byte 21, byte 22, byte 23 where byte 0 is 0x02.

 

.

0 Kudos
Message 10 of 34
(2,827 Views)