Circuit & Component Check

J

John Popelish

Jan 1, 1970
0
Danny said:
Which leg of the MOSFET should it connect to? Not sure I understand its
purpose :-\

The source lead. The caps connect between the positive and negative
supply points for the motor and its driver transistor (as close as
possible to those points, too). When the drive transistor turns off
or on, suddenly, a wave of current would otherwise travel all the way
back to the battery, bouncing every circuit connected to it.

Imagine sitting on a large trampoline, trying to read a book of fine
print, while a fat kid jumps on it a few feet away, to visualize the
effect the motor load will have on the PIC.
 
D

Danny T

Jan 1, 1970
0
John said:
The source lead. The caps connect between the positive and negative
supply points for the motor and its driver transistor (as close as
possible to those points, too). When the drive transistor turns off
or on, suddenly, a wave of current would otherwise travel all the way
back to the battery, bouncing every circuit connected to it.

Sorry, I thought you meant both ends connected to the leads you
specified, but from reading Andrew Holme's post, I gathered that one end
connects to the join from the MOSFETs to the motors, and the other end
to ground - is this correct?

I don't quite understand the need for two *different* capacitors - why
would one not do?

Thanks,
 
A

Andrew Holme

Jan 1, 1970
0
Danny said:
John Popelish wrote: [snip]
Sorry, I thought you meant both ends connected to the leads you
specified, but from reading Andrew Holme's post, I gathered that one
end connects to the join from the MOSFETs to the motors, and the
other end to ground - is this correct?

I think you have that wrong. Here's a diagram:



+6V ---->|-->|-->|-->|---+
4 Diodes |
|
+--------+------+
3.2V +-----+-------+-----+ | | +
| | | | --- ---
| | | | C1--- C2---
| _-_ | _-_ | |
- |___| - |___| | |
^ - ^ - === ===
| | | | GND GND
| | | |
+-----+ +-----+
| |
| |
||-+ ||-+
||-> ||->
----||-+ -----||-+
N-Type | N-Type |
MOSFET | MOSFET |
| |
=== ===
GND GND


C1 and C2 are the two capacitors.
I don't quite understand the need for two *different* capacitors - why
would one not do?

The big capacitor (say 100uF - 1000uF) acts as a reservoir, but does not
respond so well to fast transients. The smaller capacitor (say 100n) takes
care of higher frequencies. One capacitor (perhaps 1uF) would help
somewhat. Two are "belt and braces."
 
D

Danny T

Jan 1, 1970
0
Andrew said:
I think you have that wrong. Here's a diagram:

Sorry, was thrown by this:

I assumed he meant the MOSFET?

+6V ---->|-->|-->|-->|---+
4 Diodes |
|
+--------+------+
3.2V +-----+-------+-----+ | | +
| | | | --- ---
| | | | C1--- C2---
| _-_ | _-_ | |
- |___| - |___| | |
^ - ^ - === ===
| | | | GND GND
| | | |
+-----+ +-----+
| |
| |
||-+ ||-+
||-> ||->
----||-+ -----||-+
N-Type | N-Type |
MOSFET | MOSFET |
| |
=== ===
GND GND


C1 and C2 are the two capacitors.



The big capacitor (say 100uF - 1000uF) acts as a reservoir, but does not
respond so well to fast transients. The smaller capacitor (say 100n) takes
care of higher frequencies. One capacitor (perhaps 1uF) would help
somewhat. Two are "belt and braces."

Right, I understand - but wasn't this what the back emf diode was for,
to stop these spikes going anywhere? :-\
 
D

Danny T

Jan 1, 1970
0
John said:
No. The positive end of the electrolytic and one end of the film cap
connects to the positive lead of the motor. The negative end of the
electrolytic and the other end of the film capacitor connect ot the
source lead (grounded lead) of the mosfet driving the motor. This
acts as a small, 3 volt battery as close as possible to the motor.

I see. I understand your original post now, I was looking at the wrong
side of the MOSFET - of course, the other side was ground! :)

The electrolytic is good at dumping a big current for a long time, but
it has the aluminum wound up inside it, so that there is a bit of
inductance in series with the capacitance that doesn't allow it to
have this current change in an instant. The smaller, low inductance
capacitor supplies the current during this brief time.

I understood (Andrew beat you to it ;)). Incidently.. What exactly does
the capacitor do with all this current it builds up?!

Since you have two motors and two motor drivers, there should probably
be a set o capacitors for each (especially if you use a separate
voltage regulator for each motor), unless the two mosfets are right
together and the positive leads to the motor are also very connected
directly together.

I'm not sure I understand. As you can see from my diagram, they're
"near", but not connected, since I need seperate switching and supplies
for my motor (seperate supplies are just because I'm using 1A diodes,
and the motors can pull 1.07A - if I stick to the smaller motors, I
could probably share them)
 
J

John Popelish

Jan 1, 1970
0
Danny said:
Sorry, I thought you meant both ends connected to the leads you
specified, but from reading Andrew Holme's post, I gathered that one end
connects to the join from the MOSFETs to the motors, and the other end
to ground - is this correct?

No. The positive end of the electrolytic and one end of the film cap
connects to the positive lead of the motor. The negative end of the
electrolytic and the other end of the film capacitor connect ot the
source lead (grounded lead) of the mosfet driving the motor. This
acts as a small, 3 volt battery as close as possible to the motor.
I don't quite understand the need for two *different* capacitors - why
would one not do?

The electrolytic is good at dumping a big current for a long time, but
it has the aluminum wound up inside it, so that there is a bit of
inductance in series with the capacitance that doesn't allow it to
have this current change in an instant. The smaller, low inductance
capacitor supplies the current during this brief time.

Since you have two motors and two motor drivers, there should probably
be a set o capacitors for each (especially if you use a separate
voltage regulator for each motor), unless the two mosfets are right
together and the positive leads to the motor are also very connected
directly together.
 
J

John Popelish

Jan 1, 1970
0
Danny said:
Right, I understand - but wasn't this what the back emf diode was for,
to stop these spikes going anywhere? :-\

No. The caps keep the supply voltage from bouncing around when there
is a big load current change when the motor turns off or on very
suddenly.

Remember that trampoline visualization I told you about? The height
above ground represents the voltage the battery supplies to each
load. If you place a big lead ring around the spot where the fat kid
jumps, it isolates his impact from other things resting on the
trampoline. Place another lead ring around the reader (the small
capacitor across the supply pins of the PIC) and you isolate the
vibration a bit more, and if the reader shifts his weight, it keeps
that disturbance local, also.

The diodes across the motors keep the drain lead of the mosfets (not a
power supply connection) from seeing a big positive voltage each time
the mosfet turns the motor current off. This is a purely an effect of
the motor storing energy in its magnetic field and that energy has to
go somewhere when the magnetic field collapses as the current goes to
zero. This big spike can damage the mosfet, and couples noise
capacitively, to any conductors nearby. The diodes suppress the
action that makes an ignition coil produce such great sparks.

If the mosfets drove resistors instead of something inductive, there
would still be the power supply bounce, but no extra voltage spike on
the drain at turn off.
 
A

Andrew Holme

Jan 1, 1970
0
Danny said:
Sorry, was thrown by this:


I assumed he meant the MOSFET?



Right, I understand - but wasn't this what the back emf diode was for,
to stop these spikes going anywhere? :-\

Well, that's interesting. Back emf occurs the instant you interrupt the
motor current. I was going to say motors also generate noise while they're
running - which they do; but then I asked myself: what causes this "running"
noise? Is it commutation? What's the difference between commutation and
interruption? Will the back emf diode also suppress commutation noise?
Possibly, but I'm sure a decoupling and/or reservoir capacitor would further
improve matters.
 
J

John Popelish

Jan 1, 1970
0
Danny said:
John Popelish wrote:

I understood (Andrew beat you to it ;)). Incidently.. What exactly does
the capacitor do with all this current it builds up?!

Capacitors store charge. When anything tries to change the voltage
across a capacitor, it responds by moving charge (current) to resist
the change.

When the motor first is switched on, the voltage between the mosfet
source and positive side of the motor tends to collapse toward zero as
the current needed to support this voltage with this new current
ripples toward the battery. The capacitors just give this current
someplace closer to come from. If current changes quickly along the
battery supply path, the inductance of that path produces large
voltage swings. If those current changes can be slowed, That wiring
inductance produces much less voltage swing.
I'm not sure I understand. As you can see from my diagram, they're
"near", but not connected, since I need seperate switching and supplies
for my motor (seperate supplies are just because I'm using 1A diodes,
and the motors can pull 1.07A - if I stick to the smaller motors, I
could probably share them)

If there are separate voltage supplies for the two motors, then the
only way to have a capacitor connected directly from motor positive to
mosfet source is to have two sets of them. If there is a single
supply that branches out to feed two motors, it still wouldn't hurt to
have a capacitor set for each motor. That way, it is not nearly so
important how close the two mosfet sources are connected, or if the
two motor positives are tied at the same spot.

This sort of insurance is often the difference between a
microprocessor that just works and one that has all kinds of fits.
 
D

Danny T

Jan 1, 1970
0
John said:
If the mosfets drove resistors instead of something inductive, there
would still be the power supply bounce, but no extra voltage spike on
the drain at turn off.

Right, got that. Thanks! :eek:)
 
D

Danny T

Jan 1, 1970
0
John said:
If there are separate voltage supplies for the two motors, then the
only way to have a capacitor connected directly from motor positive to
mosfet source is to have two sets of them. If there is a single
supply that branches out to feed two motors, it still wouldn't hurt to
have a capacitor set for each motor. That way, it is not nearly so
important how close the two mosfet sources are connected, or if the
two motor positives are tied at the same spot.

This sort of insurance is often the difference between a
microprocessor that just works and one that has all kinds of fits.

Cheers. I'll have to copy these threads into a folder somewhere, lots of
useful info! Thanks :eek:)
 
D

Danny T

Jan 1, 1970
0
Danny T wrote:
<snip>

Yet more questions.. ;P

This comes from a book - "INSECTRONICS - Build Your Own Walking Robot"
by Karl Williams. I've no plan on walking robots, but it has IR sensors
and stuff in it, so it's a good read. Anyway, one of the circuits looks
like this:

http://dantup.me.uk/tmp/circuit.jpg

I noticed a few things...

1. MCLR is tied to Vdd with a 4.7K resistor. I had them connected
directly. Since MCLR probably doesn't draw much current, I don't
understand what the resistor would do... Anyone?

2. RB1 and RB2 have a 1K resistor, then what looks like two diodes. If
these are unused, are the diodes needed? If they're supposed to be LEDs,
1K seems high - I calculated my two sets of LEDs as needing 120Ohms
and 160Ohms?

3. The speaker ties to the same "ground" as the main +5V supply, but it
seems to have its own +9V supply. Surely each should return to it's own
power source?!

4. RA2 has a jumped, and gets tied to +5V or ground, via a 1k resistor.
I've been using 10k - how important is this value?

Sorry for asking silly questions, but I find it's the best way to learn! :eek:)
 
A

Andrew Holme

Jan 1, 1970
0
Danny said:
Danny T wrote:
<snip>

Yet more questions.. ;P

This comes from a book - "INSECTRONICS - Build Your Own Walking Robot"
by Karl Williams. I've no plan on walking robots, but it has IR
sensors
and stuff in it, so it's a good read. Anyway, one of the circuits
looks like this:

http://dantup.me.uk/tmp/circuit.jpg

I noticed a few things...

1. MCLR is tied to Vdd with a 4.7K resistor. I had them connected
directly. Since MCLR probably doesn't draw much current, I don't
understand what the resistor would do... Anyone?

This is an obsolete practice. Pull-ups were required for the original 7400
series TTL logic family back in the 1970s but they're not necessary with
modern CMOS. You can tie CMOS inputs directly to Vdd.
2. RB1 and RB2 have a 1K resistor, then what looks like two diodes. If
these are unused, are the diodes needed? If they're supposed to be
LEDs, 1K seems high - I calculated my two sets of LEDs as needing
120Ohms
and 160Ohms?

The (small) double arrows at 45 degrees identify them as LEDs. They will
glow dimmly with 1k. Perhaps the designer was trying to save power?
3. The speaker ties to the same "ground" as the main +5V supply, but
it seems to have its own +9V supply. Surely each should return to
it's own power source?!

The grounds are connected; note the earth symbols:

|
|
-------
-----
---
-
4. RA2 has a jumped, and gets tied to +5V or ground, via a 1k
resistor. I've been using 10k - how important is this value?

The value is not critical; 100 ohms or 100k would also work.

The resistor would be un-necessary for a CMOS input, but is a wise
precaution in case the software ever programs the I/O port as an output.
The same is not, apparently, done on JP7; is this an output?
 
D

Danny T

Jan 1, 1970
0
Andrew Holme wrote:

Good news (for me!)... I just got my first breadboard circuit working! I
think my problems had all been down to MCLR! I just created the circuit
you've been helping with here, but without the motors (and without the
Vdd->Vss cap, since I don't have them yet!). It just flashes two sets of
LEDs on and off, and has the unused pins (and inputs I don't yet have
switches for) tied to ground with resistors.

W00t! That's the hard part - now I can get programming world peace
instead of just LEDs! =)

This is an obsolete practice. Pull-ups were required for the original 7400
series TTL logic family back in the 1970s but they're not necessary with
modern CMOS. You can tie CMOS inputs directly to Vdd.

I just removed the 4.7K resistor on my breadboard, and it still works
the same. I'll ignore this in future :)

The (small) double arrows at 45 degrees identify them as LEDs. They will
glow dimmly with 1k. Perhaps the designer was trying to save power?

I thought they where LEDs, but thought I'd cover all bases ;)
Ironically, the lowest resistor I have here is 1K, so I've had to use
them for my test, and the LEDs glow fine - I guess there's no point
giving them more power if they don't need to be brighter :)
(or maybe he was using his dads old resistor box too!)

The grounds are connected; note the earth symbols:

|
|

I see. Is there any advantage to connecting all the ground together from
different sources to just having them totally seperate? Is it just to
make wiring easier, since any ground will do? Would this cause any extra
noise from things like motors?

The value is not critical; 100 ohms or 100k would also work.

Ok, so what *exactly* is the resistor doing? What does it do when it's
given say 0, 3, 5, 7 volts?

The resistor would be un-necessary for a CMOS input, but is a wise
precaution in case the software ever programs the I/O port as an output.

I see. Does the same hold for my circuit? I've got +5V, connected to a
resistor, then to both the input pin and a switch. If I *know* my chip
is an input (eg., I've tested it *with* the resistor), is it safe to remove?

The same is not, apparently, done on JP7; is this an output?

Don't know, it's not explained, and the assembly's pretty long... I'll
just ignore this for now :)
 
R

Robert Monsen

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

Good news (for me!)... I just got my first breadboard circuit working! I
think my problems had all been down to MCLR! I just created the circuit
you've been helping with here, but without the motors (and without the
Vdd->Vss cap, since I don't have them yet!). It just flashes two sets of
LEDs on and off, and has the unused pins (and inputs I don't yet have
switches for) tied to ground with resistors.

W00t! That's the hard part - now I can get programming world peace
instead of just LEDs! =)




I just removed the 4.7K resistor on my breadboard, and it still works
the same. I'll ignore this in future :)

I just looked at the datasheet for the 16F676, and it specifies a
resistor of at least 1k, along with an optional cap of 0.1uF to ground.
This is on pg 58 of the 16F630/16F676 datasheet.

Also, note that MCLR can be used to avoid problems when the voltage
comes up too slowly. Microchip sells a part specifically for this (the
MCP100 series, if memory serves) that will keep MCLR low until the
voltage comes up enough for the system to run. You can also build a
circuit like this fairly easily, or just ignore it and tie it to Vdd if
you aren't worried about it. However, MCLR problems seem to be endemic
to the microchip product line for some reason.
I thought they where LEDs, but thought I'd cover all bases ;)
Ironically, the lowest resistor I have here is 1K, so I've had to use
them for my test, and the LEDs glow fine - I guess there's no point
giving them more power if they don't need to be brighter :)
(or maybe he was using his dads old resistor box too!)




I see. Is there any advantage to connecting all the ground together from
different sources to just having them totally seperate? Is it just to
make wiring easier, since any ground will do? Would this cause any extra
noise from things like motors?

Ground is the common reference point in your circuit. Without it, you
can't connect up the parts of your circuit. This is because voltage is
not an absolute measure, it's a relative measure. Thus, when you signal
from one part of your circuit to another part using voltage you must
reference that voltage signal to something. That something is ground.

Note, however, that ground isn't always the same. Wires have a little
resistance and inductance, and so the more current that flows over them,
and the more it changes abruptly (as in motors), the more voltage will
be across them. Consequently, grounds that have lots of current can be
different than grounds that have only a little current. Just something
to keep in mind.

Actually, many microchip parts have internal "weak pullup resistors",
which can be turned on and of individually for port pins. They are 10k.
Look at the datasheet for your part.

I was just bitten by this, in that I forgot about the internal pullups,
and wondered why my 100k resistor wasn't pulling the input to ground.
Turning off the pullups fixed the problem.
Ok, so what *exactly* is the resistor doing? What does it do when it's
given say 0, 3, 5, 7 volts?




