Seeking a little bit of assistance [Mosfet/PWM]

dotc0m

New Member
Good evening ladies and gents

I've been working on a little project and i'm having problems with the PWM output of my picaxe 18m2.
The idea is to have the ds18b20 read a temperature and the 18m2 adjust the speed of a 5v motor accordingly.

The MOSFET I am using (i'm unsure if its actually suitable - i'm new to this sort of electronics building), is a FQP30N06L n-channel mosfet. I have tried attaching the motor and supression diode (1n4001) on both the D and S side of the mosfet - however i only seem to get the motor running at low speed and the microcontroller does not alter it based on the speed.

This is the code i have so far:
Code:
symbol temperature = b1		;Rename b0 variable to temperature

main:
readtemp c.1,b1
debug
pause 500
serout b.2, n2400, ( 254, 1 )					; Clear OLED display
pause 50								; pause to clear
serout b.2, n2400, ( 254, $80 )				; First line of display 
serout b.2, n2400, ( "Temperature" )			; Display "Temperature" 
serout b.2, n2400, ( 254, $C0 )				; Second line of display 
serout b.2, n2400, ( #temperature, "C" )			; Display the temperature 
select case temperature
case <=20
	pwmout B.3, 99, 119
case 21 to 25
	pwmout B.3, 99, 159
case 26 to 30
	pwmout B.3, 99, 199
case 31 to 35
	pwmout B.3, 99, 231
case 36 to 40
	pwmout B.3, 99, 267
case 41 to 45
	pwmout B.3, 99, 299
case 46 to 50
	pwmout B.3, 99, 319
case 51 to 55
	pwmout B.3, 99, 359
case =>56
	pwmout B.3, 99, 399
else
	pwmout B.3, 99, 0
endselect
wait 2
goto main
any help would be appreciated - i can draw up a little circuit diagram if that would help.
regards
 

hippy

Ex-Staff (retired)
If you just use PWMOUT commands in your program; does that alter the fan speed ?

Code:
do
  pwmout B.3, 99, 119 : pause 2000
  pwmout B.3, 99, 359 : pause 2000
loop
 

dotc0m

New Member
If you just use PWMOUT commands in your program; does that alter the fan speed ?

Code:
do
  pwmout B.3, 99, 119 : pause 2000
  pwmout B.3, 99, 359 : pause 2000
loop
It doesn't i'm afraid. I'm at a bit of a loss as to what i've done wrong.
 

nick12ab

Senior Member
It doesn't i'm afraid. I'm at a bit of a loss as to what i've done wrong.
Sounds like the MOSFET is connected backwards and the load is being powered through the body diode.

The source of the MOSFET should be connected to 0V, then the motor connected between the drain and the power supply.

If this is not the case, please provide your circuit.
 

dotc0m

New Member
Sounds like the MOSFET is connected backwards and the load is being powered through the body diode.

The source of the MOSFET should be connected to 0V, then the motor connected between the drain and the power supply.

If this is not the case, please provide your circuit.
circuit diagram for web.png

thats pretty much how i have the mosfet connected. picaxe output on G, motor connected to Drain and source to 0v
 

nick12ab

Senior Member
thats pretty much how i have the mosfet connected. picaxe output on G, motor connected to Drain and source to 0v
Have you tested the MOSFET?
Connect the gate to 5V (disconnect it from the PICAXE) and the motor should run at full speed.
Connect the gate to 0V or leave it pulled down (check both!) and the motor should not turn at all.

Do you really have no capacitors between 5V and 0V in your circuit?
 

rossko57

Senior Member
Note; if this is for a computer case fan or suchlike, they sometimes have their own speed controller built in. PWM'ing the supply to one of those won't work very well.
 

rq3

Senior Member
Your schematic looks fine, except for the lack of bypass capacitors across the power supply, per Nick12AB. The MOSFET you have chosen should also work fine, assuming your 5 volt motor isn't drawing obscene amounts of current.

However, your MOSFET is a pretty antique and slow device. And your're trying to drive it with a 10 KHz PWM signal. Verify your wiring, add decoupling caps, and use the PWM Wizard to drop your PWM frequency to something on the order of 100 Hz as a start. If it goes, you can work up from there. Although, as Nick12AB also said, if you can't turn the motor ON and OFF just by pulling the MOSFET gate high and low (manually, with a wire, while disconnected from the picaxe) then you certainly can't PWM either.
 

inglewoodpete

Senior Member
View attachment 19406

thats pretty much how i have the mosfet connected. picaxe output on G, motor connected to Drain and source to 0v
Hmm. That drawing does not include the 10k + 22k "download circuit" resistors. They form an essential part of any PICAXE configuration - the PICAXE will not run reliably without them, especially when there is an inductive load in the circuit.
 
Top