# Calculating resistors required

D

#### Danny T

Jan 1, 1970
0
Hi all,

Sorry for more reeeally basic questions, but advice I've been given by
different people conflicts, and some of the reading on the web is a bit
over my head, whereas you guys always seem to explain things well

I've got a programmed PIC16F chip, and I want to wire it up to a few
things... My power supply is 4AA batteries (about 6V), but my chip wants
about 5V. The switches connected to my chip also want about 5V.

My motor is driven from an output pin of the chip (which I guess, is
5V?), but the motor is 3V. My LEDs are 3V too.

I guess I need a resistor to reduce my 6V to 5V, which can then be
connected to the chip + input switches. The 5V output would be find for
the 5V LEDs, but I guess I need another resistor for each motor.

It's also been mentioned that my switches should be connected to 0V via
a resistor when "off", and 5V when "on". I don't understand the
reasoning for this :-\

Also, if I was to need 6V to drive something, but the output from my
chip is less, though my main supply is enough - how do I go about
changing a 5V (I think!) output, to 6V? I've been reading about
transistors thinking they do what I want, but I've just confused myself
even more!

Many thanks!

A

#### Andrew Holme

Jan 1, 1970
0
Danny said:
Hi all,

Sorry for more reeeally basic questions, but advice I've been given by
different people conflicts, and some of the reading on the web is a
bit over my head, whereas you guys always seem to explain things well

I've got a programmed PIC16F chip, and I want to wire it up to a few
things... My power supply is 4AA batteries (about 6V), but my chip
wants about 5V. The switches connected to my chip also want about 5V.

You need a low-dropout regulator to convert 6V into 5V ("low-dropout" refers
to the small difference between input and output voltages); you might get
away with a diode drop (about 0.7V). Consult the IC datasheets: check the
absolute max/min power supply voltages.
My motor is driven from an output pin of the chip (which I guess, is
5V?), but the motor is 3V. My LEDs are 3V too.

I find it hard to believe that a PIC output can provide enough current to
drive your motor. Are you sure? You would normally need a transistor (e.g.
MOSFET) with a back e.m.f. protection diode. You could also use a dropper
resistor, in series with the motor, if the power supply is too high for it.
Also: I would power the motor from the unregulated supply to reduce noise on
the microprocessor side; and use power supply decoupling capacitors.
I guess I need a resistor to reduce my 6V to 5V, which can then be
connected to the chip + input switches. The 5V output would be find
for the 5V LEDs, but I guess I need another resistor for each motor.

You can't use a resistor: the voltage drop across a resistor depends on the
current flowing through it; the current is not constant. Consider using a
diode or a (low dropout) regulator.
It's also been mentioned that my switches should be connected to 0V
via a resistor when "off", and 5V when "on". I don't understand the
reasoning for this :-\

You mentioned "switches" that "also want about 5V" above. I wondered if you
meant logic-level drive MOSFETs or something else? Switches, in the normal
sense, do not "want" any voltage! Switches, in their simplest form, are two
terminal open/closed mechanical devices which make or break a circuit.
Logic inputs are driven from switches like this. View diagram using a fixed
width font:

VCC
+
|
|
.-.
| | R
| |
'-'
|
|
+-----> Logic
|
|
\ o
\
\.
o
|
|
===
GND

Also, if I was to need 6V to drive something, but the output from my
chip is less, though my main supply is enough - how do I go about
changing a 5V (I think!) output, to 6V? I've been reading about
transistors thinking they do what I want, but I've just confused
myself even more!

+6V (or higher)
+
|
|
.-.
| |
'-'
|
|
|
||-+
||<- N-Channel
PIC >-----||-+ MOSFET
| Logic Level Drive
|
|
===
GND
created by Andy´s ASCII-Circuit v1.24.140803 Beta www.tech-chat.de

A

#### Anthony Fremont

Jan 1, 1970
0
Danny T said:
Hi all,

Sorry for more reeeally basic questions, but advice I've been given by
different people conflicts, and some of the reading on the web is a bit
over my head, whereas you guys always seem to explain things well

I've got a programmed PIC16F chip, and I want to wire it up to a few
things... My power supply is 4AA batteries (about 6V), but my chip wants
about 5V. The switches connected to my chip also want about 5V.

