Searching \ for '[PIC] Feeding LDR from RB Outputs' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/microchip/ios.htm?key=output
Search entire site for: 'Feeding LDR from RB Outputs'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] Feeding LDR from RB Outputs'
2011\10\21@033400 by Yigit Turgut

picon face
Hello everyone,

I have a sub-project where I continuously monitor LDR output  and
drive a mini motor according to the algorithm. Motor I drive is
manufactured by NIHON MINI MOTOR CO LTD and is perfectly driven by RB0
and RB1 digital outputs (no other components, directly PIC-to-Motor).
My concern is  ; 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 thus I am seeking practically
effective workarounds.

Have a nice day

2011\10\21@055209 by Graham Lewis

flavicon
face
If you are not concerned about the spectral response would a small solar
cell meet your requirements?

Having a great day thank you

{Original Message removed}

2011\10\21@060021 by Brent Brown

picon face
On 21 Oct 2011 at 10:33, Yigit Turgut wrote:

> Hello everyone,
>
> I have a sub-project where I continuously monitor LDR output  and
> drive a mini motor according to the algorithm. Motor I drive is
> manufactured by NIHON MINI MOTOR CO LTD and is perfectly driven by RB0
> and RB1 digital outputs (no other components, directly PIC-to-Motor).

Eyebrows raised as I consider the possible nasty side effects that could arise from a direct motor connection to PIC, no matter how low the current... but you imply this is not a problem so will ignore it for now and concentrate on your question.

> My concern is  ; If I power the LDR from let's say RB4 port, how will
> this effect the stability of the system ?

By LDR do you mean Light Dependent Resistor? If yes, how do you mean affect system stability? Are you asking about port RB4 because it may be special eg: open drain output?

> I am not in a position to dedicate a power supply for LDR thus I am
> seeking practically effective workarounds.
Are you asking how to measure a Light Dependent Resistor using a single PIC I/O line? It would be possible to drive the port pin to charge/discharge a capacitor through the varying resistance of the LDR and determine resistance by measuring charge or discharge time.

Sorry, we can't really see what you're asking just yet... need a few more clues.

-- 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:  spam_OUTbrent.brownTakeThisOuTspamclear.net.nz

2011\10\21@060802 by alan.b.pearce

face picon face
> I have a sub-project where I continuously monitor LDR output  and
> drive a mini motor according to the algorithm. Motor I drive is
> manufactured by NIHON MINI MOTOR CO LTD and is perfectly driven by RB0
> and RB1 digital outputs (no other components, directly PIC-to-Motor).
> My concern is  ; 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 thus I am seeking practically
> effective workarounds.

Where is the problem? An LDR is a resistor, where the resistor value is dependent on the level of light incident on the surface. Connect it between an ADC input pin and ground, and put a resistor of the same value the LDR has when your average amount of light is falling on it (I suspect this will be around 5-10K at daylight values). The ADC measures the voltage as the LDR resistance varies. There will be some non-linearity between the amount of light and the voltage, but if this is important then use a table to linearise the ADC output.


-- Scanned by iCritical.

2011\10\21@071743 by IVP

face picon face
> direct motor connection to PIC, no matter how low the current

If this is a typical mini motor

http://www.solarbotics.net/library/pieces/parts_mech_grmotors_c_niho.html

current might not be an issue, although this one might be marginal.
Some protection against hash and back EMF would be neede

2011\10\21@102434 by Electron

flavicon
face

Hi,
if the motor produces back EMF (i.e. no electronics in it, just brushes)
then I think you will be very concerned.


At 09.33 2011.10.21, you wrote:
{Quote hidden}

>

2011\10\21@115752 by Yigit Turgut

picon face
On Fri, Oct 21, 2011 at 12:52 PM, Graham Lewis <.....mrlewisKILLspamspam@spam@ihug.co.nz> wrote:
> If you are not concerned about the spectral response would a small solar
> cell meet your requirements?
>
> Having a great day thank you

I am working in ultraviolet spectrum and LDR's I use have best
spectral response in 190-350nm region. Using a solar cell would
introduce too much deviation in measurement.


On Fri, Oct 21, 2011 at 1:00 PM, Brent Brown <brent.brownspamKILLspamclear.net.nz> wrote:
{Quote hidden}

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.

Motor rotates 45 degrees in both directions approximately 50 times a
day.  Made approximately 1000 turns after the system built no problems
so far. It's a very tiny lens motor, I guess it wouldn't harm to
attach some flywheels.


On Fri, Oct 21, 2011 at 1:06 PM,  <.....alan.b.pearceKILLspamspam.....stfc.ac.uk> wrote:
{Quote hidden}

Not quite like a problem,  I wondered if a digital output can be used
safely as a reference voltage in the same circuit. I tried and it
works as expected so far.


On Fri, Oct 21, 2011 at 5:23 PM, Electron <EraseMEelectron2k4spam_OUTspamTakeThisOuTinfinito.it> wrote:
>
> Hi,
> if the motor produces back EMF (i.e. no electronics in it, just brushes)
> 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.

2011\10\21@182732 by IVP

face picon face
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 ?

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 ?
Jo

2011\10\21@194855 by Brent Brown

picon face
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 ground then max current drain is: 5V/5kOhms = 1mA, or power is 5V^2/5kOhms = 5mW

Is that too much current for your power supply? It is not too much current for most PIC I/O port lines, except perhaps RB4... as previsouly mentioned have you checked to make sure RB4 is not an "open drain" output for your particular 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, from 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. Voltage 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 your LDR, thus giving a voltage divider: the voltage at the node of the LDR and fixed resistor will vary with varying resistance of the LDR.

-- 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.brownspamspam_OUTclear.net.nz

2011\10\21@195614 by Brent Brown

picon face
> > if the motor produces back EMF (i.e. no electronics in it, just brushes)
> > 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 only.... 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 forward biased in one direction - shorting the motor. So then you need 4 x diodes in a bridge 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?

-- 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:  @spam@brent.brownKILLspamspamclear.net.nz

2011\10\22@062250 by Yigit Turgut

picon face
On Sat, Oct 22, 2011 at 1:27 AM, IVP <KILLspamjoecolquittKILLspamspamclear.net.nz> 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 <RemoveMEbrent.brownTakeThisOuTspamclear.net.nz> wrote:
{Quote hidden}

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 <spamBeGonebrent.brownspamBeGonespamclear.net.nz> wrote:
{Quote hidden}

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

2011\10\22@063649 by IVP

face picon face
> 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

While the motor is running ? I've used LDRs and other opto sensors
and not found them noisy at all

> long time operation at 5.1V might cause some malfunction

Vdd limit is 5.5V for most, if not all, 5V PICs. I have many projects
with Vdd of 5.12V (for easier ADC maths

2011\10\22@164148 by Brent Brown

picon face
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 problems. You might try some software debugging to see what is going wrong.... is Or it taking your motor into a region of operation you hadn't been in before? Unexpected interrupt? Perhaps compare with a potentiometer.  
> 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 would consider a USB supply likely to be noisy (high freq) simply because it emanates from a PC. Lots of USB powered designs use a series ferrite inductor/choke/filter, or else an R/C filter.

> 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.

Good. RB4 was open drain output on many older PICs, but it is true push/pull on 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 of +/-25mA. You will also see spec for Voltage on any pin -0.3V to (Vdd + 0..3V). Both specs relate to input protection diodes. Note that the absolute max specs only guarantee the device will survive, does not guarantee that it will operate correctly under these conditions. As far as I can see there are no specs relating to normal use of the protection diodes (this has long been the case with PIC devices), therefore the burden is on the designer to do everything possible to minimise/avoid current in these diodes.

Take a look at BAT54S. Two Shottky diodes connected in series in a SOT-23 package, so you would only need two of them to get the 4 diodes to make a bridge. For both packages connect anode to GND, cathode to +5V, the remaining two common connections go one to each side of your motor (each PIC output).

-- 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:  TakeThisOuTbrent.brownEraseMEspamspam_OUTclear.net.nz

More... (looser matching)
- Last day of these posts
- In 2011 , 2012 only
- Today
- New search...