Pages: [1]   Go Down
Author Topic: removing delay() in DallasTemperature.cpp  (Read 757 times)
0 Members and 1 Guest are viewing this topic.
ca
Offline Offline
Jr. Member
**
Karma: 0
Posts: 63
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

My project require the use of a Dallas temperature sensor and the my program already execute other functions that can not be delayed at all. The Dallas need a 1 second delay everytime a request is made. How DallasTemperature.cpp program can be modified to not use delay() but millis() instead ?

http://milesburton.com/downloads/Arduino/DallasTemperature/DallasTemperature.rar

Code:
// Send command
void DallasTemperature::beginCommunication(void)
{
  pDataWire->reset();
  pDataWire->select(arSlaveAddr);
  pDataWire->write(STARTCONVO,1);         // start conversion, with parasite power on at the end
  delay(1000);
}
« Last Edit: July 26, 2009, 06:47:33 am by sync » Logged

Van Alstyne, TX
Offline Offline
Full Member
***
Karma: 1
Posts: 154
Haven't smoked an Arduino... yet.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You could save the current millis() value and add 1000 (although 750
will be fine) to it after  the StartConversion has been commanded.
Afterwards, the Arduino can continue doing what it needs to do,
periodically checking the value of millis() to see if the delay has
expired, and read the temperature then.   The temperature value
will be retained by the 18x20 until the Arduino has a chance to read it.
Logged

Pages: [1]   Go Up
Jump to: