Message Boards
Threads [ Previous | Next ]
Simple ADC
Simple ADC
2/23/10 7:45 AM
Hi,
I bought the PIC32 USB starter kit and now I want to use it as an simple ADC.
What I want to do is connect only one port to a external voltage source (about 6V max) and of course one ground connection. Then I want to convert this analog signal to a digital one which I can then send and display on my PC.
Is there anyone that has done a similar thing and will be willing to share their code?

Here is what I have:
Configure:
OpenADC10 (ADC_MODULE_ON | ADC_IDLE_CONTINUE| ADC_FORMAT_INTG16 | ADC_CLK_AUTO | ADC_AUTO_SAMPLING_ON,
ADC_VREF_EXT_AVSS | ADC_OFFSET_CAL_DISABLE | ADC_SCAN_ON | ADC_SAMPLES_PER_INT_1 | ADC_BUF_16,
ADC_CONV_CLK_INTERNAL_RC | ADC_SAMPLE_TIME_12, ENABLE_AN0_ANA | SKIP_AN2 | SKIP_AN3 |
SKIP_AN4 | SKIP_AN5 | SKIP_AN6 | SKIP_AN7 | SKIP_AN8 | SKIP_AN9 | SKIP_AN10 | SKIP_AN11 |
SKIP_AN12 | SKIP_AN13 | SKIP_AN14 | SKIP_AN15);

Interrupt Configurel:
ConfigIntADC10 (ADC_INT_ON | ADC_INT_PRI_0);

Steps:
EnableADC10();
AcquireADC10();
While(BusyADC10());
ConvertADC10();
While(BusyADC10());
variable = R
eadADC10(0);


Thanks
RE: Simple ADC
7/11/10 4:57 PM as a reply to StellenboschStudent .
I'm pretty sure you're going to need either a buffering amplifier or tap the signal through some type of voltage divider.

Unlike the 5V Pic's, this device can't read a full 5 volts on the ADC because you can't go above the supply voltage of the processor!

I'm currently working with the USB Starter Kit too, just got mine a few weeks ago and I'm still figuring it out. If I'm using the correct notation, Vdd is at 3.3Volts on that unit, so you can't go above that on the ADC. If you were to use a simple voltage "input- 5Kohm -- tap -- 5Kohm -- GND" divider, you could measure input voltages to 6.6 volts using system Vdd and Vss as ADC references.

Looks like your configuration flags are using ADC_VREF_EXT_AVSS, is that external? It still can't be above the Vdd though...