On Sat, Oct 22, 2011 at 1:27 AM, IVP wrote: > I still don't understand what you mean by > > "If I power the LDR from let's say RB4 port, how will this effect > the stability of the system ? I am not in a position to dedicate a > power supply for LDR" > > What is the stability you're concerned about and how would any > instability come about ? I am concerned about this because when I connect one pin of LDR to VDD (other pin goes to AN0 and to ground through a resistor), there is obvious malfunction in the system. Any port is powered from VDD and at first sight it seemed like a reasonably logical argument to question. > > If you power the LDR from a port pin then any noise on Vcc/Vss > will get to it, so filtering Vcc/Vss and the source of the noise seems > the obvious answer > > Are you using the LDR as part of a divider, measured by the PIC > or an opamp or some other analogue device ? > > Joe LDR is as divider, I believe noise is minimum because psu is usb port of a notebook. Also tried the same with a 5.1V dc adapter which yielded to identical results. I am aware that long time operation at 5.1V might cause some malfunction. On Sat, Oct 22, 2011 at 2:48 AM, Brent Brown wro= te: > On 21 Oct 2011 at 18:57, Yigit Turgut wrote: > >> LDR is light dependent resistor. When I set RB4 high to feed LDR, >> current it drains will change constantly and this may cause >> instability in overall operation due to overdrive of LDR. It has dark >> resistance of 4 mega ohms and bright resistance of 5k ohms. > > Like we have been asking, what "instability" fears do you have? > > If you has a single LDR between +5V (or PIC output providing +5V) and gro= und > then max current drain is: 5V/5kOhms =3D 1mA, or power is 5V^2/5kOhms =3D= 5mW > > Is that too much current for your power supply? It is not too much curren= t for most > PIC I/O port lines, except perhaps RB4... as previsouly mentioned have yo= u > checked to make sure RB4 is not an "open drain" output for your particula= r PIC? > You can not source current from an open drain output (cannot provide +VE = output > voltage or current), you can only sink current (when turned on current, f= rom a > source external to the I/O pin, flows into the PIC I/O pin to GND). > > But anyway, you can't measure current directly with a PIC I/O line. Volta= ge othe > other hand you can measure with a PIC ADC (or some other tricks that are = slightly > more complicated). So then you need fixed value resistor in series with y= our LDR, > thus giving a voltage divider: the voltage at the node of the LDR and fix= ed resistor > will vary with varying resistance of the LDR. RB4 is different from other ports where it doesn't contain a schmitt trigger. Other than that, surely, it's TTL. I didn't ask because RB4 is different in structure, it's a coincidence that I use it due to pcb limitations. LDR is powered from I/O line and ADC is conducted from AN0. On Sat, Oct 22, 2011 at 2:56 AM, Brent Brown wro= te: >> > if the motor produces back EMF (i.e. no electronics in it, just brushe= s) >> > then I think you will be very concerned. >> >> There is no observable problems but I guess I will attach a flywheel >> diode to motor. Thanks for the suggestion. > > A single flywheel diode is suitable if motor operated in one direction on= ly... but you > mentioned the motor is connected between two PIC I/O lines, presumably so= you > can operate the motor in forward or reverse. A single diode would be forw= ard biased > in one direction - shorting the motor. So then you need 4 x diodes in a b= ridge > configuration. And they need to be Schottky diodes to operate before the = PICs in > built protection diodes operate. > > What about over current protection if the motor stalls? Yes that's correct. RB1 and RB2 provide synchronized high/low levels in order to rotate the motor to required position/direction. Obviously, applying flywheels to both ends will result in no operation. Datasheet doesn't mention about the specification of the protection diodes used, what would be the equivalent diode (seperate component) to mcu's protection diodes ? It's a 18f2550 I am playing. --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .