MOSFET/circuit troubleshotting :-\

John Popelish wrote:

The capacitors are okay, and your connections match your schematic,
but you didn't follow my directions. Your connections force the motor
noise to go out to the ground bus and back on their way to the
capacitors. Those capacitors should be plugged directly into the
source row to keep that noise current local.
Ok, I'll change this. Does it really make that much difference, it's
only one wires length from ground anyway? :-\

--
Danny
 
Anthony Fremont wrote:

Never leave input pins unconnected, always have some kind of pull-up or
pull-down resistor applied, be it internal or external. The code I saw
in a.m.8 has the internal pull-ups disabled, so I hope you have external
pull-ups applied to the input pins.
I don't remember what I posted then, but bit 7 of my INPUT register is
current set to 1, to allow pull-ups. The individual pull-ups are enabled
on power :)

--
Danny
 
Andrew Holme wrote:
Danny T wrote:

it's off for *most* of the time! Stupid fool! I'll change the logic to
"buffer" it (like further down, or I'll call the delay after turning
the motors on).

Buffer it. Don't just put in a delay. You'll needlessly create glitches if
you rapidly switch it on and off; even if it's only off for a micro-second.
That would be sloppy. You shouldn't need a delay if you're doing it right.
I agree, I meant for testing. It worked, and I'll write it properly now :)

Thanks again,

--
Danny
 
"Andrew Holme" <andrew@nospam.com> wrote in message
news:crrrko$4i9$1$830fa7b3@news.demon.co.uk...
Danny T wrote:
it's off for *most* of the time! Stupid fool! I'll change the logic
to
"buffer" it (like further down, or I'll call the delay after
turning
the motors on).

Buffer it. Don't just put in a delay. You'll needlessly create
glitches if
you rapidly switch it on and off; even if it's only off for a
micro-second.
That would be sloppy. You shouldn't need a delay if you're doing it
right.

I completely agree.
 
Danny T wrote:
John Popelish wrote:

The capacitors are okay, and your connections match your schematic,
but you didn't follow my directions. Your connections force the motor
noise to go out to the ground bus and back on their way to the
capacitors. Those capacitors should be plugged directly into the
source row to keep that noise current local.

Ok, I'll change this. Does it really make that much difference, it's
only one wires length from ground anyway? :-\
Yes, it actually does. And the length of the leads on the capacitors
matters, too. Sometime you might calculate the inductance of those
wires and how much voltage that inductance can produce when an ampere
turns on or off through it in a few tens of nanoseconds. Wires are
inductors.

I would lay out a circuit board for this circuit that put the positive
motor lead adjacent ot the source pin, and jump that small distance
with a low ESR capacitor. That is the only way to keep all that
current pulsing out of the rest of the system.

--
John Popelish
 
"Danny T" <danny@nospam.oops> wrote in message
news:41e17b1e$0$29002$ed2e19e4@ptn-nntp-reader04.plus.net...
Anthony Fremont wrote:

Never leave input pins unconnected, always have some kind of pull-up
or
pull-down resistor applied, be it internal or external. The code I
saw
in a.m.8 has the internal pull-ups disabled, so I hope you have
external
pull-ups applied to the input pins.

I don't remember what I posted then, but bit 7 of my INPUT register is
current set to 1, to allow pull-ups. The individual pull-ups are
enabled
on power :)
Bit 7 of the OPTION register is /GPPU (active low). Setting it
*disables* the pull-ups. Upon power-up, the pull-ups are disabled
because the bit is set.
 
Anthony Fremont wrote:

Bit 7 of the OPTION register is /GPPU (active low). Setting it
*disables* the pull-ups. Upon power-up, the pull-ups are disabled
because the bit is set.
Doh!

Been a long few days... Corrected now - setting my option register to 0h.

Ta :)

--
Danny
 
Anthony Fremont wrote:

That should work better. ;-) Now stop using 0 and 1 when you should be
using 'W' and 'F'. Not all PICs are consitant on the values, that's why
you should use the include file.

LIST P=12f629
INCLUDE "p12f629.inc"
I knew there'd be a way to do this, since there are files for most PICs
with all this stuff in - just didn't bother to look! Ta :)