You could use 4 NiCad or NiMH batteries, this will give you approx 4.8V.
The PIC is fairly flexible, it will work from >3V - ~6V, though 6V is
really pusing it. You could also use 3 alkaline batteries for about
4.5V. Or, as you should probably do, you could use a linear voltage
regulator with a low dropout.
My motor is driven from an output pin of the chip (which I guess, is
5V?), but the motor is 3V. My LEDs are 3V too.

Unless your motor is really small (<25mA maximum current), the PIC is
not capable of driving it directly. You will need some kind of current
amplification such as a transistor or an H-bridge to drive the motor.
I guess I need a resistor to reduce my 6V to 5V, which can then be
connected to the chip + input switches. The 5V output would be find for
the 5V LEDs, but I guess I need another resistor for each motor.

A dropping resistor is not the right way to lower your voltage to the
PIC. Since the PIC will be drawing a varying amount of current (like
when turning LEDs on and off), your voltage would fluctuate wildly. You
will want to use a regulator of some kind as I mentioned above.

You *will* want to use resistors to limit the current thru your LEDs,
otherwise the PIC will attempt to supply a very large amount of current
to the LED. This is likely to result in damage to the LED and/or the
PIC output pin circuitry. (you can kill a PIC one pin at a time) LEDs
(like most diodes) are not voltage controled devices, they need current
limiting or they will burn out.
It's also been mentioned that my switches should be connected to 0V via
a resistor when "off", and 5V when "on". I don't understand the
reasoning for this :-\

The goal is to never have an input pin in a "floating" state. They are
suggesting that you use a pull-up resistor on the pin so that when the
switch isn't closed(pressed), the input pin sees a logic 1 (+5V) via the
juice feeding thru the pull-up. Then you have the switch so that it
shorts the pin directly to ground when pressed. The pull-up resistor
will limit how much current is flowing to ground, and the input pin will
"see" a logic 0. This way, the input pin is always connected to a
voltage reference of 5V or 0V.
Also, if I was to need 6V to drive something, but the output from my
chip is less, though my main supply is enough - how do I go about
changing a 5V (I think!) output, to 6V? I've been reading about
transistors thinking they do what I want, but I've just confused myself
even more!

You would want to use a transistor for this. For highish currents (like
motors), I suggest looking into the wonderful and inexpensive
logic-level n-channel MOSFETs. These are used allot like generic NPN
transistors, but have extremely low "on resistance" (milliohms usually).
The logic-level part means that you can connect the gate (base equiv)
directly to the PIC output pin and you don't even need a current
limiting resistor going into it since the MOSFETs gate input impedance
is really high. You connect the source pin (emitter equiv) directly to
;-) between the drain pin (collector equiv) and your +6V supply. When
the gate is high (+5V) the motor will run at full speed, when it's low
(0V) it will be turned fully off.

B

#### Byron A Jeff

Jan 1, 1970
0
-Hi all,
-
-Sorry for more reeeally basic questions, but advice I've been given by
-different people conflicts, and some of the reading on the web is a bit
-over my head, whereas you guys always seem to explain things well

Flattery will get you a lot of places.

-
-I've got a programmed PIC16F chip, and I want to wire it up to a few
-things... My power supply is 4AA batteries (about 6V), but my chip wants
-about 5V. The switches connected to my chip also want about 5V.

Switches generally don't care about voltage.

-
-My motor is driven from an output pin of the chip (which I guess, is
-5V?), but the motor is 3V. My LEDs are 3V too.

A couple of problems there. First off the PIC doesn't have enough drive to drive the
motor. Second LEDs use current as a more important parameter than voltage.
-
-
-I guess I need a resistor to reduce my 6V to 5V, which can then be
-connected to the chip + input switches.

Won't work. Resistors only work in this situation when the current requirements are
constant. The setup you describe is virtually guaranteed to have fluctuating current
which means that your voltage will be all over the place. In the end you'll probably
end up releasing "magic smoke" and your chip won't work anymore.

- The 5V output would be find for the 5V LEDs,

Again LEDs are much more concerned about current. You'll need current limiting resistors
for each LED.

