Comparing between 4 analogue inputs using MikcroC

Thread Starter

kamel2913

Joined Mar 6, 2015
43
Hello,

I'm working on a project : solaire tracker, this projet have 4 light sensors, this 4 sensors has analogue outputs, my probleme is I couldn't figure out how to compare between the output voltage of this captors, for exemple, using MikcroC I want to know which gives more voltage and which gives low voltage, and how to compare and using conditions, for exemple if(cap1>cap2){do somthing}....(cap1= output voltage of the captor 1, cap2= output voltage of the captor 2)

as I know for MikcroC, I can compare only digital outputs, so there's anyway that I can compare analgue output voltage?

sorry for my English, thank you for your time.
 

JohnInTX

Joined Jun 26, 2012
4,787
What microcontroller are you using? As dannyf says, get one with a multi-channel ADC (even low cost PICs have one), read channels in sequence and store the values. Then look through the data to see which is most/least etc.
 

shteii01

Joined Feb 19, 2010
4,644
You have choices.

Like others said, you can use microcontroller that has multiple analog to digital converters (ADC). This is a digital approach. You will take analog values, digitize them, the let software loaded into the microcontroller do the comparing. Arduino works pretty well for this and there is nice tutorials on how to use ADC on Arduino boards.

Side note. Make sure output of the light sensor is withing acceptable range of the ADC input. You don't want to send 10 volts from light sensor to 5volt ADC.
 

Thread Starter

kamel2913

Joined Mar 6, 2015
43
thank you guys for your replies, I'm using PIC16F877A, do I have to write any instructions in my code to active the ADCs ports?
 

JohnInTX

Joined Jun 26, 2012
4,787
thank you guys for your replies, I'm using PIC16F877A, do I have to write any instructions in my code to active the ADCs ports?
Of course you do. MikroC provides library routines for the ADC. Read up and have at it. Be sure to read the PIC datasheet sections on configuring the ADC particularly ADCON0, ADCON1 and the TRIS registers for your input pins.

If you need help, post a schematic and your code and describe any problems you are having.

Good luck.
 
Last edited:

ErnieM

Joined Apr 24, 2011
8,377
Given the time, the date, and your location the position of the sun is a known quantity. Mariners have used this fact for hundreds of years to back figure where they are. If you compute the position of the sun you eliminate the sensors and several other sources of error, like clouds, like chasing the sun after it set, cloud cover, and others.

You would have to calibrate the array position on occasion, as you would anyway with your sensors.
 
Top