Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/26/05 16:53
Read: times


 
#85834 - help with duty cycle measurement
Hello i am using a temp sensor smt160 http://smartec.nl/temperature_sensor.htm which gives temp in terms of duty cycle.I am using the 8052 to measure the duty cycle.For a certain period of time i am measuring the high period as well as the total period.I using timer0 as a timer with gate enabled to measure the high period while timer1 is used as measure the whole period.I am using the method 1 described in this pdf.

http://www.8052.com/users/gop8051/appsmt01.pdf

But still i am getting bizzare results with huge swings in the timing.i am not able to make out what i am doing wrong.I have checked sensor with oscilloscope and is alright.i did a small test how many interrupts it will give in certain period and result is matching with the datasheet.
/*This routines makes measurement for a certain period of time
Msr_dutycyc:   
            push ACC
            call TI0_init
            call TI1_init
            setb P3.7           ;Startup the temp Sensor
            jb   P3.2,$         
            jnb  P3.2,$         ;Waiting for sensor startup
            setb EA             
            jnb  Int2,$         ;Waiting for the first 1-0 interrupt to start measurement
            clr  EA             
chk_pin:    jnb  P3.2,$         ;Wait here till timer overflows which is 
            jb   TF1,Ovr_flw    ;preloaded to overflow after certain period of time
            jb   P3.2,$         ;and all the periods within this period are measured
            jnb  P3.2,chk_pin
Ovr_flw:    setb EA
            jb   Int2,$
            clr  EA
            call Addoffset
            clr P3.7 
            pop  ACC
            ret


;*********Timer0 and Int0 Intialisation***************
;Timer0 in 16 bit timer mode an di initialise external interrupt
TI0_init:
        anl TMOD,#0F0h      
        orl TMOD,#009h          
        mov TL0,#000h
        mov TH0,#000h
        setb IT0
        clr  IE0
        clr  TR0
        clr  TF0
        setb EX0
        ret

;**********Timer1 intialisation**************************
;Timer1 in 16 bit timer mode
TI1_init:
        anl TMOD,#00Fh
        orl TMOD,#010h
        mov TL1,#LOW(0FFFFh-OFFSET)
        mov TH1,#HIGH(0FFFFh-OFFSET)
        clr  TR1
        clr  TF1
        ret
 
;Interrupt which handles the 1-0 transitions

Interrupt0:
        push ACC
        jnb  Int2,FrstInt  
        clr  TR1
        clr  TR0
        mov  T0L,TL0 
        mov  T0H,TH0
        mov  T1L,TL1
        mov  T1H,TH1
        clr  TF1
        clr  Int2
        pop ACC
        ret
;********When measuring the first routine***********
FrstInt:
        setb TR1
        setb TR0
        setb Int2
        pop ACC
        ret

AddOffset:
            push ACC
            push PSW
            clr  C
            mov a,T1L
            add a,#LOW(OFFSET) ; this offset is set to so that             
            mov T1L,a          ;timer1 overflows after some time 
            mov a,T1H          ; to count a certain no of periods
            addc a,#HIGH(OFFSET)
            mov T1H,a
            pop PSW
            pop ACC
            ret
      


List of 30 messages in thread
TopicAuthorDate
help with duty cycle measurement            01/01/70 00:00      
   woefully incomplete            01/01/70 00:00      
      Definitions            01/01/70 00:00      
         gobbelygook            01/01/70 00:00      
   Routines            01/01/70 00:00      
   sorry for the gobbelygook            01/01/70 00:00      
      A job for the PCA?            01/01/70 00:00      
      now that is clear            01/01/70 00:00      
      4 errors found in your smt_1.asm pgm            01/01/70 00:00      
         maybe only 3            01/01/70 00:00      
   cannot change            01/01/70 00:00      
   SMT160 example code in C            01/01/70 00:00      
      why            01/01/70 00:00      
         It is absolute necessary !            01/01/70 00:00      
            on the fly            01/01/70 00:00      
               Thus I use assembler !            01/01/70 00:00      
                  not assembler but int            01/01/70 00:00      
                     It must be XCH !            01/01/70 00:00      
                        still wrong to read with running            01/01/70 00:00      
                           not wrong, since it is tested !            01/01/70 00:00      
                              OK            01/01/70 00:00      
            Thanks to all            01/01/70 00:00      
   Thanks Peter            01/01/70 00:00      
      Do some simple tests first            01/01/70 00:00      
         Problem solved But            01/01/70 00:00      
   Modified code and mistakes            01/01/70 00:00      
   smt160.asm example            01/01/70 00:00      
      Thanks for example            01/01/70 00:00      
   Please explain            01/01/70 00:00      
      Yes            01/01/70 00:00      

Back to Subject List