View Full Version : adcon problems with adcin
mbw123
- 2nd January 2007, 19:00
Hello everyone,
I have a simple question: I am trying to use the adcin command to get input from a pot source on a 18F4550. I am hacing problems with the defines and setting it up. I assume I want to use "DEFINE ADC_BITS 10" but I am unsure about what else I should do.
DEFINE ADC_SAMPLEUS 10 '(or 50?) What exactly is this?
DEFINE ADC_CLOCK 3 'I am assuming I should use this because I am using a crystal?
And the biggest mystery...the adcon.
I looked at the datasheet for the PIC18F4550 on adcon1 and I don't really understand it. Can anyone help me here or give me a link to a web page or something? Thanks for your help.
-Mike
mister_e
- 2nd January 2007, 19:15
Wich channel you want to read?
Wich OSC speed?
mbw123
- 2nd January 2007, 19:39
I would like to read all channels. And I am using a 20mHz crystal, although I know I need a DEFINE OSC 20 for that. What I don't understand is how to read the tables in the datasheet and how to set the defines for adcon and adcin. Thank you for your response.
-Mike
mister_e
- 2nd January 2007, 19:55
OK then, so you're not going to use the USB feature in?
Let me know, i have some spare time today... to be honest, i'm out of solution to fix my actual Projects bugs.... ARRGGHHHH! Seems i need a break ;)
Pesticida
- 2nd January 2007, 20:14
Hi,
I use this:
DEFINE OSC 4
DEFINE ADC_BITS 8
DEFINE ADC_SAMPLEUS 50
' Set clock source (3=rc)
DEFINE ADC_CLOCK 3
......................
for counter2 = 0 to 7
SUM = 0
FOR COUNTER1 = 1 to 10
ADCIN counter2,A[counter2]
PAUSEUS 24 'Pause between ADCINs
SUM = SUM + A[counter2]
NEXT COUNTER1
A[counter2] = SUM/10
And is working very good.
Regard.
mbw123
- 2nd January 2007, 21:15
I might use the USB feature... I don't know if I need the feature right now though.
I think I will use this code...but are the adc_bits and adc_sampleus numbers arbitrary?
DEFINE OSC 4
DEFINE ADC_BITS 8
DEFINE ADC_SAMPLEUS 50
' Set clock source (3=rc)
DEFINE ADC_CLOCK 3
And mister_e I could use your expertise on a few questions: I am using an infrared emitter and the strength of that beam will be measured by an infrared receiver (which will be measured with the adcin command). However, I cannot seem to find an infrared receiver. Do you know of any online stores that sell them?
The other thing I need are really cheap gearhead motors. Any suggestions?
Last question: If I do end up using the USB feature, what software could I use to receive USB data (or should I write my own) which I can then process?
I appreciate your help and wish you luck with your own projects.
-Mike
mbw123
- 3rd January 2007, 22:15
Does anyone have a link or know of an article about this where I could go to?
-Mike
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.