# Photodiode work

##### 2016-10-16 16:00:00 +0000, 1 year and 12 months ago

Choose a distance from an obstacle and create/design a circuit so that all PORTB outputs LEDs turn on/off (you decide) if you are closer/further (you decide) than this distance.

• What happens to the output from the sensor? (explain in terms of photons and electron and V=IR)?
• Which is bigger, V+ or V- on the comparator?
• Is the comparator output high or low? (explain why)
• Include your code and explain what the code is doing and how it does it

I’ve chosen to make it so that the LED’s turn on if the distance is >10cm from the object.

What happens to the output from the sensor? (explain in terms of photons and electron and V=IR)?

When the obstacle is close to the sensor, more photons will arrive at the photodiode sensor from the IR emitter, therefore more electrons will conduct, thus more current is flowing. This can be explained with Ohms law, where $P_c$ is the (Photon count) amount of photons hitting sensor.

As we can see as I increases, so too must V.

Which is bigger, V+ or V- on the comparator?
Is the comparator output high or low? (explain why)

Logic 1 is defined as $\frac{+V_s}{2}$, and logic 0 defined as $\frac{-V_s}{2}$. In order for the comparator ouput to be high, $+V$ must be greater than $-V$ since,

Include your code and explain what the code is doing and how it does it.

The code starts off by setting 0x01 as an input on PORTC, this will be where the output of the 331 comparitor goes in. INIT checks the status of PORTC, if the output from the 331 is high, the code jumps to the LEDON label, which turns all LED’s on PORTA on and then loops back to INIT to check the output again, if the output from the 331 is low, the code jumps to the LEDOFF label, which turns all LED’s off and then loops back to INIT to poll inputs again.

Return?