go away spammer

Author Topic: How does PIC understand values coming from LDR's ?  (Read 3433 times)

0 Members and 1 Guest are viewing this topic.

Offline brightjoeyTopic starter

  • Jr. Member
  • **
  • Posts: 11
  • Helpful? 0
How does PIC understand values coming from LDR's ?
« on: December 12, 2010, 01:17:35 PM »
Hi, currently in my final years and I'm on an deadline for my project. :(

I'm currently building a photovore robot using PIC 16F877Aas the brain and will follow light wherever it goes. I would like to know is how does the Microcontroller pick up on the signal sent by the 2 photoresistor? Like how does it compare which light source is more?

In some guides I read about a device called ADC (Analog to Digital Conversion). Is it relevant for my project?
In practically as well, Does the leg of the LDR directly connects to the pins of the PIC?

Currently referencing my project with the step-by-step 50$ robot tutorial here with some luck. As I do not see them use any ADC so I'm somewhat confused.

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 99
Re: How does PIC understand values coming from LDR's ?
« Reply #1 on: December 12, 2010, 02:50:24 PM »
I think that on the $50 bot the LDR's just go into a digital port on the processor and are detected as high or low.
I don't find and source code for the $50 bot the confirm this but in the $50 bot Sharp IR add-on there is some code for initializing the ADC.
Do understand that the $50 bot uses an AVR processor and not a PIC processor. The $50 bot could easily be built with a PIC but the wiring diagram and code would be different.

The LDR circuits could go into an port set-up as an ADC (on an AVR or a PIC). In this manner the code would then start a conversion then read a binary value that represents the voltage on the input pin of the ADC.

Since the way you worded the question on ADC's and the PIC16F877 I'd guess you are just beginning to use PICs. The Data sheet is vital to know how to do this. In addition do down load the Mid-Range Family Reference Manual from Microchip as this gives some better explanations on how the PIC works.
For a good tutorial check:
http://www.gooligum.com.au/tutorials.html
and do start at the beginning with the Base-line PICs as later lessons build on the earlier lessons. To work through these use the MPLAB SIMulator instead of buying PICs. There are lessons on using the PIC's ADC.

Good luck, have fun and come back here if you have difficulty understanding something.

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: How does PIC understand values coming from LDR's ?
« Reply #2 on: December 12, 2010, 04:35:03 PM »
Hi,

If you want to compare two LDR's, you could put them in series like a voltage divider and measure the node where they connect, opting for half the A/D-C reference voltage.
This will need LDR's with a sufficiently high resistance (in the brightest light they see) to keep the current to manageable levels, or they'll die when brightly lit!
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline brightjoeyTopic starter

  • Jr. Member
  • **
  • Posts: 11
  • Helpful? 0
Re: How does PIC understand values coming from LDR's ?
« Reply #3 on: December 15, 2010, 02:09:59 PM »
Hi,

If you want to compare two LDR's, you could put them in series like a voltage divider and measure the node where they connect, opting for half the A/D-C reference voltage.
This will need LDR's with a sufficiently high resistance (in the brightest light they see) to keep the current to manageable levels, or they'll die when brightly lit!


Hi, I decided to dump the whole idea of a/d-c in my microcontroller as in the first place, I don even know where to start! It was a mistake for me to choose microcontroller at the 1st place so I planned to keep my programming really simple.

in the end, I decided to use 3 LDR connected in different parts of the robot( ie: left, right ,middle) and the programming in the Microcontroller is right.

Left LDR sense light = car turns left
Right LDR sense light = car turns right
Middle LDR sense light = car moves forward
etc..




I tested it out with LED's and it worked fine like the steps mention above. but when I replace the motor( with H-bridge) directly with the LED's, the "move right" works fine, the "move forward" moves surprisingly slow, and the "move left" doesnt work at all!!

So I am wondering if there's anything else I could add.. Is LM339 a vaiable option.

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 99
Re: How does PIC understand values coming from LDR's ?
« Reply #4 on: December 15, 2010, 03:36:30 PM »
Could you post a schematic (wiring diagram) of how you have the LDR's and motors connected. Then we should be able to help.

Don't give up on a microcontroller completely. Do more reading to learn how to program but continue working on the LDR controlled Bot.

Quote
I don even know where to start
Start with the tutorial I posted a link to. If you do a couple of lessons a week then you will be ready to use the ADC in the PIC in a few months time. I spent 6 months learning PICs before using the first one in a project. Just don't give up.

 


Get Your Ad Here