Instead of this:

TMPOUT EQU 20h ; Temp output for motors
COUNT1 EQU 21h ; Delay counter1
COUNT2 EQU 22h ; Delay counter2

try doing this:

cblock 0x20
TMPOUT
COUNT1
COUNT2
endc
Cool :)


Writing a byte to the GPIO port that doesn't change the values will not
cause any glitches.
What I meant, was that if I need to change 2 bits (say, turn two motors
on, but leave the other bits as they are), is it possible in one
instruction, or would I need to have two conditional jumps, which would
then require "buffering" the input, to make sure both conditions execute
the same, even if an input changes between instructions

--
Danny
 
"Danny T" <danny@nospam.oops> wrote in message
news:41e1970b$0$14619$ed2619ec@ptn-nntp-reader01.plus.net...
Anthony Fremont wrote:

That should work better. ;-) Now stop using 0 and 1 when you
should be
using 'W' and 'F'. Not all PICs are consitant on the values, that's
why
you should use the include file.

LIST P=12f629
INCLUDE "p12f629.inc"

I knew there'd be a way to do this, since there are files for most
PICs
with all this stuff in - just didn't bother to look! Ta :)


Instead of this:

TMPOUT EQU 20h ; Temp output for motors
COUNT1 EQU 21h ; Delay counter1
COUNT2 EQU 22h ; Delay counter2

try doing this:

cblock 0x20
TMPOUT
COUNT1
COUNT2
endc

Cool :)


Writing a byte to the GPIO port that doesn't change the values will
not
cause any glitches.

What I meant, was that if I need to change 2 bits (say, turn two
motors
on, but leave the other bits as they are), is it possible in one
instruction, or would I need to have two conditional jumps, which
would
then require "buffering" the input, to make sure both conditions
execute
the same, even if an input changes between instructions
AND is the way. For example, let's say we have a port value of
b'100101' on the port and we wanted to turn off the first and last bits.
We would AND the port value with b'011110'. This would let bits 1-4
pass thru unscathed, but bits 0 and 5 would be forced off. The code to
do that would be:

movlw b'011110'
andwf GPIO, F

If we wanted to turn them both on at the same time, we could OR
(inclusive OR) the port value with b'100001'. This will turn on bits 0
and 5, but leave the rest unchanged. The code would be:

movlw b'100001'
iorwf GPIO, F

XOR (exclusive OR) is how you 'flip' bits without knowing their current
state. To toggle the first an last bits of the port, you could do
something like this:

movlw b'100001'
xorwf GPIO, F

It's still probably a good idea to use a shadow register (like your
TMPOUT) instead of ANDing and ORing directly to the port.
 
Danny T wrote:
Andrew Holme wrote:

Power supply noise from the motor might be crashing the PIC.

You said I want a 100nF cap from Vdd to Vss.. Just noticed I've got a
100uF... Guess I ordered the wrong ones...

All I currently have are 100uF, 1000uF and 1uF (ceramic). Is what I'm
using ok, or should I use one of the others?

--
Danny
The capacitors are okay, and your connections match your schematic,
but you didn't follow my directions. Your connections force the motor
noise to go out to the ground bus and back on their way to the
capacitors. Those capacitors should be plugged directly into the
source row to keep that noise current local.
--
John Popelish
 
Danny T wrote:
Things just aren't going that well *sigh* :(

I've got a simple circuit with an IC controlling a motor via a MOSFET.
The motor has a diode for back emf protection, two caps, etc., etc.

Anyway... When I power it up, the motor doesn't spin as expected. If I
replace the source/drain legs of the MOSFET with a piece of wire, the
motor runs, suggesting to me either the MOSFET is bust or the chip
isn't outputting a high.

If I wire the pin up to an LED instead of the MOSFET, the LED lights
fine. This suggests the MOSFET...

