LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Arduino and Dallas DS1820 (one-wire)

Solved!
Go to solution

I'm able to get simple blinking LED examples to work with the default firmware however, I am using the modified firmware that includes the onewire and dallastemperature libraries, which when used with the VI posted by ricky973 in post 139, I keep getting error 5002. This error 5002, seen when using highlight execution always starts after the init.vi block, I have done everything recommended by NI to try to fix the error but it just doesn't seem to comply unless I press the reset button on the arduino while the VI is running then the program runs properly. However, I still get a zero reading when the signal approaches the sub VI which gives me the same error 5002.

0 Kudos
Message 151 of 172
(2,757 Views)

The one major issue that I see is that you are running an infinite loop.  This means that you are required to abort the program using the abort button (the little red stop sign).  You should NEVER use the abort button if at all possible.  You should use a stop button that is wired to your while loop.

When you use the abort button, it terminates the program immediately and no further code is executed.  This means that the Close.vi is never executed which is required when you are working with Arduino.  If you do have to use the abort button, you will need to manually run Close.vi by opening it and selecting the appropriate COM port on the front panel (VISA Resource) and then running it.  This is because the VISA resource was never release so subsequent attempts to access it will fail because the computer thinks it is in-use.

Another thing to note is that all Arduino digital pins default to inputs.  So, if you want to write to them, you need to change their mode to be outputs.  The only exception is when you are trying to set the input pullup resistor where you actually do write to the pin while it is in input mode.

One last thing that I think you are being confused about is that when an error occurs in the Init.vi, none of the other error-wire-connected Arduino VI's will run.  So, if there is an error in the Init.vi then the subsequent VIs will not actually run (or one of the Arduino subVIs will not run).  This will result in zeros as outputs.

So, once you have fixed your code based on the above notes, try again.  If you are still having issues with the temperature sensors, please post the new versions of your VIs.

0 Kudos
Message 152 of 172
(2,757 Views)

I've added the stop button to the while loop and set the digital pins to output. The VI runs now but I'm still get 0 from the read buffer from the send recieve block of the subVI resulting in still a zero reading. The only error 5003 that I get now is from the error output of the subVI send recieve block.

Download All
0 Kudos
Message 153 of 172
(2,757 Views)

I'm not sure if I have placed the stop button on the VI properly because it does not terminate the program when I press it on the front panel. I'm wondering why the read buffer of the send recieve block in the SubVI outputs zero when the input of the send recieve block is receiving a non zero signal.

0 Kudos
Message 154 of 172
(2,757 Views)

You will always receive a value of zero if there is an error communicating with the Arduino.  So, because you are still getting an error, it is expected that the value will be zero.  You need to get the error fixed before you get any usable values.

If the error is occuring in the DS1820 Get Temp.vi then there is either something wrong with the VI itself (the only thing that can be wrong is if the values provided to the Send Receive VI are wrong) or there is something wrong with the firmware.

Update:

I took a little more time to look at the firmware and I notice that the firmware is designed only for a single sensor and that it is sending a floating point value back as ascii text.  This does not work with the "DS1820 Get Temp.vi" that you have posted.  I think that you have maybe got the wrong firmware (one that does not correspond to the VI that you have).  Or, you have the wrong VI.

So, I recommend that you go back and see if you can find the patching pair (firmware and VI) of the multiple sensor version.

P.S.  The stop button is implemented correctly and will stop the loop.

0 Kudos
Message 155 of 172
(2,757 Views)

I've uploaded the proper firmware with the addresses for three temperature sensors. Everything runs and I get readings now, no more error 5003, but the temperature readings are all the same (-32526) and they don't change even though I only have one sensor plugged in. Also, the stop button isn't working, I click it in the middle of a run and the program doesn't terminate.

0 Kudos
Message 156 of 172
(2,757 Views)

Because I can't test with the actual sensor, I can't really help much further.

I'm not sure what your issue is regarding the stop button.  The only thing that I can think of is that if you are running with hightlight execution enabled, you will have to wait significantly longer before the loop actually stops (but it will stop eventually).  Make sure that you have highlight execution disabled if you want to see the loop stop more "interactively".

0 Kudos
Message 157 of 172
(2,757 Views)

Thank you for the help Nathan. I must admit, this simple process of using one wire to read the DS18B20 sensor that can be done on the Arduino IDE quite easily is getting to be quite complicated to accomplish on Labview.

I've continued with my efforts to get this to work. I've removed the PWM control loop for the dc motor in order to simplify things and the current reading that I get now is -127.

0 Kudos
Message 158 of 172
(2,757 Views)

It is my projeck for now.

Download All
0 Kudos
Message 159 of 172
(2,757 Views)

At the request of cosuroca on the LINX forum https://www.labviewmakerhub.com/forums/viewtopic.php?f=12&t=479&p=2950#p2950

I hereby post my LIFA code I developed about a year ago, heavily based on the discussion here (mainly posts 60-80 in this topic, and similar to the get_temp. vi). It uses the Wire library, not the Dallas library.

Two custom cases 0x35 0x36 are defined in this example (Readout of a single - 0x35: the first or 0x36:second- Dallas temperature sensor found on the bus, adresses not hardcoded).

2 files are added in attachement:

The labview VI and a zip file with firmware code.

Feel free to ask for clarification if something is unclear.

Download All
0 Kudos
Message 160 of 172
(2,757 Views)