On 22 Oct 2011 at 13:22, Yigit Turgut wrote: > 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. That seems like a perfectly valid hardware configuration, would not expect = any=20 problems. You might try some software debugging to see what is going wrong.= ... is=20 Or it taking your motor into a region of operation you hadn't been in befor= e?=20 Unexpected interrupt? Perhaps compare with a potentiometer. =20 > 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. Still probably ok, but adding power supply filtering is a good thing. I wou= ld consider=20 a USB supply likely to be noisy (high freq) simply because it emanates from= a PC.=20 Lots of USB powered designs use a series ferrite inductor/choke/filter, or = else an=20 R/C filter. =20 > 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. >=20 > LDR is powered from I/O line and ADC is conducted from AN0. Good. RB4 was open drain output on many older PICs, but it is true push/pul= l on=20 your 18F2550. > 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. Under absolute maximum ratings you will see input and output clamp current = specs=20 of +/-25mA. You will also see spec for Voltage on any pin -0.3V to (Vdd + 0= ..3V).=20 Both specs relate to input protection diodes. Note that the absolute max sp= ecs only=20 guarantee the device will survive, does not guarantee that it will operate = correctly=20 under these conditions. As far as I can see there are no specs relating to = normal=20 use of the protection diodes (this has long been the case with PIC devices)= ,=20 therefore the burden is on the designer to do everything possible to minimi= se/avoid=20 current in these diodes. Take a look at BAT54S. Two Shottky diodes connected in series in a SOT-23=20 package, so you would only need two of them to get the 4 diodes to make a b= ridge.=20 For both packages connect anode to GND, cathode to +5V, the remaining two=20 common connections go one to each side of your motor (each PIC output). --=20 Brent Brown, Electronic Design Solutions 16 English Street, St Andrews, Hamilton 3200, New Zealand Ph: +64 7 849 0069 Fax: +64 7 849 0071 Cell: +64 27 433 4069 eMail: brent.brown@clear.net.nz --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .