04-20-2006 12:10 PM
04-20-2006 04:54 PM
04-20-2006 07:42 PM
04-20-2006 10:55 PM
04-22-2006 02:05 PM
04-22-2006 02:32 PM
04-22-2006 05:57 PM
Hi Brian,
Actually I have a revised snippet of code that should allow you to read from the DS1920. Sorry, I don't have a DS1920 to confirm that the code is correct, but I took it from the sample file time.c in the SDK source directory. Since I wrote my originally posted code to work with the DS1994, you should take that project and drop time04.h from the iButton include files. Then replace it with temp10.h. Also, you will need to add ioutil.c and temp10.c to the iButton source files for the subsequent code snippet to compile properly. You were right about the OWTRNU.c file. The JPEG compression made it look like OWTMU.c. So give this a whirl:
---------------------------------------------------
#include <ansi_c.h>
#include "ownet.h"
#include "findtype.h"
#include "temp10.h"
#define MAXDEVICES 4
void f_proto(void) {
int COMport, DS1920count;
uchar FamilySN[MAXDEVICES][8]; // array to hold the serial numbers for the devices found
int j, i=0;
float currentTemp;
//if a DS2480B on the serial port, stop the program
if((COMport = owAcquireEx("COM1")) < 0) {
printf("Failed to acquire port.\n");
return;
}
// success
printf("Port opened\n");
// Find the device(s)
DS1920count = FindDevices(COMport, &FamilySN[0], 0x10, MAXDEVICES);
if (DS1920count>0) {
printf("\n");
printf("Device(s) Found: \n");
for (i = 0; i < DS1920count; i++) {
PrintSerialNum(FamilySN[i]);
printf("\n");
}
printf("\n\n");
// (stops on CTRL-C)
do {
// read the temperature and print serial number and temperature
for (i = 0; i < DS1920count; i++) {
if (ReadTemperature(COMport, FamilySN[i],¤tTemp)) {
PrintSerialNum(FamilySN[i]);
printf(" %5.1f \n", currentTemp * 9 / 5 + 32);
// converting temperature from Celsius to Fahrenheit
} else {
printf(" Error reading temperature, verify device present:%d\n", (int)owVerify(COMport, FALSE));
}
printf("\n");
}
} while (!key_abort());
} else {
printf("\n\n\nERROR, device DS1920/DS1820 not found!\n");
}
// release the port
owRelease(COMport);
return;
}
04-27-2006 01:40 PM
05-05-2006 09:15 AM
11-10-2016 12:32 PM
Sorry for resurrecting a very old post, everone. But I stumbled upon this and found it to be very helpful.
How did you guys deal with all the many included headers? In my case, I'm trying to talk to a temp sensor and a EEPROM. So at first I kept the number of attached headers and c files in my project as small as possible. But these in turn all include other headers, and so on. It becomes a nightmare trying to get it all sorted.