adc on PIV 18f2553

General discussion relating to the library modules supplied with the compiler

Moderators: David Barker, Jerry Messina

Post Reply
speed64
Registered User
Registered User
Posts: 13
Joined: Mon Jul 09, 2007 10:45 am
Location: Germany Barßel

adc on PIV 18f2553

Post by speed64 » Thu Jul 10, 2008 8:14 pm

I have this pic with the example from SF tested / programmed?. But it does not work. With a pic 18F2550 does it work. Do anybody have any idea?
Thank you.

RKP
Registered User
Registered User
Posts: 82
Joined: Mon Oct 22, 2007 3:14 pm
Location: Maryland

Post by RKP » Fri Jul 11, 2008 3:16 am

speed64,

Check out this post http://www.sfcompiler.co.uk/forum/viewt ... highlight=

Like you I had a problem with the ADC but on the PIC18F2455.

Changing the lines in 18F2553.bas

from: #const _adc = $05 // 5 ADC channels available
to: #const _adc = $0A // 10 ADC channels available

may solve your problem.

Both of these USB PIC's have 10 ADC inputs, not 5 ADC inputs that their includes have defined.

Hope this helps,

RKP

speed64
Registered User
Registered User
Posts: 13
Joined: Mon Jul 09, 2007 10:45 am
Location: Germany Barßel

Post by speed64 » Fri Jul 11, 2008 7:59 am

Thanks RKP
But now is number 2047 shown and not 4096. I use easy pic 3 on AN2 5V.
There is no jumper on port A.

RKP
Registered User
Registered User
Posts: 82
Joined: Mon Oct 22, 2007 3:14 pm
Location: Maryland

Post by RKP » Fri Jul 11, 2008 10:51 am

speed 64,

Glad to hear you got the ADC module working.

Are you sure have 5V on AN2? Can you measure that?

Also show you code

speed64
Registered User
Registered User
Posts: 13
Joined: Mon Jul 09, 2007 10:45 am
Location: Germany Barßel

Post by speed64 » Fri Jul 11, 2008 11:37 am

RKP,
On the entrance AN2 do I have 0 - 5V. The value by 0 - 2,5V is 0 - 2047. The value by 2,5 - 5V stays by 2047. I have tested AN3 too, but it is the same. The programm runs in a loop and reads in AN2. The programm changes Dec TOSTR and shows it on the LCD.

CS
Posts: 127
Joined: Thu Nov 02, 2006 9:14 am

Post by CS » Fri Jul 11, 2008 5:38 pm

Hallo,

I have had nearby the same problems. David wrote:
You probably need to take a look at the datasheet, there are quite a few values to play with. You could start by trying something like:

Code: Select all

SetBaudrate(br19200) 
ADC.SetConvTime(FOSC_8) 
Repeat 
   ...
Hope this helps

CS

speed64
Registered User
Registered User
Posts: 13
Joined: Mon Jul 09, 2007 10:45 am
Location: Germany Barßel

Post by speed64 » Sat Jul 12, 2008 7:24 am

Hello cs and RKP

now everything functions, as it is. The best value is (FOSC_4). With
this value it displays directly 5V. With the other values I come on
4,99V. These adjustments function also with the PIC 18F4553

Again thanks for the fast assistance. Speed 64

Post Reply