- but I guess I need another resistor for each motor.

Resistors are not the proper way to manage differences in voltage. If you throw a
resistor in series with your motor, you'll limit the amount of power that you can give
to it.

-
-It's also been mentioned that my switches should be connected to 0V via
-a resistor when "off", and 5V when "on". I don't understand the
-reasoning for this :-\

Most switches are single pole. This means that the switch is either connected or
disconnected. When disconnected it floats and the input gets an indeterminate voltage.
This can cause problems. The 0V "pulldown" resistor will guarantee that the input is
0V when the switch is disconnected and 5V when connected.

-
-Also, if I was to need 6V to drive something, but the output from my
-chip is less, though my main supply is enough - how do I go about
-changing a 5V (I think!) output, to 6V? I've been reading about
-transistors thinking they do what I want, but I've just confused myself
-even more!

Well you have a whole host of issues to deal with. Let's work with them one at a time.
First and foremost is that your 4AA batteries will last about 2 minutes in the type of
application with LEDs and motors that you are describing. I would advise working with
a DC wall wart of at least 8V and a 7805 voltage regulator until you get everything
working. The wall wart and regulator will solve most of the issues in terms of regulating
voltage.

Next make sure that each LED has a current limiting resistor. You can look up the process
on the web.

You'll need a transistor driver for your motor. Also you can drive your motor directly
for your input voltage (8V) even if it's a 3V motor as long as the average voltage
presented to it is about 3V. You do this using pulse width modulation. Give the motor
a signal that is on 3/8 of the time and off 5/8 of the time and it'll run as if it has
3V applied to it. Another way to do it is to give the motor it's own 3V regulator built
from a LM317. Then you can run it at 100 percent without fear of burning it it.

Hope this gives ytou some insight.

BTW are you just fiddling or are you trying to build something in particular?
Also what is your PIC setup?

BAJ

D

#### Danny T

Jan 1, 1970
0
Yikes.. Looks like things aren't quite as simple as I thought! I've
responded to each point below...

You need a low-dropout regulator to convert 6V into 5V ("low-dropout" refers
to the small difference between input and output voltages); you might get
away with a diode drop (about 0.7V). Consult the IC datasheets: check the
absolute max/min power supply voltages.

The power is 3.0 - 5.5 Volts. My supply is *around* 6V (from 4AA
batteries). I'm not sure how consistant this voltage is as the batteries
wear. I thought diodes were "one way" components, but I guess you're
suggesting a diode also drops the current. So I could just put a diode
in between the battery box and the chip?

What value(?) diode should I use (and where would I find information on
choosing this value in future?)?

I find it hard to believe that a PIC output can provide enough current to
drive your motor. Are you sure? You would normally need a transistor (e.g.
MOSFET) with a back e.m.f. protection diode. You could also use a dropper
resistor, in series with the motor, if the power supply is too high for it.
Also: I would power the motor from the unregulated supply to reduce noise on
the microprocessor side; and use power supply decoupling capacitors.

Ignorance is not bliss! The output pins connect to LEDs fine, so I
assumed I could stick a small motor in. I guess not (told you I'm a
n00b! ). So, how would you recommend wiring the motor? Would a
transistor allow the output pin on the chip drive a higher
voltage/current to the motor? How do I calculate the values of
components I need? (the motor is 3V)

You can't use a resistor: the voltage drop across a resistor depends on the
current flowing through it; the current is not constant. Consider using a
diode or a (low dropout) regulator.

I guess my understanding of resistors is a bit flawed! I know my
batteries are 6v, and my chip wants 3.0 - 5.5, but nothing about the
current the batteries can produce or the chip consumes :-\

Logic inputs are driven from switches like this.

VCC
+
|
|
.-.
| | R
| |
'-'
|
|
+-----> Logic
|
|
\ o
\
\.
o
|
|
===
GND

I see. I thought the switch would be between the +ve and pin, not to
ground! How does this work? Also, how do you calculate the value of the
resistor being used there?
+6V (or higher)
+
|
|
.-.
| |
'-'
|
|
|
||-+
||<- N-Channel
PIC >-----||-+ MOSFET
| Logic Level Drive
|
|
===
GND

