// released under the GNU GENERAL PUBLIC LICENSE (GPL)
// refer to http://www.gnu.org/licenses/gpl.txt

// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

// note that not all applications need to disable interrupts when
// performing onewire transactions. but, if unmasked interrupts
// cause onewire timing violations, returned data will be suspect
// or there may be other, hard-to-reproduce problems.

Last edited by jds-pic on Sun Jan 23, 2011 5:47 pm; edited 1 time in total

jds-pic

Joined: 17 Sep 2003Posts: 205

Posted: Sat Jun 12, 2004 7:13 am

someone asked me for example code...

for temperature measurements WITH A SINGLE PERMANENTLY ATTACHED DS1822 onewire device...
in your main() or other calling function:

Code:

int temperature;

if (int onewire_init_with_error_check()) {
// set the number of bits of resolution on the ds1822.
// note that this affects the conversion time,
// RTFM and see the called function.
onewire_ds1822_set_temperature_resolution(9);

// read the temperature from the ds1822.
// note that the returned value is in deg C,
// and the "lite" function returns only positive temps.
temperature = onewire_ds1822_read_temp_c_lite();
}
else
printf("onewire device not found");

here's a little snippet that shows how to get the 48bit unique serial number from the DS1822...

Why is there 120us delay in readybyte function ?
The read-time slots is minimum 60us + minimum 1us recovery time between slots, so 80us is enough. I am using 66us read-time slots. You should take samples between 15us and 30us. I am getting sample in 18us.

Hi there. Using 16f684 and pin_c2 with internal 8MHz osc, i try to make it work. I don't have lcd on it, it's a very simple circuit. Generally working. I have 3 leds for debugging.
Anyway i can't get temperature reading. I can see that i get no pulses to pin_c2 (with oscilloscope). When i use #use FIXED_IO( C_outputs=PIN_C2) then i do see pulses coming periodically, however it's still not reading anything but 0.
Running this at main once, i can see ledr going low: