Wheres my voltage? (what am I doing wrong?)

Hey gang..

I am trying to throw a motor into my project..

when I directly wired things up.. using the motor, diode, transistor and resistor, IN-LINE.. (ie: no pcb)... things seemed to work fine for testing.

I went ahead on the project.. worked on other aspects.. and I then home etched a little PCB to solder my diode, transistor, and resistor to, as well as some other pads to solder the motor +/- to.. the battery +/- pads.. and even pads for the custom Arduino board to be soldered to..(power pads & trigger pad to control the transistor)

I was under the impression it was all 'correct'..

the battery pads and arduino pads are connected (so Arduino can be powered directly from battery pack)..

from the battery pads elsewhere.. is where I have the transistor set-up to power the motor..

I dont know if I fubar'd the board layout somehow? (seems fairly straight forward though?..and easy to follow/do)..

or if I just had it wrong to begin with..??

either way the results I am getting is a small 'jog' in the motor.. doesnt even seems to move forward.. just sorta shake a quick second...

I took out the motor (which does have two caps going from + lead to body.. and - lead to the body).. and tested it directly on a power supply seems to work/run fine.

I hook up a meter to the motor +/- wires.. and I seem to be only getting 0.32 volts???

whats going on?

the only difference/change in the schematic is that I did NOT use a 2N2222 transistor.. I used a MPS222A transistor...

the other components I have in the mix are as follows:

custom Arduino board, that is a 5v Arduino circuit merged with a Adafruit WaveShield (all-in-one, SMD..etc)

(so DAC, AMP, SD socket..and Arduino circuit).

3 switches (shouldnt have any bearing)

and a RGB SMD 5050 led (that isnt even in the mix so far when testing the motor)

I took my PCB I made for this.. tested the MOTOR output pads.. 0.32 volts..

I test the battery in pads.. 8.30+ volts.. (2 x 3.7v battery in side by side pack)

Is it the transistor I picked?

Package says:

Vcbo: 75v
Vceo 40v
Vebo: 6v

Ic: 600mA
Ft: 300MHz
Disspation: 625Mw

here are pics of the .brd and schematic:

I am not sure what Im doing wrong.. hoping someone can point out my mistake!

thanks!

The transistor may a diferent pinout check the data sheets.

Mark

Like suggested check all your pinouts first (diode, transistor, etc). Check your PCB for losses or flaws. The PCB looks pretty clean so if you are getting the right voltage from the battery it should transfer fine. i can't picture what your motor out looks like.

Im betting its the pinout on the different transistor.

the bag has them all labeled the same way.... but reading some of the comments on RadioShack.com I think they are wrong.

(which would make sense)

Im hoping thats all it is.. (which is a simple fix)

re: the motor is a simple hobby motor picked up from the local science surplus store.

said 3v-9v running range (seems a bit big?)
200-300mA stall

here are some pics:

these were all mock up picks..before wiring/pcb making..etc

I did a quick google on the part numbers which gave me the datasheets and the pinouts are the opposite way round.

Mark

for BOTH???

man not only were there other transistors in this variety pack that were not noted... the pin outs are wrong too?

ok.. so I tracked down the problem.. but I have no clue WHY its the problem..

after swapping out transistor after transistor.. and even swapping the pinout orientation.. I got the same results.

I decide to go back to my old in-line motor.. test it with this code.. (same results now.. wouldnt run/rotate properly)

I then took some old code I had did.. when the motor portion was working fine.. (I save after 'accomplishments/goals' are met and build on from there)

loaded it up.. worke fine on the old in-line circuit motor....

swapped out old motor for new'final motor on the pcb.. workd fine!!!

WTF!???

I compare the old code to the new more robust (final) code..

and dont notice any major differences relatign tot he motorPin high/low toggling..

EXCEPT that in my new code..

I had a print_ln() commented out.. and in the old code.. it was STILL there:

New code: (breaks the motor)
//putstring_nl("................motor off...");
digitalWrite(motorPin, LOW);

Old code: (works just fine)
putstring_nl("................motor off...");
digitalWrite(motorPin, LOW);

I thought I was nuts.. so I commented it out again.. and again.. motor breaks.. un-comment.. motor works as it should..

can anybody explain to me WHY? it seems the time it takes to print the 'line' gives the motor enough time to 'start/play' before being quickly toggled off.

thanks!!

I suspect without posting the complete sketch it's only going to be a wild ass guess what the reason is. And I don't even have a WAG. :wink:

