Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
November 25, 2024, 06:25:29 06:25


Login with username, password and session length


Pages: [1]
Print
Author Topic: Proton+ and DS18B20  (Read 12728 times)
0 Members and 2 Guests are viewing this topic.
jibun24
Newbie
*
Offline Offline

Posts: 13

Thank You
-Given: 0
-Receive: 0


« on: November 11, 2005, 05:12:18 17:12 »

Hi,
I use a Dallas temperature sensor DS18B20 with 18F452 and cristal of 4Mhz and it 'sworking fine.
Because I use a lot of interrupts I use now a cristal of 10 MHz.
But now the DS18B20 is not working with the 10 Mhz cristal with exactly the same code, using Owrite and Oread from Proton+. There are no speed setting to change in Proton+ for Dallas one wire components following the cristal.
I use proton+ 2.20 beta8.
I think now the timing for the DS18B20 is not good and may be this problem come from a bug of proton+.
Does somebody met this problem also ?
Thank you for you help. :confused:

Jibun24
Logged
Wizpic
Global Moderator
Hero Member
*****
Offline Offline

Posts: 1203

Thank You
-Given: 554
-Receive: 409



« Reply #1 on: November 11, 2005, 06:19:24 18:19 »

upload your code and i will see for you
there should be no differance really
i run later version
 
wizpic
Logged

When you think, "I can't do anymore. I need a break," that is the time to challenge yourself to keep going another five minutes. Those who persevere for even an extra five minutes will win in life..
vsmvdd
Junior Member
**
Offline Offline

Posts: 92

Thank You
-Given: 1
-Receive: 25


« Reply #2 on: November 11, 2005, 11:06:45 23:06 »

it maybe that your running the code for the micro too fast for the drivers used to develop
code fussion with the sensor
 
you may need to add some nops
 
a nop or 90 is developed to waist an instruction cycle
 
so adding a few nops to the interface driver for the code to the sensor chip will cure this
{look up the softwares commands table for the right nemonics for nop instuctions}
 
remember a pic18 has an internal X4 stage
 
so 10 mhz is 40 mhz core speed so 4/40 = 100ns is the single instuction speed of you 20mhz pic
 
 
and one instruction = 1 nop if you program one
 
so you may need to adjust the timing of the drivers ... in code,,,
 
4/16 = 250ns was you single speed before you changed the clock
« Last Edit: November 11, 2005, 11:18:03 23:18 by vsmvdd » Logged
jibun24
Newbie
*
Offline Offline

Posts: 13

Thank You
-Given: 0
-Receive: 0


« Reply #3 on: November 13, 2005, 02:08:33 14:08 »

Thank you for your help.

I have updated all my code with the new cristal (10 Mhz), and all the code is working fine except the DS18B20.
You will find bellow my code ans somes informations for good understanding.

Some informations
-The DS18B20 use 12 bits Analog/digital converter
-In 12 bits mode the DS18B20 need 0,75 s time conversion
-The bit 11 of the ScratchPad give the sign of the temperature
-When the temperature is negative, you must do the complement of data for get the good temperature value.
-The Float KT=0.0625
-The variable TMPRC is a word
-The byte MES is init to zero
-The procedure DS1820 is called every second

DS1820:   'Temperature Acquisition
 If MES=1 then   'temperature calculation in progress
    OREAD TRC, 4, [FMES]  'reading bit end of temperature calculation
    IF FMES=0 then return  'Calculation of temperature not finished
    OWRITE TRC, 1, [$CC, $BE] 'Send command for put results in ScratchPad
    OREAD TRC, 2,[TMPRC.LOWBYTE,TMPRC.HIGHBYTE] 'Temperature reading (ScratchPad)
    MES=0   ' Temperature acquisition of DS18B20 finished
   
    'Temperature conversion in degree Celsus
    IF TMPRC.11 = 1 then  'negative température, The bit 11 of ScratchPad give the signe        
       TZ1N=~TMPRC 'complement for get the good temperature value
       TZ1N= TZ1N * KT 'In 12Bits mode the DS18B20 have a résolution of 0.0625 per degree Celsius
       TZ1=TZ1N * -1 'Put negative temperature
      else     'Positive température          
       TZ1= TMPRC * KT 'In 12Bits mode the DS18B20 have a résolution of 0.0625 per degree Celsius                
    EndIF      
 EndIF
 
 If MES=0 then
    OWRITE TRC, 1, [$CC, $44]   ' Send request fot temperature calculation, 12 bits by default
    MES=1   'temperature calculation in progress
 EndIf
Return
Logged
dezso
Junior Member
**
Offline Offline

Posts: 82

Thank You
-Given: 34
-Receive: 137


« Reply #4 on: November 13, 2005, 08:04:39 20:04 »

How about this lline in the from of your code ?
 
 
CODE:
[indent]DEFINE OSC 10 'Oscillator speed in MHz: 3(3.58) 4 8 10 12 16 20 24 25 32 33 40

[/indent]EDN

Dezso"
Logged
jibun24
Newbie
*
Offline Offline

Posts: 13

Thank You
-Given: 0
-Receive: 0


« Reply #5 on: November 14, 2005, 05:09:08 17:09 »

Thank all,
I found the problem, I add a return just after this code:

else 'Positive température
TZ1= TMPRC * KT 'In 12Bits mode the DS18B20 have a résolution of 0.0625 per degree Celsius
RETURN
EndIF
Now the DS18B20 is working fine.

Thank you for your help
Jibun24
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC