help with student project please

s.messenger

New Member
I am a GCSE student studying electronic products. I have chosen to make a temperature sensor for my major project. I was thinking of using a
DS18B20 sensor to sense temperature and then relay this information to the PICAXE 18 and thenturn on some outputs when it reaches a temperature that can be set by the user . I was wondering if anyone could give me some tips on how to do this on PIC logicator.
Thanks
 

lbenson

Senior Member
The PICAXE 18 doesn't support the readtemp command which reads the ds18b20. The PICAXE 18X does, and 18A and 18M. If you're willing to forgo Logicator and use picaxe basic like most of the forum users, you will get better help.

At the core, your program could be as simple as:

Code:
main:
  readtemp 6,b13    ' read a ds18b20 attached to pin 6 into variable b13
  if b13 > 25 then  ' if temp > 25C then 
    high 7          ' turn on led attached to pin 7
  else
    low 7           ' otherwise turn off led attached to pin 7
  endif
  pause 1000        ' wait one second
  goto main
You can copy this into the program editor and simulate it to see how it works. Click the ">" symbol next to "generic" to change the simulated temperature from 0 to 50 to see how the led on pin 7 toggles. Click "<" to turn the led back off. Read Manual 2 to learn the meaning of each of the basic commands in the program.

Having the user input the cutoff temperature is a little harder. Two pushbutton inputs could be used, one to increase the temperature by a degree, another to decrease it. You would need an output to show what the temperature is. You can use the Program Editor display function (with a command like sertxd) or an LCD (which can be simulated).

A single pushbutton could do it if you timed a button press and used a press of, say, 2 seconds to toggle and "up" or "down" mode--shorter presses would increase or decrease the cutoff temperature based on the mode.
 
Last edited:

hippy

Ex-Staff (retired)
lbenson is right about the PICAXE-18 but if you can use a different PICAXE then PIC-Logicator has the ReadTemp command which will place the temperature into a variable.

Once you have the temperature you can use Compare to test against fixed values and perform actions when temperature is below or above a certain level.

Start with a simple ReadTemp and Debug loop, then add a Compare, then move up to two Compares, then comparing against stored value. As you build up from very little you will most likely gain experience and understanding which makes later things easier. Dive in at the deep end straight away and it will look a lot harder than it is.
 
Top