ni.com checkout is currently experiencing issues.

Support teams are actively working on the resolution.

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

So, I've tried to get this to compile but I've been unsuccessful so far.  One thing that I did notice is that you are not using the same OneWire.h file that Seth used but I even fixed that was still getting "OneWire not declared in this scope" unfortunately.  I don't know enough about classes to be able to dig further without a lot of research.

I'm sorry that I am unable to help.

0 Kudos
Message 31 of 172
(4,637 Views)

ok, now i try to use onewire that Seth used.

The onewire that i have used is the last version.

0 Kudos
Message 32 of 172
(4,637 Views)

Ok Nathan, I've got some progress, I saw this video:

https://www.youtube.com/watch?v=GmOJQb5kFVk

and changed everything as attached files,

sum up:

File Lifa_Base.ino

------------OMISS--------------

// Standard includes.  These should always be included.

#include <Wire.h>

#include <SPI.h>

#include <Servo.h>

#include "LabVIEWInterface.h"

#include "OneWire.h"   <----LOCAL LIBRARY

-------------OMISS--------------

File LABVIEEINTERFACE.ino

----OMISS---------------

#include <Wire.h>

#include <SPI.h>

#include <LiquidCrystal.h>

#include "OneWire.h"

//Includes for IR Remote

#ifndef IRremoteInt_h

#include "IRremoteInt.h"

#endif

#ifndef IRremote_h

#include "IRremote.h"

#endif

----OMISS------------

----OMISS------------

// Variables

OneWire  ds(2);     <----- PIN 2

unsigned int retVal;

int sevenSegmentPins[8];

int currentMode;

unsigned int freq;

unsigned long duration;

int i2cReadTimeouts = 0;

char spiBytesToSend = 0;

char spiBytesSent = 0;

char spiCSPin = 0;

char spiWordSize = 0;

Servo *servos;

byte customChar[8];

LiquidCrystal lcd(0,0,0,0,0,0,0);

unsigned long IRdata;

IRsend irsend;

----OMISS------------

      }

      Serial.write((IRdata>>16) & 0xFF);

      break;

      case 0x35:                 <---MY CASE       

        Serial.print(leggitmp());  <---- MY FUNCTION

      break;  

----OMISS------------

----OMISS--------------

float leggitmp(){

  //returns the temperature from one DS18S20 in DEG Celsius

  byte data[12];

  byte addr[8];

  if ( !ds.search(addr)) {

      //no more sensors on chain, reset search

      ds.reset_search();

      return -1000;

  }

  if ( OneWire::crc8( addr, 7) != addr[7]) {

      Serial.println("CRC is not valid!");

      return -1000;

  }

  if ( addr[0] != 0x10 && addr[0] != 0x28) {

      Serial.print("Device is not recognized");

      return -1000;

  }

  ds.reset();

  ds.select(addr);

  ds.write(0x44,1); // start conversion, with parasite power on at the end

  byte present = ds.reset();

  ds.select(addr);   

  ds.write(0xBE); // Read Scratchpad

 

  for (int i = 0; i < 9; i++) { // we need 9 bytes

    data = ds.read();

  }

 

  ds.reset_search();

 

  byte MSB = data[1];

  byte LSB = data[0];

  float tempRead = ((MSB << 😎 | LSB); //using two's compliment

  float TemperatureSum = tempRead / 16;

 

  return TemperatureSum;

 

}

And when i try the VI in the jpg image dosen't work.

Please if you can help me!

TNK

0 Kudos
Message 33 of 172
(4,637 Views)

Sorri i forgot the file

0 Kudos
Message 34 of 172
(4,637 Views)

That first thing that I notice is that the command number is actually 53 in decimal (0x35 in hex), not 23.

0 Kudos
Message 35 of 172
(4,637 Views)

where ? i see 23 in constant e 35 in the probe!

0 Kudos
Message 36 of 172
(4,637 Views)

The probe shows 35 in decimal when you need 35 in hexadecimal.  So, the probe needs to show 53.  If the constant where you currently have 23 (in the image) is displaying in hexadecimal (which I believe is the case), then you simply need to put 35 there.

0 Kudos
Message 37 of 172
(4,637 Views)

So I was never able to get any of the aforementioned routes to work but I was able to successfuly get LabView Interface for Arduino to receive Dallas OneWire Temperatures. 

No changes are necessary to LVIFA_base or anything, only to LabViewInterface.h. Finally there is an attached image of a test.vi that I did in order to try it. The second step in the stacked sequence is simply a 5 second delay.  Here is how I did it:

---------------LabViewInterface.h file----------------

#include <Wire.h>
#include <SPI.h>
#include <LiquidCrystal.h>
#include <OneWire.h>                    //For use with OneWire devices
#include <DallasTemperature.h>      //For use with Maxim/Dallas DS18B20 or similiar Temperature devices

//Defines for OneWire and Dallas Temperature
#define ONE_WIRE_BUS 2

//Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);

//Pass our oneWire reference to Dalls Temperature
DallasTemperature sensors(&oneWire);

-----------ADD THE FOLLOWING CASE AT THE END--------------

    /*********************************************************************************
    ** OneWire Read
    *********************************************************************************/
    case 0x35:      // OneWire Read
      sensors.begin();
      sensors.requestTemperatures();  //Send the command to get the temepratures
     
      //Get temp in degrees farenheit by index (there are other ways available to do this)
      temp = sensors.getTempFByIndex(0);
     
      Serial.print(temp);
      break;

-------------------------------------------------------------------------------------------------------------------

OneWire Test.jpg

Message 38 of 172
(4,637 Views)

Hi PentairDave,

Would it be possible if you could attach your LIFA_BASE folder? I made the changes you recommended (btw I think your supposed to implement the code in LabVIEWInterface.ino not LabVIEWInterface.h)  but am unable to verify the firmware.

Also which version of DallasTemperatureControlLibrary are you using?

Your help would be much appreciated!

0 Kudos
Message 39 of 172
(4,637 Views)

1cecream,

Here you go. I'm using the DallasTempControl version 3.7.2. I just googled it and then got the first one I could find. Let me know if this works for you.

LIFA_Base.zip

0 Kudos
Message 40 of 172
(4,637 Views)