So the N-Channel MOSFET will connect the motor to ground when the PIC
outputs a logic 1? I always thought switches where +ve side, not ground.
Is there a difference?

Thanks for your help with my newbie questions!

D

#### Danny T

Jan 1, 1970
0
Anthony said:
Or, as you should probably do, you could use a linear voltage
regulator with a low dropout.

Excellent. I'm just looking @ Rapid Electronics, and they seem to be
available in lots of different packages! Some look like ICs, and some
have 3 legs. How do I figure out what I need?

http://www.rapidelectronics.co.uk/rkmain.asp?PAGEID=20671&CTL_CAT_CODE=30416

You *will* want to use resistors to limit the current thru your LEDs,
otherwise the PIC will attempt to supply a very large amount of current
to the LED. This is likely to result in damage to the LED and/or the
PIC output pin circuitry. (you can kill a PIC one pin at a time) LEDs
(like most diodes) are not voltage controled devices, they need current
limiting or they will burn out.

Righto. I've seen a formular for figuring out what resistors I need for
LEDs as:

1000 * (supply.voltage - voltage.needed) / current

Does this look right? And is this for LEDs only, or can it be used for
other things too?

The goal is to never have an input pin in a "floating" state. They are
suggesting that you use a pull-up resistor on the pin so that when the
switch isn't closed(pressed), the input pin sees a logic 1 (+5V) via the
juice feeding thru the pull-up. Then you have the switch so that it
shorts the pin directly to ground when pressed. The pull-up resistor
will limit how much current is flowing to ground, and the input pin will
"see" a logic 0. This way, the input pin is always connected to a
voltage reference of 5V or 0V.

My only question here, is that a switch would then give logic 0. I
thought it would be reversed, and a 1 would mean the switch is pressed.
Is that the usual way of doing things?

You would want to use a transistor for this. For highish currents (like
motors), I suggest looking into the wonderful and inexpensive
logic-level n-channel MOSFETs. These are used allot like generic NPN
transistors, but have extremely low "on resistance" (milliohms usually).
The logic-level part means that you can connect the gate (base equiv)
directly to the PIC output pin and you don't even need a current
limiting resistor going into it since the MOSFETs gate input impedance
is really high. You connect the source pin (emitter equiv) directly to
;-) between the drain pin (collector equiv) and your +6V supply. When
the gate is high (+5V) the motor will run at full speed, when it's low
(0V) it will be turned fully off.

Right - getting somewhere now!

So, for a circuit with two switches, one driving an LED and one driving
a motor, would this be correct? (I know the PIC is redundant, since the
inputs directly drive the outputs, but this wouldn't always be the case!)

Excuse the bad ascii, I've never used that program before!

VCC
+
|
o----------o-------o----------o----------------------o---------
| | | |
| | | ,---.
| | | | X | MOTOR
| | | PIC '---'
| | | + __ - |
.-. .-. '-o| |o---------------)------.
R | | R | | '-------o| |o--------. | |
| | | | | .----o| |o-----. | | |
'-' '-' | | .o|__|o--. | | | |
| '----' | | | .-. | ||-+ |
| | | | | | | | ||<- MOSFET
|-------)-------' | | |R| '---||-+ |
| | | | '-' | |
| | | | | | |
| | .-. .-. '---. '--. |
| o | o R | | R | | | | |
|=|> |=|> | | | | ,---. | |
| o | o '-' '-' | X |LED | |
| | Unused Unused '---' | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
o----------o-------o-----------o--------o------o--------o---o--'
|
===
GND
(created by AACircuit v1.28.4 beta 13/12/04 www.tech-chat.de)

Two switches on the left. Two pins unused, one LED, and one motor. That
right?

Many thanks,

D

#### Danny T

Jan 1, 1970
0
Danny said:
Excuse the bad ascii, I've never used that program before!
<snip>

Whoops, I had 6V connected to the PIC there. I guess I'm missing a
voltage regulator... Do I also need one for the motor? (motor is 3V)

D

#### Danny T

Jan 1, 1970
0
Byron said:
Flattery will get you a lot of places.
LOL!

-I've got a programmed PIC16F chip, and I want to wire it up to a few
-things... My power supply is 4AA batteries (about 6V), but my chip wants
-about 5V. The switches connected to my chip also want about 5V.

