cheetha
Full Member level 2
- Joined
- Sep 17, 2011
- Messages
- 146
- Helped
- 1
- Reputation
- 2
- Reaction score
- 2
- Trophy points
- 1,298
- Activity points
- 2,310
Show us your wiring , take a photo...
If the ground surface is too small you can get this kind of problem.
Try to have only one point to ground Analog, digital and power supply
add capacitor 100nF between power supply VDD-VSS
I think you can add a small RC filter that attenuates roughly 10 times at 41 kHz that should be the frequency of your 555.
Simply remove the wire between pin 2 (output) of LM35 and pin 2 (ADC input) of the PIC. Connect these two pins using a 10 kohm resistor. Place now a 4.7 nF capacitor between pin 2 of PIC to ground.
This filter has to be as close as possible to the input pin of the PIC.
i connected 10Kohm resistor b/w pin 2 and ground and 10nF capacitor (as nearer available) b/w ground and pin2 of PIC but still temp displayed should be zero instead it varying b/w 3 and 0
Probably I didn't explain very well. The 10k resistor has to be connected from pin2 of LM35 and pin2 of the PIC (that is the input of ADC). At present you have a wire from pin2 of LM35 and pin2 of the PIC: simply replace that wire with the resistor.
It seems, instead, you connected properly the capacitor.
OK, this means isn't a problem due to noise on the line.
Do you use the 555 output to clock the ADC to which the temperature sensor is connected ? It seems you have problems with adc timing. I don't know the PIC and I'm not able to check your code. However I suggest you to verify that the constrain reported on the data-sheet on the ADC topic are satisfied.
hello,
another way to check;
i didn't any quartz + capacitor on schematic
it seems you are using internal oscillator on this PIC ?
but config is
CONFIG OSC=XT, PWRT=ON, BOR=OFF, WDT=OFF, LVP=OFF, DEBUG=OFF
XT is for Quartz ?
With a not clean wiring , you can have interference with the internal oscillator of the PIC.
Try to use a quartz ex 4MHz + 2x22pF to fixe a good clock for the PIC
hello
did you try to use FOsc for ADC instead of internal RC oscillator
;ADC CONFIGURE
BSF CTRL,ADC
MOVLW 01H ; Fosc/2 or 41H FOSC/8 ... instead of C1H
MOVWF ADCON0
.....
also
see datasheet 11.2
2: When the device frequencies are greater than 1 MHz, the RC A/D conversion clock source is only recommended
for SLEEP operation.
hello,
you turn around the main problem,
as i allready said in post #19
you get a measure +- 1bit => +-2°C
NORMAL !! Because 8 bits only.
treat measurment with 10 bits, so the weight of +- 1 bit will decrase
drasticly.
do step by step to solve your problem:
Solve adc measure to say : yes,no probleme on ADC
before to polarise on NE555
;RS232 19200,8,N,1
;with Quartz=10MHz
;SEC_DELAY=1sec
; with a LM35DZ
19:49:07.479> START
19:49:16.542> 0078 0044 0044 0044 0044 0044 0044 0044 0044 0044 0474 + 23.7°C
19:49:26.556> 0044 0044 0044 0044 0044 0044 0044 0044 0044 0044 0440 + 22.0°C
19:49:36.571> 0044 0044 0044 0044 0044 0044 0044 0044 0044 0044 0440 + 22.0°C
19:49:46.635> 0044 0044 0044 0044 0044 0044 0044 0044 0044 0044 0440 + 22.0°C
19:49:56.650> 0044 0044 0044 0044 0044 0044 0044 0044 0044 0044 0440 + 22.0°C
19:50:06.714> 0044 0044 0044 0044 0044 0044 0044 0044 0044 0044 0440 + 22.0°C
19:50:16.729> 0044 0044 0044 0044 0044 0044 0044 0044 0044 0044 0440 + 22.0°C
19:50:26.743> 0044 0044 0044 0044 0044 0044 0044 0044 0044 0044 0440 + 22.0°C
;paulfjujo 23/02/2013
list p=18f252
#include <p18f252_.inc> ;processor specific definitions
CONFIG OSC=HS ,OSCS=OFF
CONFIG BOR=OFF
CONFIG WDT=OFF ,CCP2MUX=OFF
CONFIG STVR=OFF, LVP=OFF, DEBUG=OFF
CONFIG CPB=OFF ; boot protect off
CONFIG CP0=OFF,CP1=OFF,CP2=OFF,CP3=OFF
CONFIG CPD=OFF
;---- select here Quartz & Baud rate RS232 ------------------------
#define FOSC D'10000000' ; quartz 10MHZ
#define BAUD D'19200'
#define DIVIDER (FOSC/(D'16' * BAUD))-1
; NE555 on RA4
;100K
;330
;100pF 4,7µF
;54320Hz <2Hz
ADC EQU RA0
LCD_DATA EQU PORTB
CTRL EQU TRISA
RS EQU RC0
RW EQU RA2
EN EQU RC1
CI EQU RA4 ; from NE555 output
HT EQU RA5
FN EQU RA6
Led1 EQU 2
CBLOCK 0x0000
PHigh
PLow
Q1L
Q1H
Q2
Q3
Var1
Var2
;--
Count
NbMesures
Drapeaux ; multipurpose flags
;Drapeau:7= signe mesure temp 1=negatif 0=positif pour DS1624
;Drapeau:6= Elligibilite de stockage mesure
;Drapeau:5 =test si saisie binaire ou BCD
;Drapeau:4= choix format 1=999 0=65535 pour bcd53 (5 ou 3 digits)
;Drapeau:3= choix format 1=XX 0=XXX pour bcd3
;Drapeau:2= choix output 1=Rs232 0=LCD
;Drapeau:1= choix format 1=XXXX.X 0=XXXXX pour bcd5
;Drapeau:0= pour effacer zero inutile
; Bcd
Mcount
btmp
btmp1
dixmil
mille
cent
dix
uno
value
; variables 16 bits
MesAn0 :2
valx :2
val1 :2 ; val1=LOW Val1+1=HIGH
val2 :2
Cumul :2
reste :2
result :2
ENDC
ORG 0x0000 ;place code at reset vector
nop
nop
goto Start
;This code executes when a high priority interrupt occurs.
ORG 0x0008 ;place code at interrupt vector
HiIntCode: ;do interrupts here
nop
reset ;error if no valid interrupt so reset
;----------------------------------------------------------------------------
;This code executes when a low priority interrupt occurs.
ORG 0x0018 ;place code at interrupt vector
LoIntCode: ;do interrupts here
nop
reset ;error if no valid interrupt so reset
;----------------------------------------------------------------------------
;#define TESTING
Start
CLRF TRISC
CLRF Drapeaux
; init RS232
bsf TRISC,RC7 ; RX UART
movlw DIVIDER ;set baud rate
movwf SPBRG
; Q= 10MHZ 19200 bauds
movlw 0x24 ;enable transmission TXEN=1 and BRGH=1 high baud rate
; Q=4MHZ 4800 bauds
; movlw 0x20
movwf TXSTA
bank0
movlw 0x90 ;enable serial port SPEN=1 and reception CREN=1
movwf RCSTA
; presentation
MOVLW .12 ; CLS
call Rs_Putchar
call SEC_DLY
MOVLW 'S'
call Rs_Putchar
MOVLW 'T'
call Rs_Putchar
MOVLW 'A'
call Rs_Putchar
MOVLW 'R'
call Rs_Putchar
MOVLW 'T'
call Rs_Putchar
MOVLW .10
call Rs_Putchar
MOVLW .13
call Rs_Putchar
;config TIMER1,16 BIT, INT-CLK, PRESCALER 1:8
; 0xB0h mode 2x8bits, innternal clock Fosc/4 prescaler=1/8, TRM1 OFF
MOVLW b'00110000'
MOVWF T1CON
BCF PIR1,TMR1IF
BCF PIE1,TMR1IE ; NO interrupt
BSF IPR1,TMR1IP ; hig priority interrup (if used!)
MOVLW 0x0B
MOVWF TMR1H
MOVLW 0xDB
MOVWF TMR1L
BCF T1CON,TMR1ON ; timer1 OFF , not yet used
;CONFIGURE Timer0 as COUNTER
BSF PORTA,4 ; RA4 as input
MOVLW 28H ;No prescaler,Transition on T0CKI pin, low edge ,COUNTER, 16BIT
MOVWF T0CON
BCF INTCON,TMR0IF
BCF INTCON,INT0IE
;ADC CONFIGURE
BSF CTRL,ADC
MOVLW 0C1H
MOVWF ADCON0
MOVLW 8EH
MOVWF ADCON1
CALL DELAY
movlw .10
movwf NbMesures
clrf Cumul
clrf Cumul+1
MainLoop:
;PROCESSING TEMP
ifdef TESTING
; simule ADC0 = 0039
movlw .40
movwf val1
clrf val1+1
else
BSF ADCON0,GO
CALL DELAY
BACKADC
BTFSC ADCON0,DONE
BRA BACKADC
NOP
MOVF ADRESL,W
movwf val1 ; prepare for convert
MOVF ADRESH,W
movwf val1+1
Endif
bcf Drapeaux,5 ; mode 5 digits to see 00000 up to 01023
call bcd_temp
MOVLW .9 ; Tabulation
call Rs_Putchar
; moyennage pour augmenter la resolution
bcf STATUS,C
movf val1+1,W ; addition 16 bits
addwf Cumul+1,f ; cumul = cumul + valx
movf val1,W
addwf Cumul,f
btfsc STATUS, C
incf Cumul+1,f
decfsz NbMesures
goto MainLoop
movf Cumul,W
movwf val1
movf Cumul+1,W
movwf val1+1
bcf Drapeaux,5 ; mode XXXX
call bcd_temp
; divide by 2 !!
bcf STATUS,C
rrcf val1+1,f ; rotate right through carry
rrcf val1,f
; cumul = (somme de 10 raw data) /2
; car 1023 points pour 500°C arrondi a 1000*10/2
bsf Drapeaux,5,0 ; mode xxx.XX
call bcd_temp
clrf Cumul
clrf Cumul+1
movlw .10
movwf NbMesures
MOVLW .9
call Rs_Putchar
;processing humidity
MOVLW 'F'
call Rs_Putchar
MOVLW '='
call Rs_Putchar
CLRF TMR0H ;TMR0H MUST BE LOADED FIRST
CLRF TMR0L ;TMROL MUST BE LOADED AFTER
BSF T0CON,TMR0ON ; arme comptage sur RA4 Timer0
CALL SEC_DLY ; uses Timer1 for 1sec elapsed time
BCF T0CON,TMR0ON ; stop comptage sur RA4
; display result
MOVFF TMR0L,PLow ;TMR0L MUST BE COPIED FIRST
MOVFF TMR0H,PHigh ;TMROH MUST BE COPIED AFTER
; affiche frequence
movf PLow,W
movwf val1
movf PHigh,W
movwf val1+1
; movlw 0xFF
; movwf val1
; movwf val1+1; test 65535
bcf Drapeaux,5,0 ; mode XXXXX
call bcd_temp
MOVLW .10
call Rs_Putchar
MOVLW .13
call Rs_Putchar
MOVF PHigh,W ;
MOVLW 8EH ;MSB de 36352 Hz IN DECIMAL
CPFSGT PHigh ; compare and skip if PH > TMR0H
goto ho
goto co
ho:
BSF PORTC,Led1 ; BSF PORTC,2
; BCF PORTC,3
goto MainLoop
co:
BCF PORTC,Led1 ;PORTC,2
; BSF PORTC,3
goto MainLoop
goto MainLoop ; <- what for ?
;CALL FUNCTIONS
VALUEWRT:
MOVF Q3,w
MOVWF LCD_DATA
BSF PORTC,0
;BCF CTRL,RW
BSF PORTC,1
CALL DELAY
BCF PORTC,1
MOVF Q2,w
MOVWF LCD_DATA
BSF PORTC,0
;BCF CTRL,RW
BSF PORTC,1
CALL DELAY
BCF PORTC,1
MOVLW '.' ; 2EH
MOVWF LCD_DATA
BSF PORTC,0
;BCF CTRL,RW
BSF PORTC,1
CALL DELAY
BCF PORTC,1
MOVF Q1L,w
MOVWF LCD_DATA
BSF PORTC,0
;BCF CTRL,RW
BSF PORTC,1
CALL DELAY
BCF PORTC,1
MOVF PLow,w
MOVWF LCD_DATA
BSF PORTC,0
;BCF CTRL,RW
BSF PORTC,1
CALL DELAY
BCF PORTC,1
RETURN
HEX2BCD:
CLRF PHigh
CLRF PLow
CLRF Q1L
CLRF Q1H
CLRF Q2
CLRF Q3
MULLW 30H ; W * 48 -> PRODH & L 40 points a 20°C => 40x48=1920
MOVFF PRODH,PHigh ;upper byte of product result
MOVFF PRODL,PLow ;lower byte of product result
MOVLW 0AH
CLRF Q1L
VV: INCF Q1L
BC AA
VV1:SUBWF PLow
BC VV
DECF PHigh
BN AA1
BRA VV
AA: INCF Q1H
BRA VV1
AA1:ADDWF PLow
DECF Q1L
;*************
VV2:INCF Q2
SUBWF Q1L
BC VV2
DECF Q1H
BN AA2
BRA VV2
AA2:ADDWF Q1L
DECF Q2
;**************
VV3:INCF Q3
SUBWF Q2
BC VV3
ADDWF Q2
DECF Q3
return
BCD2ASCII:
MOVF Q3,W
IORLW 30H
MOVWF Q3
MOVF Q2,w
IORLW 30H
MOVWF Q2
MOVF Q1L,w
IORLW 30H
MOVWF Q1L
MOVF PLow,w
IORLW 30H
MOVWF PLow
RETURN
COMDWRT:
MOVWF LCD_DATA
BCF PORTC,0 ;RS=0
;BCF PORTC,1 ;R/W=0
BSF PORTC,1 ;EN=1
CALL DELAY
BCF PORTC,1 ;EN=0
RETURN
DATAWRT:
MOVWF LCD_DATA
BSF PORTC,0
;BCF CTRL,RW
BSF PORTC,1
CALL DELAY
BCF PORTC,1
RETURN
Rs_Putchar
; put your routine to display char on LCD
; after writing the car, the position on LCD must be increased
; use your code instead of this code
btfss PIR1,TXIF
goto Rs_Putchar
movwf TXREG ;data transmit
return
DELAY:
MOVLW 1FH
MOVWF Var2
AGAIN:
NOP
NOP
DECF Var2,f
BNZ AGAIN
return
LDELAY:
MOVLW 5FH
MOVWF Var1
AGAIN1:
NOP
NOP
DECF Var1,f
BNZ AGAIN1
return
; one second delay f(Quartz)
SEC_DLY
bank0
IF FOSC == .10000000
MOVLW 5 ; 5 x 200mS Q=10MHz
ENDIF
IF FOSC == .4000000
MOVLW 2 ; 2 x 500mS Q=4MHz
ENDIF
IF FOSC == .2000000
MOVLW 1 ; 1 x 1000mS Q=4MHz
ENDIF
MOVWF Count,0
T0:
MOVLW LOW (.3035) ; DBh
MOVWF TMR1L
MOVLW HIGH (.3035) ; 0Bh
MOVWF TMR1H
BCF PIR1,TMR1IF
BSF T1CON,TMR1ON ;START TIMER1
T1:
BTFSS PIR1, TMR1IF
BRA T1
BCF T1CON,TMR1ON ;SToP TIMER1
DECF Count,f,0
BNZ T0
BCF PIR1,TMR1IF
BCF T1CON,TMR1ON ;STOP TIMER
return
;---------------- Binary (16-bit) to BCD -----------------------
; 16-bit-Binary -> 4 digits de 8bits
; ( val1:val1+1) -> Dixmil , mille , cent , dix , uno
bcd_temp
; save value
movf val1,W
movwf valx
movf val1+1,W
movwf valx+1
swapf val1+1,W ; HIGH
andlw 0x0F
addlw 0xF0
movwf mille
addwf mille,F
addlw 0xE2
movwf cent
addlw 0x32
movwf uno
movf val1+1,W
andlw 0x0F
addwf cent,F
addwf cent,F
addwf uno,F
addlw 0xE9
movwf dix
addwf dix,F
addwf dix,F
swapf val1,W ; LOW
andlw 0x0F
addwf dix,F
addwf uno,F
rlcf dix,F
rlcf uno,F
comf uno,F
rlcf uno,F
movf val1,W
andlw 0x0F
addwf uno,F
rlcf mille,F
movlw 0x07
movwf dixmil
movlw 0x0A
Lb1:
decf dix,F
addwf uno,F
btfss STATUS,C
bra Lb1
Lb2:
decf cent,F
addwf dix,F
btfss STATUS,C
bra Lb2
Lb3:
decf mille,F
addwf cent,F
btfss STATUS,C
bra Lb3
Lb4:
decf dixmil,F
addwf mille,F
btfss STATUS,C
bra Lb4
btfss Drapeaux,5 ; 1 => affichage 00000 a 999999
bra Bcd_5digits ; 0 => affichage + ou - XXX.XX
movlw '+'
btfsc Drapeaux,7
movlw '-'
call Rs_Putchar
movf mille,w
btfss STATUS,Z ; si digit=0 remplace par Blanc
bra Lb5
movlw ' '
call Rs_Putchar
bra Lb6
Lb5
addlw '0'
call Rs_Putchar
Lb6
movf cent,w
addlw '0'
call Rs_Putchar
movf dix,w
addlw '0'
call Rs_Putchar
movlw '.'
call Rs_Putchar
movf uno,w
addlw '0'
call Rs_Putchar
movlw '°'
call Rs_Putchar
movlw 'C'
call Rs_Putchar
bra Bcd_51
;---------------
Bcd_5digits
movf dixmil,w
addlw '0'
call Rs_Putchar
movf mille,w
addlw '0'
call Rs_Putchar
movf cent,w
addlw '0'
call Rs_Putchar
movf dix,w
addlw '0'
call Rs_Putchar
movf uno,w
addlw '0'
call Rs_Putchar
movlw ' '
call Rs_Putchar
Bcd_51
; restitue val1
movf valx,W
movwf val1
movf valx+1,W
movwf val1+1
return
END
Sat Feb 23 16:29:14 2013
----------------------------------------------------------------------
Clean: Deleting intermediary and output files.
Clean: Deleted file "C:\_Mplab8\_Mesprojets_ASM\_18Fxxxx\18F_NE555_ADC.o".
Clean: Deleted file "C:\_Mplab8\_Mesprojets_ASM\_18Fxxxx\18F_NE555_ADC.err".
Clean: Deleted file "C:\_Mplab8\_Mesprojets_ASM\_18Fxxxx\18F_NE555_ADC.hex".
Clean: Deleted file "C:\_Mplab8\_Mesprojets_ASM\_18Fxxxx\18F_NE555_ADC.lst".
Clean: Deleted file "C:\MPLAB8\_Mesprojets\18F_NE555_ADC.cof".
Clean: Deleted file "C:\MPLAB8\_Mesprojets\18F_NE555_ADC.map".
Clean: Done.
Executing: "C:\Program Files\Microchip\MPASM Suite\MPASMWIN.exe" /q /p18F252 "18F_NE555_ADC.asm" /l"18F_NE555_ADC.lst" /e"18F_NE555_ADC.err"
Warning[219] C:\_MPLAB8\_MESPROJETS_ASM\_18FXXXX\18F_NE555_ADC.ASM 241 : Invalid RAM location specified.
Warning[219] C:\_MPLAB8\_MESPROJETS_ASM\_18FXXXX\18F_NE555_ADC.ASM 242 : Invalid RAM location specified.
Warning[219] C:\_MPLAB8\_MESPROJETS_ASM\_18FXXXX\18F_NE555_ADC.ASM 319 : Invalid RAM location specified.
Warning[219] C:\_MPLAB8\_MESPROJETS_ASM\_18FXXXX\18F_NE555_ADC.ASM 320 : Invalid RAM location specified.
Executing: "C:\Program Files\Microchip\MPASM Suite\mplink.exe" /p18F252 /l"C:\Mplab8\MPASM Suite" "18F_NE555_ADC.o" /z__MPLAB_BUILD=1 /m"C:\MPLAB8\_Mesprojets\18F_NE555_ADC.map" /w /o"C:\MPLAB8\_Mesprojets\18F_NE555_ADC.cof" /x
MPLINK 4.46, Linker
Device Database Version 1.11
Copyright (c) 1998-2011 Microchip Technology Inc.
Errors : 0
Loaded C:\MPLAB8\_Mesprojets\18F_NE555_ADC.cof.
----------------------------------------------------------------------
Release build of project `C:\_Mplab8\_Mesprojets_ASM\_18Fxxxx\18F225_Tst.mcp' succeeded.
Language tool versions: MPASMWIN.exe v5.48, mplink.exe v4.46, mplib.exe v4.46
Sat Feb 23 16:29:17 2013
----------------------------------------------------------------------
BUILD SUCCEEDED
17:16:05.088> 00040 00038 00039 00039 00041 00040 00040 00038 00039 00039 00393 + 19.6°C F=54452
17:16:06.139> 00040 00038 00038 00039 00039 00041 00040 00040 00040 00038 00393 + 19.6°C F=54441
17:16:07.191> 00038 00038 00039 00037 00041 00041 00041 00040 00040 00040 00395 + 19.7°C F=54431
17:16:08.242> 00041 00041 00041 00041 00040 00040 00040 00040 00043 00040 00407 + 20.3°C F=54428
17:16:09.294> 00040 00040 00040 00040 00048 00040 00038 00038 00038 00038 00400 + 20.0°C F=54426
17:16:10.345> 00039 00039 00039 00039 00041 00041 00041 00041 00041 00039 00400 + 20.0°C F=54427
17:16:11.397> 00039 00041 00041 00041 00040 00040 00040 00040 00040 00040 00402 + 20.1°C F=54431
17:16:12.448> 00041 00038 00038 00039 00039 00039 00041 00041 00041 00040 00397 + 19.8°C F=54434
17:16:13.500> 00040 00038 00038 00038 00039 00039 00041 00041 00039 00040 00393 + 19.6°C F=54440
17:16:14.551> 00040 00038 00039 00039 00041 00041 00040 00040 00046 00038 00402 + 20.1°C F=54452
17:16:15.553> 00041 00040 00041 00038 00037 00041 00040 00040 00038 00038 00394 + 19.7°C F=54465
17:16:16.604> 00038 00039 00041 00040 00040 00038 00039 00041 00040 00042 00398 + 19.9°C F=54475
17:16:17.656> 00039 00041 00040 00038 00039 00041 00040 00038 00039 00040 00395 + 19.7°C F=54494
17:16:18.707> 00040 00041 00039 00041 00041 00039 00041 00040 00039 00041 00402 + 20.1°C F=54509
17:16:19.759> 00040 00038 00041 00040 00039 00040 00039 00040 00038 00041 00396 + 19.8°C F=54565
17:16:20.810> 00039 00040 00041 00038 00040 00039 00038 00040 00039 00042 00396 + 19.8°C F=55029
17:16:21.862> 00039 00041 00039 00041 00041 00041 00041 00041 00041 00039 00404 + 20.2°C F=54571
17:16:22.913> 00039 00040 00038 00039 00038 00041 00039 00039 00040 00039 00392 + 19.6°C F=54516
17:16:23.965> 00040 00039 00041 00041 00039 00039 00040 00039 00041 00040 00399 + 19.9°C F=54499
17:16:25.016>
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?