Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
If you have a current upto 150mA you can use a low resistor. With a know resistor and the voltage drop generated by it you can read that with an ADC and get a reading of that voltage and therefore know your current.
:arrow: At 150mA and with a resistor of 10 ohms you should have a voltage of 1.5V. And 8-bit ADC with a voltage reference of 1.5V will read values in incremets of 5.88mV so if your current is 10mA, then you have a 0.1V which will give you a value of 17. A 150mA will give you a value of 255 and a 0mA will give you a value of 0.
:idea: If you feed this into a microcontroller you could figure out you current depending on the value of the ADC and have a formula for translating the value into actual current values.
:!: I didn't realize that you were using a PIC16F877... this PIC has an internal 8 or 10 bit ADC. Just program it so that you have the ADC give you the value you need, and then use it to "shut off" the current if overpass the 150mA or something like that.