Switches generally don't care about voltage.

I phrased that badly, but I meant I need to connect a supply to the
input pins with the switches. Dunno where I got 5v from, but I assume it
needs something!

First and foremost is that your 4AA batteries will last about 2 minutes in the type of
application with LEDs and motors that you are describing. I would advise working with
a DC wall wart of at least 8V and a 7805 voltage regulator until you get everything
working. The wall wart and regulator will solve most of the issues in terms of regulating
voltage.

A wall wart? What's that? I guess something I could connect batteries or
to the wall would be good while building. I guess I need something that
plugs into the wall, converts to DC, and drops to around 6V (same as
batteries)?

Next make sure that each LED has a current limiting resistor. You can look up the process
on the web.

Yep, got this sorted

You'll need a transistor driver for your motor.

Is an N-type MOSFET the same thing?

voltage (8V) even if it's a 3V motor as long as the average voltage
presented to it is about 3V. You do this using pulse
width modulation.

Didn't know that, but it does sound a little messy. I'd rather just give
it 3V so I can leave it on/off as needed

BTW are you just fiddling or are you trying to build something in particular?
Also what is your PIC setup?

Currently I'm just fiddling. I want to simply set up a circuit with a
Danny-programmed PIC in it. The ultimate goal is just to learn as much
do!), but it'll probably start off heading down the route of little
robots that move around avoiding obstacles at home!

Thanks!

A

#### Andrew Holme

Jan 1, 1970
0
Danny said:
Yikes.. Looks like things aren't quite as simple as I thought! I've
responded to each point below...
[snip]

The power is 3.0 - 5.5 Volts. My supply is *around* 6V (from 4AA
batteries). I'm not sure how consistant this voltage is as the
batteries wear. I thought diodes were "one way" components, but I
guess you're suggesting a diode also drops the current. So I could
just put a diode in between the battery box and the chip?

What value(?) diode should I use (and where would I find information
on choosing this value in future?)?

Didoes drop voltage not current. Silicon diodes (e.g. 1N4148 or 1N4001)
drop about 0.7V so one would probably be adequate; but two, in series, would
be safer.
Ignorance is not bliss! The output pins connect to LEDs fine, so I
assumed I could stick a small motor in. I guess not (told you I'm a
n00b! ). So, how would you recommend wiring the motor? Would a
transistor allow the output pin on the chip drive a higher
voltage/current to the motor? How do I calculate the values of
components I need? (the motor is 3V)

You need to know the current to calculate the dropper resistor. Use Ohm's
Law. Or, find it by trial and error. Alternatively, you could use diodes
to drop the voltage:
6 - 3 = 3V
3 / 0.7 = 4 diodes in series.

[snip]

[snip: diagram of SPST switch with pull-up resistor]
I see. I thought the switch would be between the +ve and pin, not to
ground! How does this work? Also, how do you calculate the value of
the resistor being used there?

Yes, you could swap the switch and the resistor around to invert the sense
of the logic.
10k (or more) is fine for CMOS inputs.

[snip: diagram of N-channel logic-driven MOSFET with load]
So the N-Channel MOSFET will connect the motor to ground when the PIC
outputs a logic 1?
Correct.

I always thought switches where +ve side, not ground. Is there a
difference?

You would need a P-channel MOSFET to do it that way around.

D

#### Danny T

Jan 1, 1970
0
Andrew Holme wrote:
difference?

You would need a P-channel MOSFET to do it that way around.

But does it make any difference, switching +ve or ground? Is there any
reasons for doing it either way? Not just for the motor, but the
switches too?

A

#### Anthony Fremont

Jan 1, 1970
0
Danny said:
Excellent. I'm just looking @ Rapid Electronics, and they seem to be
available in lots of different packages! Some look like ICs, and some
have 3 legs. How do I figure out what I need?
http://www.rapidelectronics.co.uk/rkmain.asp?PAGEID=20671&CTL_CAT_CODE=30416

That's determined by how much current you need to draw, how much power
the regulator is going to have to dissipate (as heat) dropping the
voltage to the output level and how much margin the regulator has to
work with (i.e. how much greater the input voltage is than the output
voltage). The LM2940CT looks pretty good for you for all around
experimentation if you want to supply allot of current, but the LP2950CZ
should work ok in your circuit (as long as it is not trying to drive the
motors too). It is limited to 160mA output.
Righto. I've seen a formular for figuring out what resistors I need
for LEDs as:

1000 * (supply.voltage - voltage.needed) / current

Does this look right? And is this for LEDs only, or can it be used for
other things too?

It's just a variation of Ohms law with the 1000 multiplier allowing you
to specify current in milliamps instead of amps. For example, if you
are using a diode with a 1.7Vf (forward voltage drop), and you wished to
run it from a 5V supply, you will need to drop 3.3V thru the resistor.
If you want 20mA of current then ((5-1.7)/20)*1000 = 165 Ohms.
My only question here, is that a switch would then give logic 0. I
thought it would be reversed, and a 1 would mean the switch is
pressed. Is that the usual way of doing things?

It can be done the other way around if you like.
Right - getting somewhere now!

So, for a circuit with two switches, one driving an LED and one
driving a motor, would this be correct? (I know the PIC is redundant,
since the inputs directly drive the outputs, but this wouldn't always
be the case!)

Excuse the bad ascii, I've never used that program before!

VCC
+
|
o----------o-------o----------o----------------------o---------
| | | |
| | | ,---.
| | | | X | MOTOR
| | | PIC '---'
| | | + __ - |
.-. .-. '-o| |o---------------)------.
R | | R | | '-------o| |o--------. | |
| | | | | .----o| |o-----. | | |
'-' '-' | | .o|__|o--. | | | |
| '----' | | | .-. | ||-+ |
| | | | | | | | ||<- MOSFET
|-------)-------' | | |R| '---||-+ |
| | | | '-' | |
| | | | | | |
| | .-. .-. '---. '--. |
| o | o R | | R | | | | |
|=|> |=|> | | | | ,---. | |
| o | o '-' '-' | X |LED | |
| | Unused Unused '---' | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
o----------o-------o-----------o--------o------o--------o---o--'
|
===
GND
(created by AACircuit v1.28.4 beta 13/12/04 www.tech-chat.de)

Two switches on the left. Two pins unused, one LED, and one motor.
That right?

It looks ok to me. I assume you have MCLR disabled and are using the
internal oscillator.

J

#### John Popelish

Jan 1, 1970
0
Danny said:
Hi all,

Sorry for more reeeally basic questions, but advice I've been given by
different people conflicts, and some of the reading on the web is a bit
over my head, whereas you guys always seem to explain things well

I've got a programmed PIC16F chip, and I want to wire it up to a few
things... My power supply is 4AA batteries (about 6V), but my chip wants
about 5V. The switches connected to my chip also want about 5V.

You take only a slight risk by powering the PIC directly from 4 AA
cells. They put out 6 volts (or a little above) only when new. With
any significant load, they sag, quickly. I would mess with a
regulator, only is the chip was very valuable.
My motor is driven from an output pin of the chip (which I guess, is
5V?), but the motor is 3V. My LEDs are 3V too.

This loads have current requirements, as well as voltage needs. You
have to take both into account when designing drivers. The PIC
outputs have very limited current capability (read the spec sheet).
The outputs may have enough capability ot drive an LED, especially in
active low (on when the output is pulling negative), so a series
resistor may be all you need for those. The resistor has to waste the
extra voltage while passing the desired current. For instance if you
desire that 10 ma pass through both LED and resistor, and you expect
about 3 volts to be consumed by the LED, you have 2 or 3 volts that
must be burned up by the resistor. 3 volts drop divided by 10 ma
current through = 300 ohms resistance needed.

The motor will quite likely need a driver that provides current gain.
A PNP transistor connected as emitter follower (base to PIC output,
collector to ground, emitter to motor, other side of motor to battery
+) will provide about battery - .7 volts to motor when the PIC output
goes low. If you need a high active driver, change to an NPN
transistor and swap the collector and motor battery connections.
Limiting the motor voltage to an accurate maximum voltage is a bit
more complicated.
I guess I need a resistor to reduce my 6V to 5V, which can then be
connected to the chip + input switches. The 5V output would be find for
the 5V LEDs, but I guess I need another resistor for each motor.

