MOSFET/circuit troubleshotting :-\

Danny T wrote:
Andrew Holme wrote:

Have you got the source and drain the right way round now? There's no point
checking the gate-source voltage until this is sorted out. Source should be
connected to ground.

I believe all my problems come down to the one thing - my pic "high"
isn't really high.

I've got two chips, both with the same program burnt (I can post, it it
helps).

They sit "high" until an input goes low, then they go low too.

Using my meter, is seems these outputs are:

GP4 0.3V (way below the min the datasheet says!)
GP5 0.6V

When I make the input low, they go:

GP4 0V
GP5 0V

Both chips do the same, and I can't find anything in the datasheet to
suggest even if I had something silly enabled/disabled, this would happen.

Any ideas?

--
Danny
Without a scope to look at these outputs, you have little assurance
that you are really getting a continuous logic high out of the pins,
and not a train of slim pulses. You might connect a small capacitor
in series with your meter, set to AC volts, and see if you get no AC
(steady voltage) on the logic high test. If you measure more than a
few millivolts AC, you are not getting a steady state output.
You are troubleshooting both software and hardware, simultaneously.
--
John Popelish
 
Andrew Holme wrote:
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've changed my code, it now looks like this:

Start
clrf TMPOUT ; Clear temp output
btfsc GPIO,2 ; If left sensor is high
bsf TMPOUT,4 ; Right wheel on!
btfsc GPIO,0 ; If right sensor is high
bsf TMPOUT,5 ; Left wheel on!
btfsc GPIO,1 ; If front sensor is high
clrf TMPOUT ; stop all!
movf TMPOUT,0 ; Move output
movwf GPIO ; To GPIO
GOTO Start ; Start again

My question is... If I had a third output, the "Stop all!" line would
turn it off. Is there any way to clear two bits and leave the other 6
unchanged, without having to do:

btfsc GPIO,1 ; If front sensor is high
bcf TMPOUT,4 ; stop left!
btfsc GPIO,1 ; If front sensor is high
bcf TMPOUT,5 ; stop right!

Since this wouldn't necessarily be consistant (if the sensor switches
between those lines), which probably means reading from GPIO onto a temp
register, then processing here. Writing bytes with unchanged bits would
be much better!

--
Danny
 
Danny T wrote:

I've changed my code, it now looks like this:

Start
clrf TMPOUT ; Clear temp output
btfsc GPIO,2 ; If left sensor is high
bsf TMPOUT,4 ; Right wheel on!
btfsc GPIO,0 ; If right sensor is high
bsf TMPOUT,5 ; Left wheel on!
btfss GPIO,1 ; If front sensor is low
clrf TMPOUT ; stop all!
movf TMPOUT,0 ; Move output
movwf GPIO ; To GPIO
GOTO Start ; Start again
I've corrected that, the front sensor is low to say stop, whereas the
other sensors are the opposite

--
Danny
 
"Danny T" <danny@nospam.oops> wrote in message
news:41e17daa$0$14618$ed2619ec@ptn-nntp-reader01.plus.net...
Andrew Holme wrote:
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've changed my code, it now looks like this:

Start
clrf TMPOUT ; Clear temp output
btfsc GPIO,2 ; If left sensor is high
bsf TMPOUT,4 ; Right wheel on!
btfsc GPIO,0 ; If right sensor is high
bsf TMPOUT,5 ; Left wheel on!
btfsc GPIO,1 ; If front sensor is high
clrf TMPOUT ; stop all!
movf TMPOUT,0 ; Move output
movwf GPIO ; To GPIO
GOTO Start ; Start again
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"

Put that near the top of your program and then use STATUS, RP0 instead
of STATUS, 5 etc... You would also not have to define all those
constants yourself.

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


My question is... If I had a third output, the "Stop all!" line would
turn it off. Is there any way to clear two bits and leave the other 6
unchanged, without having to do:

btfsc GPIO,1 ; If front sensor is high
bcf TMPOUT,4 ; stop left!
btfsc GPIO,1 ; If front sensor is high
bcf TMPOUT,5 ; stop right!

Since this wouldn't necessarily be consistant (if the sensor switches
between those lines), which probably means reading from GPIO onto a
temp
register, then processing here. Writing bytes with unchanged bits
would
be much better!
Writing a byte to the GPIO port that doesn't change the values will not
cause any glitches.
 

Welcome to EDABoard.com

Sponsor

Back
Top