I see. Does the same hold for my circuit? I've got +5V, connected to a
resistor, then to both the input pin and a switch. If I *know* my chip
is an input (eg., I've tested it *with* the resistor), is it safe to
remove?

The initial value for parts from reset is to be an input, I believe.
Unless you explicitly change this, they will never be an output.
However, you are not taking into account possible software errors that
may creep in at a later date. Prudence suggests that you provide for
this possibility by using a resistor.
Don't know, it's not explained, and the assembly's pretty long... I'll
just ignore this for now :)


--
Regards,
Robert Monsen

"Your Highness, I have no need of this hypothesis."
- Pierre Laplace (1749-1827), to Napoleon,
on why his works on celestial mechanics make no mention of God.
 
D

Danny T

Jan 1, 1970
0
Robert said:
I just looked at the datasheet for the 16F676, and it specifies a
resistor of at least 1k, along with an optional cap of 0.1uF to ground.
This is on pg 58 of the 16F630/16F676 datasheet.

I'm currently using 16F627 and 12F629. What section of the datasheet was
it under, so I can check what these say?

Actually, many microchip parts have internal "weak pullup resistors",
which can be turned on and of individually for port pins. They are 10k.
Look at the datasheet for your part.

I noticed these, but didn't full understand them. If these are turned
on, is it safe to remove the resistors and connect directly to 5V/Ground?
 
D

Dominic-Luc Webb

Jan 1, 1970
0
The grounds are connected; note the earth symbols:

|
|


Actually, maybe you can explain the way that NPN 2N3904 transistor
is connected? It looks odd to me that the emitter is not tied to
ground, but the collector is. I am not sure I see what it is
supposed to do in this circuit.

Dominic
 
D

Dominic-Luc Webb

Jan 1, 1970
0
2. RB1 and RB2 have a 1K resistor, then what looks like two diodes. If
these are unused, are the diodes needed? If they're supposed to be LEDs,
1K seems high - I calculated my two sets of LEDs as needing 120Ohms
and 160Ohms?


Maybe you mean RB0 and RB1.... if the supply is 5 volts and these
are typical 5 mm 2.0 volt and 0.03 amp LEDs, then a typo would
make more sense. This would work out to exactly 100 Ohm, just
obeying Ohm's law.

I'll wait and see if anyone suggests an explanation for that
transistor. It would more more sense to me if the collector
and emitter were in reverse order. In that case, it would look
like the basic textbook example with 9 VDC to one speaker wire
and the other speaker wire going to collector and then the emitter
goes to ground, as usual.

Surely someone with more experience sees something I do not.

Dominic
 
R

Robert Monsen

Jan 1, 1970
0
Danny said:
I'm currently using 16F627 and 12F629. What section of the datasheet was
it under, so I can check what these say?

It's under 'special features of the CPU', where it talks about MCLR
I noticed these, but didn't full understand them. If these are turned
on, is it safe to remove the resistors and connect directly to 5V/Ground?

I don't think so. Connecting it to 5V would just bypass the resistor.
Connecting it to ground would just waste 0.5mA to no purpose.

The pullups work just like an external 10k resistance to Vdd. The point
is that you can set ports up as inputs without worrying about the CMOS
'floating input' problem, which causes a big current drain when a CMOS
input sits 1/2 way between ground and Vdd.

As far as your circuit goes, if you use these pullups, you don't have to
connect the port to anything, it will automatically read as high when
you look at it, and won't consume inordinate amounts of power.

You can also use this to your advantage with pushbuttons, for example.
Use a normally open pushbutton, set the port to use the internal weak
pullups, and connect the other side to ground. Then, if you push the
button, the port will read 0, otherwise, it'll read high.

If you aren't using the port, however, you can just set it to be an
output using the TRIS register, and then safely leave it unconnected.

--
Regards,
Robert Monsen

"Your Highness, I have no need of this hypothesis."
- Pierre Laplace (1749-1827), to Napoleon,
on why his works on celestial mechanics make no mention of God.
 
A

Andrew Holme

Jan 1, 1970
0
Dominic-Luc Webb said:
Actually, maybe you can explain the way that NPN 2N3904 transistor
is connected? It looks odd to me that the emitter is not tied to
ground, but the collector is. I am not sure I see what it is
supposed to do in this circuit.

Yes, the emitter and collector are the wrong way round: the collector should
go to the piezo, and the emitter should go to ground - as you said.

Also, the base resistor (R5) is unnecessarily small. If we take an
excessively high estimate of 200mA for piezo current, divide by a low
estimate of 50 for gain (beta), we still need only 4ma of base current to
saturate the transistor. The base resistor should be (5-0.7)/4 = 1k.
 
Top