I replaced the MOSFET with a new one - same problem. I tried
disconnecting the gate and connecting it to 4.5V via a 10M resistor -
motor spins fine!
Power supply noise from the motor might be crashing the PIC. Write a simple
test program which toggles two outputs on for 1-second, off for 1-second.
Make sure the watchdog is disabled. Connect one output to the MOSFET gate.
Check _both_ outputs using a logic probe. You can make a simple logic probe
consisting of an LED and a resistor in series. Do you have a multimeter?
Check the gate-source voltage with that. If you have enough spare outputs,
a slow binary count on three (or more) outputs would be a better check. Do
you have (or can you borrow) an oscilloscope? Look at the power supply
lines on a 'scope. Are they clean? You are blind without test equipment.
 
Rheilly Phoull wrote:

Dare we ask for a circuit ??

VCC
+ 4.5V Drop to 3.1V
------------------------>|-------->|--.
| | 1uF 100uF
| | Ceramic Electrolytic
| 100uF '------------------------.
| || .-----' | |
| .----||-----. | _-_ --- ---
| | || | - |___| 3V Motor --- ---
| | | ^ - | |
| |Vdd __ Vss | | | .--------'
.-------o--o| |o---o---. '-----' |
| .--------o| |o- | | |
| | -o| |o- | ||-+ S |
'-)--------o|__|o- | G||<- N MOSFET |
| MCLR | '---||-+ D |
| | | | |
'---------------------)------' | |
| | |
|-------------------------------------------------'
===
GND
(created by AACircuit v1.28.4 beta 13/12/04 www.tech-chat.de)


--
Danny
 
Danny T wrote:

MOSFET source S and drain D are the wrong way around (in the diagram).

My motor now spins... *But* it doesn't stop when the pin goes low :-\
(if I replace it with an LED, the LED goes off)

Looking at my diagram, surely the motor is grounded via the diode then
the capacitor? Wouldn't this cause it to always be on?

