Log in

View Full Version : 16F727 ADC problem



VeryEvilBetty
- 21st August 2011, 09:09
Hello

I cant get get ADC to work on my 16F727 already tried alot for 3 hours

Im trying to get it to work on E1 and E0

mister_e
- 21st August 2011, 09:18
Hi and welcome aboard!
Rule #1: post your code here and we will help you to spot the problem... unless you may end up with comments like "My crystal is broken..." and plah plah plah :D

Jumper
- 21st August 2011, 09:45
Rule #2: Have you checked with a voltmeter that the desired signal is present on the legs of the PIC and that the level is less than VDD.

VeryEvilBetty
- 21st August 2011, 09:46
Could find a edit button.


Device 16F727
Config1 DEBUG_OFF, BOR_OFF, CP_OFF, MCLRE_OFF, WDT_OFF, INTOSCIO
Xtal 16
; 76543210
PORTB = %00000000
TRISB = %00000010
ANSELB = %00000000 ;Or %00000001 or %00000010 or %00000000
; 76543210
ANSELE = %00000010
PORTE = %00000000
TRISE = %00000010

DEFINE ADC_BITS 10
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 10
ADCON0 = %00011001
ADCON1 = %01110011

Declare LCD_ENPin = PORTB.3 ;De EN aansluiting moet nu aan PORTA.6
Declare LCD_RSPin = PORTB.2 ;De RS aansluiting moet nu aan PORTA.7


Symbol potmeter = PORTE.1
Symbol voltmeting = PORTE.2

Dim var1 As Word
Dim var2 As Word

'-------[INITIALISE THE PICMICRO]----------------------------------------
Clear ;Wis alle RAM geheugen
DelayMS 500 ' Wait for the PICmicro to stabilise
Cls
Print "Rdy"
GoTo main ' Jump over the subroutines


main:
While 1 = 1



ADCIN 5, var1
ADCIN 6, var2
Print At 1,1, Dec var1
Print At 2,1, Dec var2

Wend

End

VeryEvilBetty
- 21st August 2011, 10:23
yes the signal is present on the leg of the pic but i just get a 3 diget number that keeps changeing and doesnt respond when i turn on my potmeter

mackrackit
- 21st August 2011, 10:47
I think you will have better luck on the Proton forum.
http://www.protonbasic.co.uk/

When you post there you will want to describe how you have the hardware setup along with the code.