Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

10 bit ADC to 1 bit ADC

Status
Not open for further replies.

rabhishek91

New Member
Hi everyone.
I am doing a project wherein i am reading analog values using inbuilt ADC of Atmega32A.
It is known that Atmega32A has 10bit ADC.
I don't need resolution of 10 bit for my project. So is there any way where i can read the values and get 1 bit output directly ? I know it can be converted using software but is there any alternative way wherein i can achieve this using hardware(like Setting bits or clearing bits)?

or

My main motto is to read 5V as logic 1 and 0V as logic 0. Can this be done in any other way ?

Please don't get me wrong if this is a silly question. I am new to this programming stuff.
Any help would be much appreciated.
Thanks in advance. :)
 
My main motto is to read 5V as logic 1 and 0V as logic 0.

All the pins work that way by default when the uController powers up. No extra configuration or code needed.
 
Every pin can be digital output, digital input, analogue input or a function for a module..

I believe the ATMEL MEGA series have DDxn register .. This configures the direction of the port... And the DDOV and DDOE registers set to digital operation.

I don't use this chip so take a look at the manual.. https://www.electro-tech-online.com/custompdfs/2013/03/doc2503.pdf
 
if what you are intending is "true" 10 to 1 bit round off, ie the threshold is in the middle, digital input wont do it as it will go HI 1 by the time the input reaches > 0.3V or 1V or so. if you are using 5V rail and you want to round off to HI 1 at 2.5V (threshold is in the middle) you can leave the ADC ON and only read the 5 higher bits of ADC register, if its not zero then you can assign a 1bit register as 1.
if HI(ADC, 5) then myVar = 1; else myVar = 0;
 
if what you are intending is "true" 10 to 1 bit round off, ie the threshold is in the middle, digital input wont do it as it will go HI 1 by the time the input reaches > 0.3V or 1V or so. if you are using 5V rail and you want to round off to HI 1 at 2.5V (threshold is in the middle) you can leave the ADC ON and only read the 5 higher bits of ADC register, if its not zero then you can assign a 1bit register as 1.
if HI(ADC, 5) then myVar = 1; else myVar = 0;

Yes sir. What you have told is right. I had never though of this. Thank you.
Sir i need to get the input continuously via sensor. So while configuring ADC. Which configuration do i need to select ? Is it Free running mode or Single conversion mode ? Can you please throw some light on this ?
 
What kind of sensor?

Like strain gauge. I need to monitor the voltage continuously. If it is below certain level then i'll perform some operation. I don't have idea about those 2 operating modes of ADC. I went through data sheet but it did not help me. . .:confused:
 
Single conversion works such that you start manually and then read the result wither by polling the status flag or by using an interrupt routine that gets called when the conversion is done. Free running is the same thing, but after the first converison is ready it starts doing another one.
It is up to you to decide the timing of what you're measuring and decide how often you want to read the value.
 
Single conversion works such that you start manually and then read the result wither by polling the status flag or by using an interrupt routine that gets called when the conversion is done. Free running is the same thing, but after the first converison is ready it starts doing another one.
It is up to you to decide the timing of what you're measuring and decide how often you want to read the value.

So if i need to read the value multiple times without setting the bit manually i need to go with free running mode right ?
 
its hard to tell whether you have to use free running, single, isr or poll based. it depends on your whole program and its/your intension. learning how each mode is done will give you some light. for begineer who dont have much time studying i recommend single conversion poll based because its safer and you need to explicitly request for it, one call = one ADC value and no mess around with isr. others may have different thought, so YMMV.
 
its hard to tell whether you have to use free running, single, isr or poll based. it depends on your whole program and its/your intension. learning how each mode is done will give you some light. for begineer who dont have much time studying i recommend single conversion poll based because its safer and you need to explicitly request for it, one call = one ADC value and no mess around with isr. others may have different thought, so YMMV.

Thanks for your reply sir. Seems like i have to go long way .
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top