matc
stranger
Reged: Jun 29 2009
Posts: 6
Loc: Sydney, Australia
|
|
i am in dire need of some source code or examples for a DS18B20 one wire thermometer. i need the code for use with a 4MHZ 16F628. i cant find anything of use in Hi-Tech C and am at a dead end. i need this for my final year major work. this is interfaced with a nokia 3310 lcd. i all ready have others inputs/ouputs working perfecting to retrieve settings but i need the temp settings!
|
mikerj
Guru
  
Reged: Oct 19 2003
Posts: 1482
Loc: Devon, UK
|
|
As long as you have a reasonably accurate delay function, implementing the one wire protocol is not difficult. This project uses the DS1821 which is similar, but I strongly suggest you read the datasheet and familiarise yourself with the one wire protocol rather than blindly implementing other peoples code or you will have no chance in debugging it.
|
Dan Henry
Guru
  
Reged: Oct 16 2003
Posts: 3872
Loc: Colorado
|
|
There's a bunch 1-Wire example code in C and even PIC assembler on the Maxim website ready for you to adapt.
|
matc
stranger
Reged: Jun 29 2009
Posts: 6
Loc: Sydney, Australia
|
|
thats the problem i have tired implementating code from the maxim website as well as all other examples i can find, only problem is i am very new to the programming environment and this is my first time progrmamming a pic. my main problem is with code implementation. i can understand it, but have trouble converteing it to hi-tech c because of how new i am to it. anybody have pre-written examples in hi-tech c that i could use as a starting point?? (i already tried the one on the mircochip website).
|
swanny
enthusiast
Reged: Sep 12 2008
Posts: 247
Loc: New Zealand
|
|
Sounds like you need to have a bit more of a play around first. Flash some leds, use some timers to flash leds, do stuff on interrupts etc etc. You'll need to familiarise yourself with the datasheet. Most 'variable' names are the same in htc as they are in the datasheet (and the ones that aren't can be figured out by looking in the compiler header for your device).
Is this a uni project? Maybe your supervisor has some code examples you can have a play with.
|
matc
stranger
Reged: Jun 29 2009
Posts: 6
Loc: Sydney, Australia
|
|
ok will do. its not a uni project, its a final year electronics major work for my hsc (high school). ive basically built a media centre out of an xbox from scratch, (ie designed my own modchip and contrl circuits). the nokia lcd is the final part and is just showing various outputs (i.e bios setings, hdd read/write sequences). The last step was this temp sensor, to stop it from overheating, but i keep hitting a wall. i have about 3 years programming experience but as this is my firt real pic project, some of the concepts are still a bit out of reach. one more question though, do i need to setup the inbuilt timers on the pic? i already have the watchdog timer, etc disabled, i have a feeling that something in interfering with the timer1, timer2 or whatever they are called.
thanks for all the help so far.
|
mikerj
Guru
  
Reged: Oct 19 2003
Posts: 1482
Loc: Devon, UK
|
|
Quote:
(i already tried the one on the mircochip website).
And what was the result?
|
matc
stranger
Reged: Jun 29 2009
Posts: 6
Loc: Sydney, Australia
|
|
either doesnt output anything or crashes, however this may be an issue with the library i am using to print to the 3310 screen. the main print function ( nokia_printmessage(char*message)) obviously only allows the input of characters so i tried sending the intergers in bytes to the screen using a send byte function, but still no output or a crash! still need to play around a bit. if anyone would be kind enough to take the time to have a quick look at my code and the resulting libraries i will be happy to post it. cheers
Edited by matc (Thu Jul 02 2009 07:32 AM)
|
Neil_K
 
Reged: Mar 09 2005
Posts: 960
Loc: NY,USA
|
|
Do you have access to an oscilloscope?
|
swanny
enthusiast
Reged: Sep 12 2008
Posts: 247
Loc: New Zealand
|
|
You need to format the integers as a string to display them on your screen.
Depending on what sort of numbers you have you may choose to do this yourself or use some kind of library function.
Seen this: http://www.electronics-lab.com/projects/mcu/013/index.html I particularly like the way you adjust the contrast for your display 
Might have to get one of those LCDs to have a play with.
|