It's also been mentioned that my switches should be connected to 0V via
a resistor when "off", and 5V when "on". I don't understand the
reasoning for this :-\

This probably means that the program is set up to to watch the input
switches (things you push to make the program do things) that are
activated when they connect to +5, and when you are not pushing on
them, a resistor pulls the input down to zero volts (active high).
This is a completely arbitrary program choice.
Also, if I was to need 6V to drive something, but the output from my
chip is less, though my main supply is enough - how do I go about
changing a 5V (I think!) output, to 6V? I've been reading about
transistors thinking they do what I want, but I've just confused myself
even more!

The simplest way is to add an N channel mosfet to the output (gate to
output, source to zero, load between +6 and drain). When an output
goes high, the mosfet will switch on and connect the full battery

J

#### John Popelish

Jan 1, 1970
0
Danny said:
Andrew Holme wrote:

But does it make any difference, switching +ve or ground? Is there any
reasons for doing it either way? Not just for the motor, but the
switches too?

Either can work, and the choice is up to the programmer. But most
digital ICs pull down better than they pull up, so they can supply
more load current in active low mode with less loss of voltage than
when used in active high mode. I like inputs to be active low,
because if the switch wiring shorts out to the case, the input line
just gets grounded, instead of connecting the +5 volt supply to the
case. But the choice is pretty arbitrary.

P

#### Peter Bennett

Jan 1, 1970
0
Anthony Fremont wrote:

My only question here, is that a switch would then give logic 0. I
thought it would be reversed, and a 1 would mean the switch is pressed.
Is that the usual way of doing things?

The tradition of using pull-up resistors and a switch to ground comes
from the characteristics of a TTL logic input. TTL inputs required a
fairly low resistance to ground before they would consider it a logic
low, and if the input was left open-circuit, would normally consider
it a high (but it is still good practice to use pull-up resistors).

CMOS inputs, as on most microcontrollers, don't source or sink any
current - if left unconnected, they will be in an unknown intermediate
state. Since they don't supply any significant current in either
state, you can use a fairly high value of resistor to pull the input
either high or low - then use the switch to pull it in the other
direction.

--
Peter Bennett, VE7CEI
peterbb4 (at) interchange.ubc.ca
new newsgroup users info : http://vancouver-webpages.com/nnq
GPS and NMEA info: http://vancouver-webpages.com/peter

B

#### Byron A Jeff

Jan 1, 1970
0
-
-> Flattery will get you a lot of places.
-
-LOL!
-
-
-> -I've got a programmed PIC16F chip, and I want to wire it up to a few
-> -things... My power supply is 4AA batteries (about 6V), but my chip wants
-> -about 5V. The switches connected to my chip also want about 5V.
->
-> Switches generally don't care about voltage.
-
-I phrased that badly, but I meant I need to connect a supply to the
-input pins with the switches. Dunno where I got 5v from, but I assume it
-needs something!

If the switch is going into the PIC then 5V is right.

-
-
-> First and foremost is that your 4AA batteries will last about 2 minutes in the type of
-> application with LEDs and motors that you are describing. I would advise working with
-> a DC wall wart of at least 8V and a 7805 voltage regulator until you get everything
-> working. The wall wart and regulator will solve most of the issues in terms of regulating
-> voltage.
-
-A wall wart? What's that? I guess something I could connect batteries or
-to the wall would be good while building. I guess I need something that
-plugs into the wall, converts to DC, and drops to around 6V (same as
-batteries)?

a Wall wart is a DC power supply. Here's a typical picture:

http://encyclobeamia.solarbotics.net/articles/_pix/wallwart.gif

And you don't want 6V because then you'll have a problem regulating it. For
a 7805 you generally want at least 2.5V of headroom. So if you want regulated
5V then you'll want an input voltage of at least 7.5V. That's why I said 8V
in the original post.

- [SNIP]
-> You'll need a transistor driver for your motor.
-
-Is an N-type MOSFET the same thing?

Yup.

