My First Project

the_norris

New Member
Hi all

Been lurking with intent for sometime. :)

Well I've started on a project to build a simple PWM controller for a model railway. I got myself a kit/breadboard and PICAXE 14M.

So far I've build the Voltage regulator circuit - power from a bench PSU. This works great.

Then I gotthe chip and download circuit working after a bit - found that the download socket's pins are a bit too short to work on a breadboard well. - fixed.

Next step was to read a linear Pot. - used the debug command to output to reading back to laptop. - worked, yippy! :)

The only problem is that i'm trying to use PWN to drive a IRF530. Here are my questions:

1) Which pin of the 14M should I be using for the output of PWM?
2) I'm following the circuit in the picaxe_manual3 - page 7 for the IRF530 - i'm not sure from the circuit diagram where source and drain should connect to 0v or 12v - gate is to the picaxe.

Thanks for any help.

Phil
 

SilentScreamer

Senior Member
Look at manual one appendix C for which pins to use (page 79). On the 14M it is the physical pin 5.

Alternatively use hpwm (so you have a choice of 4 different pins for this), though I'm not entirly sure on the differences so I'll leave it to the experts :D
 

lbenson

Senior Member
Anyone working with the 14M beyond the basics will want to be familiar with Appendix C – Configuring the PICAXE-14M Input-Output Pins in Manual 3--p 79 in V 6.7. For the MOSFET, I'd defer to others, but for the circuit you cited, your 12V goes where the 6V is shown, and the 0V for both power supplies are tied together. Search the site for MOSFET for many, many sources of information. Much depends upon your current draw. For PWM rather than simple on/off switching, many caveats apply--if your MOSFET gets hot, check 'em out.
 
Last edited:

the_norris

New Member
Thanks for the replies.

Does the SOURCE or DRAIN of the FET go to the 12v?

I've got both supplies 0v tied together. In fact its the same supply - 12v from bench PSU split to feed the Voltage regulator and the supply voltage out to the model train.

Phil
 

adub

New Member
In this case the drain goes to the load and the source ties to ground.

I have a few train parts laying around....some old track and cars and an engine that looks new....I'd be interested in seeing what schematic you're using for the power supply.

There are lots of threads about PWMing mosfets on the forum....consensus seems to be use a driver chip. Do a search for mosfet. Something should come up.

If you're only drawing an amp or so you can probably get away without heating up the mosfet too badly.

Good luck.
 

the_norris

New Member
Hi

Once again - thanks for the replies.

Attached is a quick drawing for the output. I add the 22K resistor - read somewhere that this will pull down the GATE to 0v when the ouput of the PICAXE is low. (stopping it floating)?

Phil
 

Attachments

westaust55

Moderator
Hi

Once again - thanks for the replies.

Attached is a quick drawing for the output. I add the 22K resistor - read somewhere that this will pull down the GATE to 0v when the ouput of the PICAXE is low. (stopping it floating)?

Phil

Phil,

The pull down resistor that you have mentioned is described on PICAXE Manual 3 page 7 which you have also referred to:
Therefore on sensitive circuits it may be necessary to include a 100k pulldown resistor on the MOSFET gate. This holds the gate off until the PICAXE actively drives the output.
Would not think that a 22kOhm value in lieu of 100kOhm would cause problems.

From your earlier question, do you have the FET transisitor connected correctly?
 

Attachments

Last edited:

the_norris

New Member
Hi

Can confirm that the FET is connected correctly.

I took a step back. Using simple loop of code - to pwm out 25%, 50%, 75% duty with 2sec pause between each step.

I can see the voltage step up every 2 sec when connect a meter to PIN5.

SO I know the code is good.

Might be the FET is dead? Is there a way to test it?

Phil
 
Last edited:

inglewoodpete

Senior Member
To test an IRF530:
* Ensure power supply is OFF
* Connect source to 0v rail
* Connect gate to 0v via a mid-range resistor eg 4.7k to 47k (for safety)
* Connect drain to +5 or +12v power rail via another resistor (say 1k to 10k)
* Connect voltmeter on 20v range between drain and 0v
* Meter should read 0v
* Apply power
* Meter should read voltage = +ve rail (+5 or +12 v)
* Connect gate to + rail
* Meter should read voltage = 0v or very low value

