I've hit a road block while attempting to gather data off a Dallas DS2438 1-Wire Battery Monitor using a PIC16F88. Initially the script and wiring seemed correct. I've used a similar setup for a Dallas DS18B20 Temp Sensor and it worked like a charm. I assumed the sensor was damaged, but after giving 5 more a try, I figured I would post to see if anyone else had a suggestion.
The raw return is a bunch of 1's on the LCD. I've tried many different options, but with the same result.
Below is the PICBasic code I've been working with (although messy, but I'll fix later after I gain communication with the sensor) and a schematic. Any and all feedback is appreciated.
DS2438 Datasheet: http://datasheets.maxim-ic.com/en/ds/DS2438.pdf
PIC16F88 Datasheet: http://ww1.microchip.com/downloads/e...doc/30487c.pdf
DEFINE OSC 20 ' We're using a 20MHz oscillator
DQ_Pin VAR PORTB.2 ' One-wire Data-Pin "DQ" on PortB.2
Busy VAR BIT ' Busy Status-Bit
ANSEL = %00000000 ' set the AN's to digital
voltage VAR word
DEFINE DEBUG_REG PORTB ' Debug Port = PortB
DEFINE DEBUG_BIT 1 ' Debug.bit = 1
DEFINE DEBUG_BAUD 9600 ' Default baud rate = 9600
DEFINE DEBUG_MODE 1 ' Send Inverted serial data with debug
high PORTB.0 ' Proof of life LED
pause 500 'Let the LCD warm up
Start_Convert:
OWOUT DQ_Pin,1,[$CC, $B4] ' send voltage conversion command
Wait_Up:
OWIN DQ_Pin, 4, [Busy] ' Read busy-bit
IF Busy = 0 THEN Wait_Up ' Still busy..?, Wait_Up..!
PAUSE 15 ' Give it some time
OWOUT DQ_Pin,1,[$CC, $BE, $00] ' Skip ROM search, send Convert V, Read page 00h
OWIN DQ_Pin,2,[voltage.lowbyte, voltage.highbyte] ' Read two bytes
GOSUB Convert_Volt
GOTO Start_Convert
Convert_Volt:
DEBUG $FE,$01 ' Clear the LCD
DEBUG "Voltage:" ,Dec voltage.Highbyte/100,".", DEC1 voltage.Lowbyte/10,"v",10,13 ' needs to be modified
DEBUG "Raw:", IBIN16 voltage, 10,13
pause 1000 ' Wait 1 second then loop
RETURN
END
![]()
Bookmarks