Deciphering analog signal? (comparators? schmitt triggers?)

Thread Starter

silentwf

Joined Aug 25, 2010
2
hi everyone,
i'm new to electronics. i've been trying to get my microcontroller (atmel at89s51) to read readings from a LDR. i have a LED light source that feeds light to the LDR and will be interrupted by black stripes (well, simply speaking, an encoder).
so what i'm doing now is passing a 5v to the LDR and have the LDR control a NPN transistor, then have the output of transistor directed back to my controller.
now the problem is that i get voltages that are within the threshold value of the controller, and it causes my controller to read random values.
i've searched online and found out that i'll either need comparator or a schmitt trigger. from what i'm reading (wiki), it seems like a schmitt trigger is a better option. is this correct?
 

Papabravo

Joined Feb 24, 2006
21,225
I don't understand what you are saying. Words are a REALLY crappy way of describing a circuit. Help will be forthcoming if you post a schematic. That is your only hope of progress on this problem.
 

SgtWookie

Joined Jul 17, 2007
22,230
Well, Schmitt triggers can turn arbitrary levels into logic levels. For example, once a "high" threshold has been passed, the input must descend below the "low" threshold in order for the output to toggle states.

Keep in mind that LDRs (like CdS sensors) have a relatively slow response time. If your input will cycle often, you will need something more on the order of a phototransistor. You should also consider photointerruptors; they are like optocouplers, but you can pass a light-blocking element between them to turn the output on/off.
 

Thread Starter

silentwf

Joined Aug 25, 2010
2
Ok, sorry about using words to desribe what I need, but the schmitt trigger is what i was looking for. Thank any ways.

@SgtWookie: by "relatively slow" response time, by how slow do you mean? right now i'm using it as the recieiving end of my encoder, and it seems fine (i guess cuz my motor spins really slowly). I will take a look into those parts that you mentioned.
 
Top