control motor with a potentiometer

kenwood120s:
With analogRead(3) you're reading the ANALOG pin A3, and since it's not connected to anything it's just picking up some random atmospherics. If you ground that hole or take it to 5V with a wire you'll see it becomes 0 or 1023. I just stuck a wire in one of my pins and the value changes as I wave the wire around.

Gotcha.

part 2?

shmilylauber:
Gotcha.

part 2?

Patience: see #19

OK the the transistor that i am using: MOSFET IRF520N.

'bout the patience: you know when they hand out patience to everyone in heaven before your born...? yeah, well they handed it to me on a fork... :stuck_out_tongue:

shmilylauber:
OK the the transistor that i am using: MOSFET IRF520N.

Ok well that's an n-channel mosfet and your diagram has the symbol for a p-channel, and in fact afaik has it wired as a p-channel. (But that's the diagram with the pot wired wrong and it's a bit confusing)

Have a look at this and compare the relative position of the motor/mosfet as you have them, and the way the diagram in the link shows an n-channel.

But that said, you really want a logic level n-channel mosfet, where 5V on the gate will switch it, which yours isn't.

But that said, you really want a logic level n-channel mosfet, where 5V on the gate will switch it, which yours isn't.

While the IRF520 isn't ideal, the device will certainly turn on with 5 volts on the gate (with a low enough Rds) for what the OP is doing.

OP:Please post photos of your circuit so we can verify your wiring. Ignoring the fact it was requested back in post #6 and we're at twenty three posts and counting, it's not an unreasonable request.

avr_fred:
While the IRF520 isn't ideal, the device will certainly turn on with 5 volts on the gate

Ok fair enough but it looks to me it's on the wrong side, since the symbol he used and afaics the actual position of the mosfet is that of a p-channel.

here's my wiring pic:

if that isn't showing up try this:

The symbol that i used does not reflect the actual mosfet in my circuit. i made the schematic on fritzing and this was the only mosfet i found there. First time i'm using that software, don't really know how to use it.

shmilylauber:
The symbol that i used does not reflect the actual mosfet in my circuit.

Fair enough but I think as an n-channel mosfet it should be wired on the other side of the motor; yoi do have it wired as a p-channel

Meaning it should control the voltage going in? And not controlling the connection to ground?

Did that. Doesn't really change anything.

Your wiring picture is correct for your original sketch, ignoring the analogRead(motorPin) issue.

It may well be a flaky mosfet if the motor speed is just creeping and does not change. Measure the dc voltage from the black lead of the motor to gnd over the analog input range. The voltage should be inversely related to the pot setting. Zero pot equals 5 volts and 1023 on the pot (or wahatever max is) should be approaching zero volts. There should be some linear range in between but that depends somewhat on your meter.

If the voltage never changes, it's a bad or out of spec mosfet.

Ok. The voltage changes from 741 mv to 0.51 mv. Which i think makes no sense. as i supplied 6 volts to for the motor, which is supposed to get passed on, no?

And as someone suggested here that i change the mosfet to control the power not the ground. Did that, and now the mosfet gets really hot when i connect power.

thanks,
shmily

How about a 2n2222 tranistor? is that any good? that's the only other transistor i have lying around....

And what about an H bridge? Do i need a mosfet with that?

shmilylauber:
And as someone suggested here that i change the mosfet to control the power not the ground. Did that, and now the mosfet gets really hot when i connect power.

You should check that the wiring of your n-channel mosfet looks like this.

Are you sure that's the correct picture?

Cause that doesn't look like a mosfet to me...

Sorry, fixed: it was linking to a pic (wrong) AND the URL of a site (correct). Copy/paste finger trouble.

It's the Nick Gammon page I linked to earlier: I wasn't sure your diagram was correct earlier, confusing with the pot connected wrong and all, and using the wrong mosfet symbol :wink:

But it does look like your circuit in your photo is correct according to Gammon's diagram except you don't have a pull down on the gate that Imentioned previously.

I just re-looked at your diagram, which I thought was switching the wrong side, but it is correct, albeit with the symbol for the wrong mosfet. I forgot the symbol of n- and p- channel mosfets have D and S reversed.

Moral of the story: use the correct symbol...

Point taken. Any idea what the problem could be with the motor not going all the way down?