Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 10th March 2007, 04:28 PM   (permalink)
Default Microcontroller as ADC

Hi guys can u plz post the ckt of microcontroller used as an ADC ?

If possible the code as well ..

plz help its urgent ...
microcare is offline  
Old 10th March 2007, 04:37 PM   (permalink)
Default

Check my tutorials!.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 10th March 2007, 10:11 PM   (permalink)
Default

okay, relax! on which micro controller are you working..?

i suppose it is a 8051 cause it doesn't have an ADC .. right?
__________________
Ibrahim Kamal
check my electronics and robotics page: http://www.ikalogic.com/
ikalogic is offline  
Old 10th March 2007, 11:32 PM   (permalink)
Default

If you’re going down the PIC Micro road, maybe this could help



Click here to watch this circuit in action

This circuit is designed to take 2 ADC samples and display them on an LCD, heres the program;

Code:
Device 16F877
Declare XTAL 4

DECLARE ADIN_RES 10                 ' 10-bit result required
DECLARE ADIN_TAD FRC              ' RC OSC chosen
DECLARE ADIN_STIME 50             ' Allow 50us sample time

Declare LCD_TYPE 0                     ' Type of LCD Used is Alpha
Declare LCD_DTPIN PORTB.4         ' The control bits B4,B5,B6,B7
Declare LCD_RSPIN PORTB.2         ' RS pin on B2
Declare LCD_ENPIN PORTB.3         ' E pin on B3
Declare LCD_INTERFACE 4             ' Interface method is 4 bit

PORTB_PULLUPS True

Dim Result1 As Float
Dim Result2 As Float

Dim Last_Result1 As Float
Dim Last_Result2 As Float

Symbol Input1 = PORTA.0
Symbol Input2 = PORTA.1

TRISA = %00000011                     ' Configure AN0 (PORTA.0+1) as an input

ADCON1 = %10000000                 ' Set analogue input, Vref is Vdd

Main:

Result1 = ADIN 0                             ' Grab A0's digital value
Delayus 1                                       ' Allow internal capacitors to charge
Result2 = ADIN 1                             ' Grab A1's digital value

Result1 = Result1 * 5 / 1023              ' Scale it to volts
Result2 = Result2 * 5 / 1023                 '

If Last_Result1 <> Result1 Then       ' Check if value has changed
    Print At 1, 1, Dec2 Result1, "V "       ' If it has, display new data
    Last_Result1 = Result1                     ' and update last value
EndIf

If Last_Result2 <> Result2 Then        ' Check if value has changed
    Print At 2, 1, Dec2 Result2, "V "        ' If it has, display new data
    Last_Result2 = Result2                      ' and update last value
EndIf

Goto Main                                        ' Loop for ever
The output on the LCD would look like this (keep in mind that the voltages are for every changing in the above circuit)



If your using voltages over 5V, the logic device must be protected from them with a simple voltage divider similar to this;



Now the voltage will be reduced by 50% and you can easily sample this and multiply the sample result by two too scale it back up.

10 Bit ADC has a resolution of 0.0048 Volts, its more than enough for many applications.
__________________
Spency.

PIC Micro's - Your mind is the limit

PIC's and interfacing with other devices - a PIC Basic Guide @ digital-diy.net
gramo is offline  
Old 11th March 2007, 05:26 AM   (permalink)
Default

im working on 89c051
microcare is offline  
Old 11th March 2007, 08:57 AM   (permalink)
Default

Quote:
Originally Posted by microcare
im working on 89c051
see that's what i was expecting.. if you really want to use the 89c51.. well, you can build a ADC out of a R/2R network DAC, 2 opamps and a uC..

The idea is to let the micro generate numbers from 0 to 255, feed them to the R/2R DAC, generating voltages from 0 to 5v, and at each step compare the o/p with your voltage to be measured using the second op-amp (configured as a comparator).

you will get a '1' out of the second op-amo when your counter reach the measured voltage. here, stop counting, and the last counted number (btw 0 and 255) is the digital value propotional to the analog input.
__________________
Ibrahim Kamal
check my electronics and robotics page: http://www.ikalogic.com/
ikalogic is offline  
Old 11th March 2007, 09:11 AM   (permalink)
Default

Quote:
see that's what i was expecting.. if you really want to use the 89c51.. well, you can build a ADC out of a R/2R network DAC, 2 opamps and a uC..

