Monday 24 September 2012

Spin motor spin.. please? come on SPIN WILL YOU!!!

The Arduino spin motor spin does not seem to work as smoothly as the Arduino code book would like us to believe. The myth is yet to be solve but it seems that the transistor is to blame for the mishap of the motors movement.

First thoughts were that one needs the 330 ohm resistor instead of the 10k.
Second that the diode (one way value) is pointing the wrong way.
..Perhaps the positive and negative motor wires are the wrong way around.

first lets have a look at the making of the transistor. Below is a handy site which explains the transistor in english and will aid in your understanding of this revolutionary tool


 Basically though - the transistor has a positive or collector (typically to the left of the flat part) and a negative or emitter (typically to the right of the flat part). The current will go from positive to negative therefore it goes from positive to collector and emitter to earth. The other prong (the middle one) is the thing that triggers the transistor - it receives a signal and the circuit works - no signal - no transistor - no circuit.

Now, the thing that absolutely baffles me is that to get this thing to work I have to connect the transistor to the circuit backwards. With the current flowing into the emitter and then coming out of the collector to ground - IT WORKS!

First I thought that maybe the transistor I had was built backwards?

data sheet time.

no. not the answer.

Is the diode pointing the incorrect way?

no, make sure that the diode (the black band points to the direction you want the current to flow) is pointing  from positive to negative and it will control the speed of the motor. If it's the other way around the motor speeds up substantially.


A diode makes sure that the current flows one way and avoids a backwards short circuit.

The diode in our case is meant to create a loop surrounding our motor. I guess this is to make sure the current doesn't flow back through the motor which would stall it.

Is the motor the wrong way around?

No, it totally doesn't matter it just changes which way the motor spins.

The circuit is clearly working as if you just connect the motor to 5v and GND it goes ballistic, so what is going on? The other odd phenomenon which occurs is:

IF I SET IT ALL UP ACCORDING TO THE BOOKLET AND SWITCH THE 5V AND GND IT WORKS! 

After all of this however if you set it up correctly (as per the book) making sure that:
-the diode is pointing the correct way (black strip up towards 1)
- you use the 330 ohm you can then control the motor.
- that the flat part of the transistor is facing j (contrary to what I just told dan)
It will work wonderfully.I decided to give the instructions one last red hot go - this time it worked... I think this is going to be one of those long frustrating semesters.

conclusion - not sure what happened tonight however the circuit seems to work if you put the diode and transistor backwards however the code then doesn't work.

CODE03 lesson 3

IF ALL ELSE FAILS READ THE INSTRUCTIONS -  IF THAT FAILS LISTEN TO PAUL. 

Time to code my motor. Yay!

Adding the light sensor was pretty straight forward after we got them working.
I was all about grabing the value from the analogRead function and mapping it to 0 - 255 and applying that to the engines on/off function. Lastly we re jigged the code to make it more responsive to the changing light.

Lastly I managed to snap the cord off my motor, which concluded my evening and this post.

P.s to Stephen - I know the colour scheme I'm just pretty colour blind thus becomes a little frustrating whilst at home.

No comments:

Post a Comment