If the FET does not give voltage readings as above when it is connected correctly, it is damaged. MOSFETs are very easily damaged ESD (static). If it's winter in your part of the world, you have very low humidity in your house and you have not been taking appropriate ESD precautions, the MOSFET could have irreparable damage.
 

Dippy

Moderator
Can you just check MOSFET to make sure it is IRF530Nxx or IRF530Pxx.
There is an IRF5305SP which is a P Chan.


I'm not saying it's impossible to pop a power MOSFET with static but I have yet to manage it - even after rubbing the cat. Must be my sweaty palms.

Try Pete's suggestion first.

Then replace your 'motor' in your drawing with an LED+1k0Res and repeat your code.
Does it vary in brightness as it runs through?

The 22K is only there to force the gate low (and switch FET off) when PICAXE is starting up or if PICAXE unpowered but rest of circuit is powered. As the PIC o/p driver is sink/source it will do all the high/low stuff once powered and running.

However, I would put in a 'precautionary' low val res from PICAXE to MOSFET gate. eg 47R to 100R.
When doing fast PWM there will be a repeated intial high discharge from MOSFET gate (as it has capacitance).
The PIC gate may be able to handle it, but protecting your PICAXE for the outrageous cost of a penny may be prudent.

For fast efficient running of MOSFETs under fast PWM then use a MOSFET driver circuit or driver ic.
Direct PIC drive is not 'man' enough. Fine for slow switching but not for fast PWM.
Big and brief currents are needed to drive the gate properly.
I won't elaborate as this has been covered in great detail over the last few months.
So, spend 10 minutes having a search.

Note: without a driver connected to the 12V you won't get the best out of this MOSFET. It isn't Logic Level.

Lastly, can you be a bit more careful with your definitions.
Your drawing says "14M" and "Pin5".
Well for a 14M, pin 5 is, in fact, Input2.
I'm sure you probably mean "Output5" on Pin8.
These ambiguities can cause horrendous confusion, so be careful please.

PS. It is perfectly easy to test a MOSFET. Stuff it into a breadboard.(For an N Channel). Connect source to 0V. 22K res between gate and 0V. LED+1kRES between +V and drain. Then apply a res (a low value) between +V and Gate. LED should come on. Measure with DMM on volts between Drain and 0v. Volts should be very low.
In fact, as you have read the Data Sheet, you should be able to predict it approx.
Conversely if you measure the current you could calculate the MOSFET's res.
You can also see how the MOSFETs res changes as you change the supply voltage and gate voltage.
(This is part the same as Pete's test above with a lesson added FOC).

Sorry, I've blathered too long so I doubt if you'll read all this... ;)
 

the_norris

New Member
Look at manual one appendix C for which pins to use (page 79). On the 14M it is the physical pin 5.

Alternatively use hpwm (so you have a choice of 4 different pins for this), though I'm not entirly sure on the differences so I'll leave it to the experts :D
Was using physical pin 5 as pointed out above. but thanks for the tips to test a FET. Will have a look over the weekend.

Might be easier to use a transistor? Any recommedations - need to handle 12-14v@ 2amp.

Phil
 

Dippy

Moderator
Re: pins. Oh PWMs.. yes, beg pardon.

A MOSFET is a transistor.
Do you mean a bipolar with b/c/e?
Could do. Personally, I would persevere with MOSFET.

Oh there will be dozens that can handle that.
Go to Farnells website, type 'transistor' into search.
Then do a parametric search.
I haven't got time - the pubs are open :)
 

BeanieBots

Moderator
I'd also suggest you stick with the transistor you have.
The IRF530 is slightly overkill being 100v @ 14A but will be fine.
If you need to buy a new transistor, consider the IRF520 as used on some of the PICAXE project boards. It's still 100v but only 9A which is more than enough for your 2A requirement. Being a slightly lower spec means it also has less gate capacitance which means it won't be such a problem to drive when using PWM.
 

the_norris

New Member
Hi all

Thanks for all your help/tips. Will take on broad what has been say and have a play at the weekend - something called 'work' gets in the way! :)

In response to Dippy - the model numbers on the FET are: IRF530A with 213 above it and a big 'F'. Doing a search for datasheet I found this PDF:

http://www.fairchildsemi.com/ds/IR/IRF530A.pdf

Phil
 
Top