1 //---------------------------------------------------------------------------
2 // Copyright (C) 2000 Dallas Semiconductor Corporation, All Rights Reserved.
4 // Permission is hereby granted, free of charge, to any person obtaining a
5 // copy of this software and associated documentation files (the "Software"),
6 // to deal in the Software without restriction, including without limitation
7 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 // and/or sell copies of the Software, and to permit persons to whom the
9 // Software is furnished to do so, subject to the following conditions:
11 // The above copyright notice and this permission notice shall be included
12 // in all copies or substantial portions of the Software.
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 // IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES
18 // OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 // OTHER DEALINGS IN THE SOFTWARE.
22 // Except as contained in this notice, the name of Dallas Semiconductor
23 // shall not be used except as stated in the Dallas Semiconductor
25 //---------------------------------------------------------------------------
27 // getV.c - This utility gets the Volts for pins Vad and Vdd from the DS2438.
38 // Global necessary for screenio
43 char *argv[]={__FILE__, "exow"};
45 //----------------------------------------------------------------------
46 // This is the Main routine for debit
48 int main() //short argc, char **argv)
56 uchar famvolt[MAXDEVICES][8];
58 // check for required port name
61 sprintf(msg,"1-Wire Net name required on command line!\n"
62 " (example: \"COM1\" (Win32 DS2480),\"/dev/cua0\" "
63 "(Linux DS2480),\"1\" (Win32 TMEX)\n");
64 //output_status(LV_ALWAYS,msg);
69 if(!owAcquire(portnum,argv[1],msg))
71 //output_status(LV_ALWAYS,msg);
80 numbat = FindDevices(portnum,&famvolt[0],SBATTERY_FAM,MAXDEVICES);
82 printf ("No device found.\n");
87 Vdd = Volt_Reading(portnum,TRUE,&famvolt[0][0]);
88 Vad = Volt_Reading(portnum,FALSE,&famvolt[0][0]);
90 temp = Get_Temperature(portnum,&famvolt[0][0]);
92 humid = (((Vad/Vdd) - 0.16)/0.0062)/(1.0546 - 0.00216 * temp);
95 printf("The humidity is: %4.4f\n", humid);
96 printf("Given that the temp was: %2.2f\n", temp);
97 printf("and the volt supply was: %2.2f\n", Vdd);
98 printf("with the volt output was: %2.2f\n", Vad);
103 }while(!key_abort());
105 owRelease(portnum,msg);
106 //output_status(LV_ALWAYS,msg);