PICMicrocontrollerInputMethods

for Analog to Digital Conversion

See:

Questions:

RE:BILL&POOKIE CODE GEN WORK OR NOT FOR ME?
I am trying to use a 16f87x for adc of acs750 lca-050 corrent>voltage sensor, convert the adc to decimal 0.000-50.000, and display it on led/lcd. i want rms values for the current sampling.(1/sec or so maybe) (readable display) i have several pics, several c>v sensors, and very little understanding of the code req'd. i prefer 5 digit display, with leading zero's blanked before dp, dp after 2'nd digit(like this [xx.xxx]) sensor is 0v out for 0amp, 2.5v out for 50 amps. my supply is std +5vdc. kinda new to assembly, seriously interested. i use mplab & mpasm. plan to start with led, then port to lcd after it works. then maybe a volt meter with 50 amp current. should be a very handy instrument. so with that in mind.....bring it on.

KB3IFS

James Newton replies: Try it an see.+

+

what is the calculation to be done to get the digital output of an analog input in an adc in a microcontroller using adc inut voltage,adc reference voltage etc

James Newton replies: See The "Bill & Pookie" 10 bit A2D binary to decimal w/scaleing code generator+

+

• KILLspamkkouinis~NOSPAM~ at yahoo.gr asks: " i use pic 16f877 and i want to make 8-bit A/D conversion. Can i setup the internal A/D converter to take samples of 8-bit and not of 10-bit?" + Sure. Just throw away the bottom 2 bits. "thanks.but then have to multiply the result with 4 factor?" Err... are you saying that you need to multiply by four for some reason of your own or are you asking if disreguarding the last two bits requires a multiply by four?

If you just want an 8 bit A/D and you have a 10 bit A/D you just shift all 10 bits right two bit places. That is all. No need to multiply by 4. The original range of values is 0 to 2^10 or 1024. The new range of values is 0 to 2^8 or 256 which is exactly what you would get from an 8 bit A/D

If you want to multiply by four, well: *4 = left shift twice but in your case, just use the lower 8 bits. That is the same as takeing all 10 bits, shifting right two bits and then back left two bits.

I am working with the PIC16C745 and I can successfully get a2d to work, but only on 1 channel at a time. Is there a way to switch to a channel, do a single conversion, and then switch to another channel and repeat? When I try this the channels interfere with each other and I get bad results.

Yes, "channels interfering" is a common problem. I'm pretty sure you have a "settling time" problem. When you switch from one channel to another, you *must* wait a certain amount of "settling time" before starting the next conversion. Please do *all 3* of these: (1) After the code switches from one channel to another, *delay* the full Tacq time, and only then start the conversion. (Typically the ADC routine does: Start ADC, wait for end of conversion, Switch to next channel, Read ADC, Store value. Then return and let the rest of the program go while waiting for this new channel to settle). (2) Buffer your analog signals with an op amp (running off the same power supply as the PIC), so the output of the op amp is directly connected to the PIC analog input pin. And (3) Read the "Analog to Digital" section of the data sheet one more time to make sure I didn't miss anything. -- David Cary

+

• One thing I found in trying to switch between multiple analog inputs with a 16F690 was that some of the example files from microchip had a mistake in the wait for conversion complete -- btfss instead of btfsc when checking for the clear of the "GO" bit.+

PICList post "LM335" Interesting idea for expanding A2D resolution. +

 file: /Techref/microchip/a2d.htm, 7KB, , updated: 2011/8/19 23:20, local time: 2024/9/9 08:05, TOP NEW HELP FIND:  44.220.181.180:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?Please DO link to this page! Digg it! / MAKE! PIC Microcontroller, Analog to Digital Conversion

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.

Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
 Did you find what you needed? "No. I'm looking for: " "No. Take me to the search page." "No. Take me to the top so I can drill down by catagory" "No. I'm willing to pay for help, please refer me to a qualified consultant"

 PICList 2024 contributors: o List host: MIT, Site host massmind.org, Top posters @none found - Page Editors: James Newton, David Cary, and YOU! * Roman Black of Black Robotics donates from sales of Linistep stepper controller kits. * Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters. * Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated! * Contributors: Richard Seriani, Sr.

.