The idea is to let the micro generate numbers from 0 to 255, feed them to the R/2R DAC, generating voltages from 0 to 5v, and at each step compare the o/p with your voltage to be measured using the second op-amp (configured as a comparator).

you will get a '1' out of the second op-amo when your counter reach the measured voltage. here, stop counting, and the last counted number (btw 0 and 255) is the digital value propotional to the analog input.
OR
Buy a ready made ADC chip
Ayne is offline  
Old 11th March 2007, 11:12 AM   (permalink)
Default adc

chek it. if u find it useful i will send u code

Last edited by abbas1707; 12th March 2007 at 01:25 PM.
abbas1707 is offline  
Old 11th March 2007, 11:28 AM   (permalink)
Default

i think the author of the thread wanted to use "a 8051 µC as an ADC" right?
__________________
Ibrahim Kamal
check my electronics and robotics page: http://www.ikalogic.com/
ikalogic is offline  
Old 11th March 2007, 12:09 PM   (permalink)
Default

hi gramo,

Is the 2*100k resistive divider input to the 16F877 ADC a mis-type.
Considering the specified maximum adc input impedance of 10K.

Eric
ericgibbs is offline  
Old 11th March 2007, 12:28 PM   (permalink)
Default

Quote:
Originally Posted by ericgibbs
hi gramo,

Is the 2*100k resistive divider input to the 16F877 ADC a mis-type.
Considering the specified maximum adc input impedance of 10K.
It's certainly a mistake, maximum source impedance should be something like 2.5K - otherwise accuracy can suffer, and reading speed is greatly comprimised.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 12th March 2007, 07:47 AM   (permalink)
Default

Sorry about that, it was a quick click in paste, wasn’t actually think that far into it

This is more like it



So what’s the most efficient/accurate impedance for ADC samples with PIC’s?
__________________
Spency.

PIC Micro's - Your mind is the limit

PIC's and interfacing with other devices - a PIC Basic Guide @ digital-diy.net
gramo is offline  
Old 12th March 2007, 08:35 AM   (permalink)
Default

Quote:
Originally Posted by gramo
So what’s the most efficient/accurate impedance for ADC samples with PIC’s?
Keep the source impedance less than 2.5K as the datasheet says, the delay is caused by the charging time of the internal capacitor for the sample and hold.

For an experiment, set up two analogue inputs, and read and display them both in a continuous loop - easy in your BASIC compiler. Take one pin to 5V and one to 0V, the first should read 255 and the second zero.

Now connect the pins via 100K resistors, and see what readings you get - they won't be correct any more, add a time delay after each reading, adjust the delay until both read correctly again. Try it with 1Meg and 10K resistors, and meausre the difference! - post your results here, it could be informative.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 12th March 2007, 02:00 PM   (permalink)
Default

I'd be curious as well.
__________________
"Because I be what I be. I would tell you what you want to know if I
could, mum, but I be a cat, and no cat anywhere ever gave anyone a
straight answer, har har."
Sceadwian is offline  
Old 13th March 2007, 05:08 AM   (permalink)
Default

Guys,

let's say I want to sample voltages in a range of 40V using pic. I need to reduce the voltage to 5 volts max. You were using voltage dividers, but is there another way of doing that without making a path between Vdd and Vss? Also, according to pic datasheet, the resistance of the source should be less then 2.5k in order to sample it properly, in the case of gramo's post, is the resistance 1k||1k = 0.5k (grounding Vdd like large signal analysis for xtors)?

Thank You.
BOBKA is offline  
Reply

Bookmarks

Thread Tools
Display Modes



Similar Threads
Title Starter Forum Replies Latest
Microcontroller interface with ADC revjam Chit-Chat 4 1st August 2008 09:21 AM
how to interface a ADC 0809 TO MICROCONTROLLER AND THEN MICROCONTROLLER TO DECODER praneeth22 Micro Controllers 1 9th March 2007 07:20 PM
clock source for microcontroller stk500 hani_a Micro Controllers 0 22nd June 2004 12:37 AM
Connection of Siemens c167 microcontroller to peripherals. Roslan Electronic Projects Design/Ideas/Reviews 3 23rd March 2004 07:52 PM
Interfacing a microcontroller with a modem matt_d82 General Electronics Chat 3 21st March 2004 03:43 AM



All times are GMT. The time now is 07:11 AM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker