Pages: [1]   Go Down
 Author Topic: Project 09 (Motorized Pinwheel) problem - motor spins forever  (Read 3817 times) 0 Members and 1 Guest are viewing this topic.
Offline
Newbie
Karma: 0
Posts: 7
 « on: May 29, 2013, 03:24:00 pm » Bigger Smaller Reset

Hello,

being a student in software development, I am currently learning to program with an Arduino Uno with the Arduino Starter Kit (it is great, by the way !).

I arrived to Project 09 (Motorized Pinwheel) and I run into a problem that may be simple but that I cannot seem to resolve :

I made the circuit according to the drawing in the book, but when I plug the 9V battery to the 9V snap, the motor immediately starts spinning, without stopping.

If I understand well, the goal of this project is to make the motor spin only when we press the switch.
But therefore in my case, it makes nothing (the motor spins, the switch being pressed or not ...).

I really don't understand what I am doing wrong, so I am today asking for your help !
Maybe I didn't understand the real purpose of this project, and/or I'm missing the obvious (I think that's it ! ).

I put a photograph of my circuit in attachment.
Because everything doesn't appear on it : the red and black wires on top right lead to the 9V battery snap and the ones at bottom right lead to the motor (like in the book's circuit drawing).
I believe that it perfectly fits the schema, so I really don't understand !

I also put the sketch I upload to my Arduino, despite the fact that I don't think it changes something...
(it is a complete copy-paste of the book's code, if there is a problem with it, I'm missing the obvious)
Code:
const int switchPin = 2;
const int motorPin = 9;
int  switchState = 0;

void  setup() {
pinMode(motorPin, OUTPUT);
pinMode(switchPin, INPUT);
}

void  loop() {

if (switchState == HIGH) {
digitalWrite(motorPin, HIGH);
}
else {
digitalWrite(motorPin, LOW);
}
}

Thank you for your time, and bear with me if I'm doing something obviously wrong, I'm a complete beginner at electronics
 IMG_20130529_214540.jpg (202.58 KB, 667x500 - viewed 150 times.)  IMG_20130529_214540.jpg (202.58 KB, 667x500 - viewed 92 times.) Logged

Ohio, USA
Offline
Newbie
Karma: 0
Posts: 12
 « Reply #1 on: May 31, 2013, 07:51:25 am » Bigger Smaller Reset

I don't have the book or schematic in front of me, but from the pictures it looks like you're wiring the motor directly to the power.  You have the hot/red wire directly connected to the right-side power strip (assuming that the 9v supply is attached at the top) and you have the black  connecting through the diode to ground.  Where's the "switch" to turn that off?

EDIT (6/1/13)
Am now at home, looking at the diagram it seems that the diode goes to the positive bus, not the negative bus as your picture shows...
 « Last Edit: June 01, 2013, 08:52:17 am by dean_1230 » Logged

Offline
Newbie
Karma: 0
Posts: 7
 « Reply #2 on: June 02, 2013, 04:23:25 pm » Bigger Smaller Reset

Well maybe I was wrong on that point, but the thing is that I tried again today (with the diode being at the right place !) and guess what...

Now the motor never spins... (I mean in the circuit, if I plug it only in circuit with the 9V battery, it still works)

Actually I think that at my previous attempt, I inverted the battery snap poles, plugging the (-) one to the battery's (+), and vice versa.
It may explain why it was spinning before, and why it isn't now.
The thing is that when I press the button, it still doesn't spin...

I begin to wonder if, during my many manipulations trying to get it to work, I haven't broken something like the transistor.
Especially if, as I think, the current has been reversed at any time.
(If that's it, given that I tried with the two transistors bundled with the kit, they may be both broken   )

By the way this may seem very silly, but, following the book's circuit schema, when they say the metal tab to be "facing away from you", they of course mean that the face with the little black rectangle thing must be facing the Arduino, right ?

I must admit I'm running out of ideas ...

EDIT: After having changed all the pieces of the circuit (push button, transistor, resistor ...) I finally got it to work as expected ! This way, I'm not afraid anymore to have something broken since I know it worked at least once. Thanks for the help !
 « Last Edit: June 03, 2013, 12:13:58 pm by Pando » Logged

Offline
Newbie
Karma: 1
Posts: 9
 « Reply #3 on: August 09, 2013, 06:41:05 pm » Bigger Smaller Reset

Hi guys.

I'm in the same condition of Pando, I plug the 9v battery and the motor never stop to spin, and I haven't solved the problem changing all the pieces (mosfet, button...) and I have the same code...what I can do to solve?

I tried with the second scheme too, but the result is the same...
 IMAG0293.jpg (1229.55 KB, 2560x1440 - viewed 56 times.)  IMAG0292.jpg (1307.28 KB, 2560x1440 - viewed 47 times.) « Last Edit: August 10, 2013, 04:23:37 am by danipisca07 » Logged

Offline
Newbie
Karma: 0
Posts: 2
 « Reply #4 on: September 01, 2013, 04:17:13 am » Bigger Smaller Reset

I tried using pin 8 instead of pin 9 and it worked!
I think it could be a problem in using PWM pin 9...
Another solution could be to use analogWrite(9,255) instead of digitalWrite(9,HIGH) and analogWrite(9,0) instead of digitalWrite(9,LOW).
 Logged

Offline
Newbie
Karma: 0
Posts: 4
 « Reply #5 on: September 17, 2013, 12:36:54 pm » Bigger Smaller Reset

I am using the wiring from project09 and analogWrite(PWMpin,speed) to vary the rotation freq of the dc motor...

The problem is that the speed varies from a max (analgWrite(PWMpin,255) to a minimum (analogWrite(PWMpin,0) but it never stops. Even if I write analogWrite(PWMpin,0) it doesn't stop.

Any Idea?

 « Last Edit: September 17, 2013, 12:52:16 pm by sdragou » Logged

Venezuela
Offline
Sr. Member
Karma: 12
Posts: 392
Ground.......ground........always ground
 « Reply #6 on: September 17, 2013, 01:41:31 pm » Bigger Smaller Reset

Hello sdragou,

Verify that your PWMpin is not asigned to pins 5 or 6.
According to Arduino's analogWrite 'Notes and Known Issues', see http://arduino.cc/en/Reference/analogWrite

Quote
The PWM outputs generated on pins 5 and 6 will have higher-than-expected duty cycles. This is because of interactions with the millis() and delay() functions, which share the same internal timer used to generate those PWM outputs. This will be noticed mostly on low duty-cycle settings (e.g 0 - 10) and may result in a value of 0 not fully turning off the output on pins 5 and 6.

If that is your case, then, it explains the behavior of your project. Regards!

P.S. Remember also that the motor slows down for certain amount of seconds.
 Logged

 Pages: [1]   Go Up