Discuss Need tons of help asap!!s.o.s in the C Programming forum on Dev Shed. Need tons of help asap!!s.o.s C programming forum discussing all C derivatives, including C#, C++, Object-C, and even plain old vanilla C. These languages are low level languages, and used on projects such as device drivers, compilers, and even whole computer operating systems.
Posts: 5
Time spent in forums: 48 m 38 sec
Reputation Power: 0
Need tons of help asap!!s.o.s
Hello guys,
im an Industrial Informatics student and im working on a project concerning an automatic moving photovoltaic. I use light sensors for motion. Automatically it has to find the less sensor value and moves to that position .. Im using 20 sensors.. I have difficulty in reading the sensors as they use Adc...
Using ATmega 16A
Atmel Studio 6.0
I really need ur help guys if its possible!!Thanks
Posts: 3,354
Time spent in forums: 1 Month 2 Weeks 3 Days 8 h 21 m 53 sec
Reputation Power: 383
Do you have a cute little robot with wheels and motors and cpu and beeping and blinking lights (I hope not) and stuff? Would an ATmega forum be more useful to you?
__________________
[code]Code tags[/code] are essential for python code!
Posts: 5
Time spent in forums: 48 m 38 sec
Reputation Power: 0
nop , just a piece of wood/steel..no wheels & stuff. Just a photovoltaic with sensors / stepper motors etc. AVR Forum didnt help cuz they dont say anything about programming!
Posts: 3,836
Time spent in forums: 2 Months 3 Weeks 2 Days 16 h 15 m 5 sec
Reputation Power: 1774
The first thing I would suggest is you look through the atmel application notes and review any of them which mention ADC, especially any which focus on basic operation.
> Im using 20 sensors.. I have difficulty in reading the sensors as they use Adc...
Start small and simple.
Using just one sensor, write a program that turns on a LED when the sensor is exposed to light, and turns off the LED when there is no (or less) light on the sensor.
Posts: 6,125
Time spent in forums: 2 Months 2 Weeks 3 Days 16 h 57 m 4 sec
Reputation Power: 1949
Is your problem with the ADCs? Just what is the problem? Do you not know how to interface with them? The data sheets should tell you that. Do you not know what to do with the digital value you receive from them? Well, what's the conversion function? Just exactly what is the problem that you're having?
In one product I worked on (computerized greenhouse controls), we had sensors that were hooked up to ADCs which were read by microprocessors (more primitive than 8051s, so that was purely in assembly) and then those values were transmitted back to a PC which converted the readings into temperature, humidity, light level, whatever. In most cases, it was a simple linear formula of 0 to 5 volts corresponding to digital values from 0 to 255 which in turn corresponded to readings from some minimum to some maximum. In the case of one humidity sensor, the curve was not linear so we had to use a look-up table. What is the conversion formula for your sensors? What is keeping you from simply applying that formula?
Posts: 5
Time spent in forums: 48 m 38 sec
Reputation Power: 0
@salem
Im gonna post the program in a while
@dwise1_aol
Its my first time "playing" with ADCs , reading sensors and etc, so yea basically i dont know how to interface with them. Is it possible to add u on skype?
Posts: 58
Time spent in forums: 1 Day 17 h 52 m 2 sec
Reputation Power: 2
The infinite loop just causes the CPU to loop through the exact same code indefinitely until the power is shut off. That is a normal technique for embedded code.
Is there a way you can tell if adc_init() has properly initialized the ADC's ?
And what about adc_read(i) ? Is there a way you can either print out a value or illuminate an LED when it returns some value but extinguish the LED when it returns some other value? That would give you an indication of whether or not it is properly reading an analog voltage that you could manually change for testing.
Posts: 58
Time spent in forums: 1 Day 17 h 52 m 2 sec
Reputation Power: 2
Google "AVR AT Mega16A enable ADC" for lots of tutorials on using the ADCs in this CPU. You probably forgot something. I don't know what it is. Trying out the tutorials might help you figure out the missing link. If the ADCs are interrupt-driven, it is also possible something in the code masks off all the ADC interrupts except for the two that are working. Investigate that possibility.
P.S. You need to figure out whether the ADC interrupts are hardware interrupts or software interrupts. If they are software interrupts, then it is a distinct possibility that some ADC interrupts are disabled. If they are hardware interrupts, then you will need to investigate further.
Last edited by EEmaestro : October 29th, 2012 at 11:21 AM.