Lefty

I can post the code(s).. (both) to compare..

but they are NOT pretty.. lots of commented out lines..etc. for testing and notes..etc (yadda yadda)

and Im sure that my code is not 'great' (or pretty).. or as efficient/lean as it could be either.. (I hope that doesnt turn into the focus!) :wink:

let me clean it up a bit.. then post it..

here we go:

In the play file function...

you see this:

void playfile(char *name){
  //yadda yadda....
  putstring_nl("................motor off...");
  digitalWrite(motorPin, LOW);
}

if I leave the putstring_nl() in there.. works as it should (or at least as I am expecting it should)..

if I comment it out.. the motor stops working correctly..

my thinking now is that the putstring_nl() is giving the motor a smidge more time to actually turn on/run/move... where as otherwise it just toggles off too fast?

the motor is only suppose to be 'jogged' quickly.. (to rotate a gun barrel.. ie: think gatling gun type effect).. 1 time on trigger press.. in auto mode.. it obviously repeatedly 'jogs/toggles' the motor.. (looking like a continuous rotation...but it just continuous toggle/jogging in reality)

to be honest.. Im happy I 'stumbled' upon this.... and extra happy its working as it should.. (or as I "want it to" I'll say.. regardless of how I got here) LOL..

but I am curious as to WHY?

thanks

code wouldnt fit.. here is link to a text file of it:

http://dmstudios.net/misc/blasterOS_v1.txt

hey retrolefty-

any chance you took a peek?

thanks

xl97:
hey retrolefty-

any chance you took a peek?

thanks

Took a peek, and it's well above my software pay grade, I'm a hardware guy, I just play a software guy on this site. :wink:
But perhaps others will check it out.

Lefty

HAHA.. better than me I suppose..

I 'play' both hardware and software guy! LOL :slight_smile:

What I need is PaulS to rip it apart and tell us (and when I say 'us', I mean,.. me) why that putstring_nl() line makes things 'work'.. and commenting it out breaks it.
(but I dont know if Im 'up' for all the other critique on the rest of the code....... better be in good shape and have your i's dotted and t's crossed if PaulS is gonna peek at it!!)) :wink:

Hi,

From your function playfile()

  putstring_nl("................motor off...");
  digitalWrite(motorPin, LOW);
  wave.play();

Unless I've missed something you (in all cases) call playfile() just after you turn the motor ON is this correct.

In playfile() you turn the motor off!!!

So you are hoping that the time it take for the code to execute will be long enough for the motor to do something.

So try a short delay in stead of the putstring_nl().

Mark

that is correct..

its a quick 'jog' of the motor to spin and wind out...etc..

I thought delay()'s were a no-no..

especially if you have other things going on in the code?

(which I do.. audio, leds..etc)

I'll give it a try either way when I get home to see if affects anything.

(thanks to PaulS for just recommending same thing in an off-topic thread)

If the delay does cause a problem then a for loop that counts to 10,000 or even 100,000 should do the trick.

Mark

worth a shot.. :slight_smile:

is it 'bad form' to just leave IN the putstring_nl();??

and do I need to have Serial.begin() enabled/started for putstring/putstring_nl lines? or does that only apply to Serial.read/write commands?

thanks

Bad form? well sort of, but I am just assuming you would like to get rid of all debug code!

Mark

PS I think a realy good way to fix this.

Add this or somthing very like it to your code

// add the following
unsigned long motorStart = 0;
boolean motorOn = false;
int motorRuntime = 200;// length of time to run motor in millis

void doMotor(){
  // motor control stuff
  int curTime = 0;
  if (motorOn){
    curTime = millis();
    if (curTime-motorStart>motorRuntime){
      motorOn = false;
      digitalWrite(motorPin, LOW);
  }
}

void startMotor(){
    digitalWrite(motorPin, HIGH);
    motorStart = millis();
    motorOn = true;
}

replace your "digitalWrite(motorPin, HIGH);" calls to startMotor();

and at the start of loop add a call to doMotor();

This should do the job.

Mark

xl97:
I can post the code(s).. (both) to compare..

but they are NOT pretty.. lots of commented out lines..etc. for testing and notes..etc (yadda yadda)

Given that you've already found the critical part of the code that provokes the error, I suggest you use that knowledge to write a sketch that demonstrates the problem as simply and directly as possible. That way, people can concentrate on the code that causes it, rather than wading through code which is largely irrelevant.