When the pin goes low, the motor slows down, but it's far from stopped :(
And if I disconnect Gate from anything, the motor still spins! :(

If I take the MOSFET out and put my meter on it, it seems to have a
*very* resistance, so I'm not sure it's that :(

--
Danny
 
On Sun, 09 Jan 2005 14:05:24 +0000, Danny T <danny@nospam.oops> wrote:

Andrew Holme wrote:

[snip:diagram]

MOSFET source S and drain D are the wrong way around (in the diagram).

Well, before I got to change them around, I think I've just goose
something - I heard a fizzing and a funny smell (much like when I blow
an LED last week). I can't find which component it might've been -
everything looks ok... :-\
It's probably the MOSFET. When something smokes, it's usually the
power component. BTW, before you replace it, you are sure you have
enough gate voltage available to turn it on?? Your supply rail voltage
is pretty low. What's the threshold voltage of the FET you're using?
If not known, what's the type number of the FET you're using and we'll
tell you...
 
Andrew Holme wrote:

1. Do you have the red probe on the pin and the black probe on ground?
Yep.

2. Is the pin programmed for active pull-up or open-drain? It needs to be
an active pull-up.
Wha?! :-\
I know about weak pull-ups for inputs, but didn't realise there was
anything for outputs...

3. Was anything else connected to the pin when you measured this?
Nope.

I've checked the datasheet (PIC12F629) re Q2, and can't find any mention
of what you suggest - aand weak pull-ups it says are for inputs, and are
disabled for outputs...

If I tie the inputs high (to Vdd), instead of leaving them unconnected
(with pull-ups, they're high anyway), the voltage on both output pins
doubles when high (around .6 and 1.19)

I'm *totally* confused!
--
Danny
 
Danny T wrote:
Andrew Holme wrote:

1. Do you have the red probe on the pin and the black probe on
ground?

Yep.

2. Is the pin programmed for active pull-up or open-drain? It needs
to be an active pull-up.

Wha?! :-\
I know about weak pull-ups for inputs, but didn't realise there was
anything for outputs...

3. Was anything else connected to the pin when you measured this?

Nope.

I've checked the datasheet (PIC12F629) re Q2, and can't find any
mention of what you suggest - aand weak pull-ups it says are for
inputs, and are disabled for outputs...

If I tie the inputs high (to Vdd), instead of leaving them unconnected
(with pull-ups, they're high anyway), the voltage on both output pins
doubles when high (around .6 and 1.19)

I'm *totally* confused!
I think Anthony has spotted the problem. You're switching the outputs on
and off in a loop! Your meter is reading the average value of a
high-frequency square wave.
 
Anthony Fremont wrote:

I looked at the code you posted in a.m.8-bit. What voltage does the pin
put out when it is not connected to the MOSFET? Your loop is turning
the motors off at the beginning. Assuming a clock of 4Mhz, your loop
takes 12uS to execute. 8 of those 12uS are spent with outputs turned
off resulting in a square wave with a duty cycle of 33%, hence the
average voltage is 1.3V. (1.3V * 3) + .7V = 4.6V or to put it another
way (4.5V - .7V)/3 =~1.3V
The motor failed to turn at all, it wasn't just slow (this is after I
got the rest of the stuff the right way round ;))

Do you have external pullup resistors on the inputs? If so, what value?
I did (10K), but it made no difference. Internal pull-ups are enabled,
and I now leave the pins unconnected.

My current circuit is 4.5V to Vdd, with a 1uF cap across Vdd to Vss. Vdd
and MCLR are connected with a 1K resistor. GP4 and GP5 are unconnected
(outputs - I'm putting my meter on these), and GP0, GP1 and GP2 are left
unconnected (I've connected these to ground to test "low" output readings).


How did you come up with your __CONFIG value. It all looks good except
for the '3'. Shouldn't that be a '1'? The datasheet says that other
bit is unimplemented.
I've changed this. I used the drop-down boxes in MPLAB and set the
options, and it generated 3A4. After posting that code, I checked
everything in the datasheet, and changed it to 1A4 after coming to the
same conclusion!

Updated code is below. Setup is as described above...

*dawns*

You're right!! My output is reading really low on my meter, because it's
off for *most* of the time! Stupid fool! I'll change the logic to
"buffer" it (like further down, or I'll call the delay after turning
the motors on).

Don't I feel stupid!

Thanks - it's really appreciated!

--
Danny
 
"Danny T" <danny@nospam.oops> wrote in message
news:41e1686f$0$14577$ed2619ec@ptn-nntp-reader01.plus.net...
Andrew Holme wrote:

1. Do you have the red probe on the pin and the black probe on
ground?

Yep.

2. Is the pin programmed for active pull-up or open-drain? It needs
to be
an active pull-up.

Wha?! :-\
I know about weak pull-ups for inputs, but didn't realise there was
anything for outputs...
Some PICs (many actually) have some open collector output pins. They
are not configurable, you just have to know that they exist and deal
with them appropriately. I checked the datasheet and your PIC (12F629)
does not appear to have any open collector outputs. Open collector
means that the output pin cannot output a 5V driving signal, it can only
pull low. This means that the pin cannot *source* and current, it can
only *sink* it. If the pin is being used as an output pin and you wish
to drive say an LED, you would use an external pull-up resistor to
supply the positive voltage to illuminate the led and then turn it off
by driving the pin low. Open collector outputs are common in the micro
world.

3. Was anything else connected to the pin when you measured this?

Nope.

I've checked the datasheet (PIC12F629) re Q2, and can't find any
mention
of what you suggest - aand weak pull-ups it says are for inputs, and
are
disabled for outputs...

If I tie the inputs high (to Vdd), instead of leaving them unconnected
(with pull-ups, they're high anyway), the voltage on both output pins
doubles when high (around .6 and 1.19)

I'm *totally* confused!
Never leave input pins unconnected, always have some kind of pull-up or
pull-down resistor applied, be it internal or external. The code I saw
in a.m.8 has the internal pull-ups disabled, so I hope you have external
pull-ups applied to the input pins.
 
Danny T wrote:
Andrew Holme wrote:

Check the gate-source voltage with that.

1.15V from gate to source

BINGO. That's wrong: that's not enough to switch the FET on; it should be
almost Vdd.

It's only just over 1V, but the motor is *on*. When the pin goes low,
the pin output drops to exactly 0, but the motor only slows - this
doesn't make any sense?

--
Danny
It makes sense if the gate oxide has been blown and there is a low
resistance, now, between gate and source. Take the mosfet out and
check the gate to source resistance with an ohm meter.

--
John Popelish
 

Welcome to EDABoard.com

Sponsor

Back
Top