-
-
- > voltage (8V) even if it's a 3V motor as long as the average voltage
- > presented to it is about 3V. You do this using pulse
- > width modulation.
-
-Didn't know that, but it does sound a little messy. I'd rather just give
-it 3V so I can leave it on/off as needed

Then you'll probably want to have a second regulator. Look up LM317 adjustable
regulators as I said in my previous post. Both the 7805 and LM317 are available

-[SNIP]

BAJ

D

#### Danny T

Jan 1, 1970
0
Anthony said:
It looks ok to me. I assume you have MCLR disabled and are using the
internal oscillator.

Yep! (When I can figure out how to stop the programmer going nuts when I
disable MCLR! - If not, I guess I just connect the MCLR pin to the PIC
Vdd pin?)

Going back to the regulators...:
http://www.rapidelectronics.co.uk/rkmain.asp?PAGEID=20671&CTL_CAT_CODE=30416

That's determined by how much current you need to draw, how much power
the regulator is going to have to dissipate (as heat) dropping the
voltage to the output level and how much margin the regulator has to
work with (i.e. how much greater the input voltage is than the output
voltage). The LM2940CT looks pretty good for you for all around
experimentation if you want to supply allot of current, but the LP2950CZ
should work ok in your circuit (as long as it is not trying to drive the
motors too). It is limited to 160mA output.

So, would I be right in thinking that 2x LM2940CT-5.0 would drop 6V to
around 5V?

I want to drive 2x3V motors, but it seems the LM2940CT-5.0 has a minimum
input of 5.45 (to drop to around 5V). Motor specs say:

But none of the low dropout regulators seem to fit... Was just looking
at fixed voltage regulators, but the only one that'll allow a high
enough current is an output of 5V, still too high for my motors :-(

http://www.rapidelectronics.co.uk/r...CAT_CODE=30414&STK_PROD_CODE=M29655&XPAGENO=1

Any suggestions?

D

#### Danny T

Jan 1, 1970
0
Andrew Holme wrote:

Any chance you could look at my thread "Circuit & Component Check" to
see if all looks well?

Thanks!

D

#### Danny T

Jan 1, 1970
0
Anthony Fremont wrote:

Any chance you could look at my thread "Circuit & Component Check" to
see if all looks well?

Thanks!

D

#### Danny T

Jan 1, 1970
0
Byron A Jeff wrote:

Any chance you could look at my thread "Circuit & Component Check" to
see if all looks well?
And you don't want 6V because then you'll have a problem regulating it. For
a 7805 you generally want at least 2.5V of headroom. So if you want regulated
5V then you'll want an input voltage of at least 7.5V. That's why I said 8V
in the original post.

Would something like this work? (if I cut the end off and attach wires I

http://www.argos.co.uk/webapp/wcs/s...001&langId=-1&catalogId=2501&productId=111269

Or do I need something that says "DC" in it?

Thanks!

A

#### Anthony Fremont

Jan 1, 1970
0
Danny T said:
Yep! (When I can figure out how to stop the programmer going nuts when I
disable MCLR! - If not, I guess I just connect the MCLR pin to the PIC
Vdd pin?)

Yes, you can usually tie it directly to the +5V.
Going back to the regulators...:

So, would I be right in thinking that 2x LM2940CT-5.0 would drop 6V to
around 5V?

Why 2x?
I want to drive 2x3V motors, but it seems the LM2940CT-5.0 has a minimum
input of 5.45 (to drop to around 5V). Motor specs say:

But none of the low dropout regulators seem to fit... Was just looking
at fixed voltage regulators, but the only one that'll allow a high
enough current is an output of 5V, still too high for my motors :-(

http://www.rapidelectronics.co.uk/r...CAT_CODE=30414&STK_PROD_CODE=M29655&XPAGENO=1

Any suggestions?

Don't use a regulator to power your motors. You could use a bunch of
diodes, you could tap power from the middle of the battery pack, you
could put the motors in series, or you could PWM the motors directly
with the +6V. There are other ways, but I'd probably go with center
tapping the PS (battery pack) or better yet using a different PS
altogether for the motors (helps prevent noise in the PICs PS).

Replies
0
Views
644
Replies
21
Views
2K
Replies
10
Views
1K
Replies
1
Views
290
Replies
7
Views
868