PDA

View Full Version : DS 1620 Code example?



G-R-C
- 24th September 2006, 21:02
Hello
After doing a quick search here and on Google, I was able to find 1 minor
example code for PBP. In a project using another company's complier
my code has run out of memory. This forces my project into a situation
where a newer 18 pin PIC like the 16F88 is required. And that is the main
problem. As this pic is not supported by them.

Will someone help point me into the right direction as where to find code
for the DS 1620 for PBP.

Thanks gang
Gordon

sayzer
- 25th September 2006, 03:40
Hi Gordon,

Thanks to Bruce.
Here you can find an example in which you can see the code for DS1620.

http://www.rentron.com/PicBasic/SERLED.htm



-----------

G-R-C
- 25th September 2006, 03:46
AHH-HA
Yes thats what I had in mind.
Thank you Sazyer.

precision
- 25th September 2006, 03:50
' PicBasic Pro program to read DS1620 3-wire temperature sensor
' and display temperature on LCD

' Define LOADER_USED to allow use of the boot loader.
' This will not affect normal program operation.
Define LOADER_USED 1

Include "MODEDEFS.BAS"

' Define LCD pins
Define LCD_DREG PORTD
Define LCD_DBIT 4
Define LCD_RSREG PORTE
Define LCD_RSBIT 0
Define LCD_EREG PORTE
Define LCD_EBIT 1

' Alias pins
RST var PORTC.0 ' Reset pin
DQ var PORTC.1 ' Data pin
CLK var PORTC.3 ' Clock pin

' Allocate variables
temp var word ' Storage for temperature


Low RST ' Reset the device

ADCON1 = 7 ' Set PORTA and PORTE to digital

Low PORTE.2 ' LCD R/W line low (W)
Pause 100 ' Wait for LCD to start

Lcdout $fe, 1, "Temp in degrees C" ' Display sign-on message


' Mainloop to read the temperature and display on LCD
mainloop:
RST = 1 ' Enable device
Shiftout DQ, CLK, LSBFIRST, [$ee] ' Start conversion
RST = 0

Pause 1000 ' Wait 1 second for conversion to complete

RST = 1
Shiftout DQ, CLK, LSBFIRST, [$aa] ' Send read command
Shiftin DQ, CLK, LSBPRE, [temp\9] ' Read 9 bit temperature
RST = 0

' Display the decimal temperature
Lcdout $fe, 1, dec (temp >> 1), ".", dec (temp.0 * 5), " degrees C"

Goto mainloop ' Do it forever

End


or read http://www.melabs.com/resources/samples/x1/pbp/temp3x.bas

G-R-C
- 25th September 2006, 04:01
Thanks precision
This code looks very clean and striaght forward.
This should be easy to apply to my project.

Gordon

BobK
- 25th September 2006, 14:25
Hi Gordon,

I see from your other post regarding ISP Pro that you purchased PICBasic. Did you get the PICBasic Compiler or did you get the PIC Basic Pro version. There are distinct differences between the 2 programs.

Just trying to save you the time of using the above program with PIC Basic.

BobK

Acetronics2
- 25th September 2006, 16:46
Why not try here:

http://www.rentron.com/PicBasic/one-wire3.htm

simply ...

Alain

G-R-C
- 27th September 2006, 02:45
Thanks for the link ace. I purchased the pro after reading Chuck Hellebuyck's
book "Programming Pic Microcontrollers with PicBasic". Just seemed like PBP
was the way to go when using LCDs and a few other features.

Gordon