LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial communication with thermometer

1. Again, what you are showing does not reflect the manual you gave us.  Are you sure you have the right manual?

2. Do NOT use Local Variables here.  They do nothing but add confusion and race conditions.  Use wires!

3. You have an infinite loop.  Stop using the Abort button in the toolbar to stop your VIs.  Initialize you port before the loop, close it after the loop, and use a stop control to stop your loop gracefully.

4.  I would do something like this.  The idea is to store you temperatures in an array and you just update the value you just received.  Notice I reduced the read size to only cover one temperature at a time.  But the powerful part is the Unflatten From String to parse the message for me.  The cluster contains an U8 for the Start Byte, U8 for the Channel, a U16 for I don't know what they are for, and finally a U16 for the data.  After that, it is just doing the math you already defined for the data and using the case structure to decide which element in the array I am replacing.


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
Download All
Message 11 of 34
(1,223 Views)

Hi again,

 

Yes, the manual seems to be wrong. The instrument is the RS PRO 1384 Temperature Data Logger:

https://uk.rs-online.com/web/p/data-loggers/1232235/

You can click on the user guide of its website and you will get the manual.

 

I will probably change the local variables to wires and insert the Stop button at a later stage, thanks for the advice.

 

Your point 4 looks nice, but since I am a beginner user of Labview, it is somewhat far from my current knowledge. Instead of that I found an alternative as shown in the attachment which now works.

 

However, I frequently find this error:

capture.png

I think it might be related with the COM port getting blocked, maybe closing/opening issue. I have now put the open and close out of the loop but this error occurs again. Any idea about the reason?

0 Kudos
Message 12 of 34
(1,188 Views)

@garciaj wrote:

Your point 4 looks nice, but since I am a beginner user of Labview, it is somewhat far from my current knowledge. Instead of that I found an alternative as shown in the attachment which now works.


That is why I gave you code so you could study it.  That is how you expand your knowledge.

 

As far as your writing to the file, do not use the Write Delimited Spreadsheet function here.  It opens and closes your file with each iteration.  This will kill any performance you might have.  Use the Open/Create/Replace File function before you loop to create the log file.  Inside the loop, use Array To Spreadsheet String to format your data and then Write Text File to save the data to your file.  Then use Close File after the loop.  For logging inside of the same loop, this will give you the best performance.  If you need more performance, then you will need to use a Producer/Consumer setup to move your logging to another loop.


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 13 of 34
(1,178 Views)

Get rid of the local variables.  There is no reason to write a value to a terminal and the local variable of the same terminal at the same time!

 

If you do occasionally get the timeout error, then put some other indicators on there to help debug it.  For instance, you ask for 48 bytes, but if you get less than that, you'll get a timeout error.  When you get a timeout error, how many bytes did you actually receive?  Put an indicator on that string to look at the message.

 

And definitely get rid of those other local variables and replace with wires.  Be sure to get that done right away and before you post any updated version of your code to this thread.

0 Kudos
Message 14 of 34
(1,161 Views)

Did you manage to write your VI successfully?

0 Kudos
Message 15 of 34
(1,054 Views)

I think we stopped working with this apparatus since we bought another model. So we did not advance the code.

0 Kudos
Message 16 of 34
(1,055 Views)

@crossrulz wrote:

1. Again, what you are showing does not reflect the manual you gave us.  Are you sure you have the right manual?

2. Do NOT use Local Variables here.  They do nothing but add confusion and race conditions.  Use wires!

3. You have an infinite loop.  Stop using the Abort button in the toolbar to stop your VIs.  Initialize you port before the loop, close it after the loop, and use a stop control to stop your loop gracefully.

4.  I would do something like this.  The idea is to store you temperatures in an array and you just update the value you just received.  Notice I reduced the read size to only cover one temperature at a time.  But the powerful part is the Unflatten From String to parse the message for me.  The cluster contains an U8 for the Start Byte, U8 for the Channel, a U16 for I don't know what they are for, and finally a U16 for the data.  After that, it is just doing the math you already defined for the data and using the case structure to decide which element in the array I am replacing.



Hi, I am a very new user to LabVIEW and would like to ask about this VI. It seems like you intended to convert from the Fahrenheit output to Celsius, but when I run the VI the front panel temp shows a value in the thousands. Adding a probe to the data wire shows the correct Deg F temperature. But there is some error happening when converting. Even removing the conversion operation results in an incorrect reading on the front panel. 

 

Would you have a solution for this? 

0 Kudos
Message 17 of 34
(887 Views)

Hi JD,

 


@JDSuper wrote:
Hi, I am a very new user to LabVIEW and would like to ask about this VI. It seems like you intended to convert from the Fahrenheit output to Celsius, but when I run the VI the front panel temp shows a value in the thousands. Adding a probe to the data wire shows the correct Deg F temperature. But there is some error happening when converting. Even removing the conversion operation results in an incorrect reading on the front panel. 

 

Would you have a solution for this? 


We probably would come with a solution rather quickly - as soon as you attach your VI!

(When you are using one of the latest LabVIEW versions, like LV2022 or above, then I would recommend to downconvert to LV2021 or LV2019 to get a broader audience…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 18 of 34
(877 Views)

@JDSuper wrote:
Hi, I am a very new user to LabVIEW and would like to ask about this VI. It seems like you intended to convert from the Fahrenheit output to Celsius, but when I run the VI the front panel temp shows a value in the thousands. Adding a probe to the data wire shows the correct Deg F temperature. 

Are you talking about the blue wire coming out of the "data" unbundle node or the raw string received from the instrument?

 

How does the raw string look like? Do you have documentation? Are you sure the unflatten operation uses the correct datatypes?

 

Please attach a simple VI containing a typical sample of the received string verbatim as diagram constant (*see below) and tell us what temperature you are expecting to see.

 

*(i.e. create an indicator on the pink wire, run the VI, stop the VI, right-click the new indicator and "change to constant", save the VI under a new name and attach it here)

Message 19 of 34
(869 Views)

Hi Crossrulz, Mr.Altenbach, Gerdw

Can one of you please explain to me the 1,11 / 2,12/ etc... part of the case structure? I just want to expand my knowledge. 

GRCK5000_0-1679706369374.png

2nd question) Does the case structure's radix should always be changed based on the type of data being read?

GRCK5000_1-1679706544310.png

 

I look forward to hearing from anyone who understands this.

0 Kudos
Message 20 of 34
(856 Views)