NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Support Forum » Motor Code Problem

March 01, 2011
by missle3944
missle3944's Avatar

Hi all, I am experimenting with the motors and microcontrollers tutorial but I have run into a wall. I was able to salvage a 3v brushed motor and a diode. I am using the motor code that was included in the downloads of the motors and microcontrollers tutorial page. But for some reason as soon as I turn the MCU on the motor just starts to spin at max speed. I am also confused as what I do with the 2n7000 MOSFET pins. Also I don't understand why there are 2 pins required of the motor on the microcontroller, being PB3 for continuous control and PB2 for PWM? I have the pushbutton wired to PB4 and the lcd recognizes when I push it because it shows a 1 or a 0.

/ PIN DEFINITIONS:
//
// PB4 - Push button input
// PB3 - continuous motor control
// PB2 - PWM output (OC1B)

Also I think my motor draws too much current because as soon as the motor turns on then the lcd goes to random numbers and jibbrish.

March 01, 2011
by rkuykendall
rkuykendall's Avatar

Hi Missile3944, first thing I think the code is set up for two possible different modes, either full on with the push button or PWM with the temp sensor changing the duty cycle. You shouldn't be using both output pins at the same time. Also you shouldn't be connecting the motor straight to the output pins directly as the motor will draw too much current through the MCU. The mosfet is used as a switch with the MCU connected to the gate and only controlling current, not supplying it.

March 02, 2011
by missle3944
missle3944's Avatar

Hi I do have the motor hooked up to the mosfet but I am unsure what I plug into drain gate and source. Here are some photos of my setup

alt image text

alt image text

March 02, 2011
by rkuykendall
rkuykendall's Avatar

It appears that you've got the MCU connected to the source pin of the mosfet, you want it connected to the gate pin (the middle one). I can't see that you have anything else connected to the mosfet, am I missing something? At any rate you will then connect the motor straight to the positive rail on one terminal, the other terminal will connect to the drain pin of the mosfet. You then connect the source pin of the mosfet to the negative rail and you should be set up.

How did your servo experiments turn out?

Post a Reply

Please log in to post a reply.

Did you know that our USB NerdKit works on Windows, Linux, and Mac OS X? Learn more...