ADC.bas

General discussion relating to the library modules supplied with the compiler

Moderators: David Barker, Jerry Messina

Post Reply
be80be
Registered User
Registered User
Posts: 90
Joined: Mon Feb 23, 2009 2:15 am
Location: tn

ADC.bas

Post by be80be » Thu Dec 13, 2012 5:52 am

Been trying to use the ADC.bas in 8 bits reading ADRESL but i get 255 to 0 from VDD to middle of the pot then it jumps to 255 to 0 middle to grd.

The 10 reading work fine

I tested it with this code

Code: Select all

Dim Variable As Word
Dim Variable1 As Word

SetBaudrate(br19200)
Variable = 0
While True
  ADC.Read (0)
  DelayMS(500)
  Variable = ADResult    // 10 bit reading
  Variable1 = ADRESL  //8 bit reading
  
 
 USART.Write("Decimal : ", DecToStr(Variable), 13, 10)  // decimal number
 USART.Write("Decimal : ", DecToStr(Variable1), 13, 10)  // decimal number
 
 DelayMS(500)
Wend

User avatar
RangerBob
Posts: 152
Joined: Thu May 31, 2007 8:52 am
Location: Beds, UK

Post by RangerBob » Thu Dec 13, 2012 9:54 am

What device are you using?

Some of the newer devices have some really funky ADC set-ups which I imagine the standard ADC.bas module can struggle with.

be80be
Registered User
Registered User
Posts: 90
Joined: Mon Feb 23, 2009 2:15 am
Location: tn

Post by be80be » Thu Dec 13, 2012 1:46 pm

Pic18f2550 I want the 8 bit reading but i get double.

I'm thinking i've gone crazy can't see where it's reading wrong the adc bas has the right setting

User avatar
Senacharim
Posts: 139
Joined: Tue Aug 10, 2010 5:19 pm
Location: Ventura, CA

Post by Senacharim » Thu Dec 13, 2012 3:02 pm

What does the spec for the 18f2550 say the ADC returns? If it's a 10-bit number, then you'll just need to scale it down to 8 bits if you need 8 bits.

You can do it!
Surviving Member
Bermuda Triangle Battalion
from 2026 to 1992

Voted "Most likely to time travel"--Class of 2024.

be80be
Registered User
Registered User
Posts: 90
Joined: Mon Feb 23, 2009 2:15 am
Location: tn

Post by be80be » Thu Dec 13, 2012 4:12 pm

Ok I feel like a nut I set rightjustify to false that puts the right 8 bits in ADRESH 0 to 255 It reads like I should

Thanks for waking me up Senacharim they put me on some med's for diabetes I think it's slowed my thinking way down. :shock:

Post Reply