# how to detect current using PIC16F877A

Discussion in 'The Projects Forum' started by amyken, Apr 10, 2009.

1. ### amyken Thread Starter New Member

Apr 10, 2009
3
0
the circuit having parallel lamps. if one of the lamp is break down, the value of current will smaller than usual. the output of microcontroller will give warning when the current is smaller than usual. how to detect the decrease of current using PIC 16f877A? please help me.

2. ### t_n_k AAC Fanatic!

Mar 6, 2009
5,448
790
You first need to create a signal proportional to the total lamp current - such as via a series "shunt" resistor. If the shunt is 1Ω and the current is (say) 0.1A then you would have a 0.1V signal.

Then you could use an external comparator circuit to detect the "shunt" voltage drop to the value corresponding to the one lamp only state. The comparator output could then be used as input to one of the PIC's digital input lines. Code reads the digital input line to detect the change.

Alternatively, you could feed the same shunt voltage as an input to the PIC's A-to-D converter module. After reading in the voltage, use your code to determine the current level and hence deduce the lamp states.

This is a relatively simple task to be committing to the substantial power of the PIC - much like breaking peanuts with a hammer. Presumably this is more about gaining experience with PIC's.

3. ### mik3 Senior Member

Feb 4, 2008
4,846
70
What lamps?

Is their power supply regulated?

4. ### amyken Thread Starter New Member

Apr 10, 2009
3
0
car lamp

the power supply for PIC had regulated to 5V

5. ### mik3 Senior Member

Feb 4, 2008
4,846
70
You can use a 0.5R resistor in series with each lamp and measure the voltage drop across that resistor.

If the voltage drop equals zero then the lamp is burned.

Another option is to use one resistor and measure the total current of the lamps but this may give you false results due to variations on the applied voltage across the lamps (if the lamps draw a small amount of current). However, if the lamps draw above 0.5 Amps then you can do it with one resistor safely.

6. ### amyken Thread Starter New Member

Apr 10, 2009
3
0
thanks for helping me.
i'll try simulate first and will tell the result