Powering 12V motor through shield and external power

Hello everyone,

Let me begin by saying I'm completely new to Arduino. I am attempting to use the Arduino as a relay to turn a motor different directions based on input voltages. I am using the Uno with a Seeed motor shield.

-I created the code, and bench tested the setup with success....but only attempted using the Arduino USB as a power source (with low voltage motor). -I then connected the setup using 12V external power supply to the motor shield (with no motor connected) and saw 9v at the motor jacks, reversing polarity as intended. -When I hooked up a 12V (0.6A max) motor, i'm seeing reversing polarity as intended, but only at 2.7V.

Any ideas?

I apologize in advance if this has been covered.

Thanks!

What is the 12V supply? Can it generate enough current? Are you using PWM?

Circuit diagram?

Is that 12V current going to the motor via the Vin header? Take care on the current draw - Vin is connected after the reverse polarity protection diode, so you will see some voltage loss there, and the diode is only rated for 1A.

Otherwise, provide a link to the motor shield.

I then connected the setup using 12V external power supply to the motor shield (with no motor connected) and saw 9v at the motor jacks, reversing polarity as intended.

If by "saw" , you mean "read on a DMM" , are you aware that using a DMM to measure a PWM signal is only going to give you the average voltage because there is no steady state voltage since PWM by definition means switching from Vcc to GND ? Comparing your steady state power supply voltage with the average voltage on the motor terminals is all but useless (pointless). If you put a scope on the motor terminals you will "see" the signal.

When I hooked up a 12V (0.6A max) motor, i'm seeing reversing polarity as intended, but only at 2.7V.

This statement tells us practically nothing since you have not given the specs for the 12V power supply and we don't know that it can source 600 mA. It would help to see a vendor link or datasheet for the motor but more importanctly , what do mean by 12V power supply (exactly) ?

MarkT:
What is the 12V supply? Can it generate enough current? Are you using PWM?

Circuit diagram?

I have attached a “napkin sketch” of a diagram.

The 12V power is supplied from a car fuse box. Previously, I had connected from the fuse box, through a DPDT switch and into the motor. It worked just fine. I am not intending to use PWM. The motor is essentially a car window motor.

CrossRoads:
Is that 12V current going to the motor via the Vin header?
Take care on the current draw - Vin is connected after the reverse polarity protection diode, so you will see some voltage loss there, and the diode is only rated for 1A.

Otherwise, provide a link to the motor shield.

The 12V power supply is not going into the “Vin” slot. It is going to the power input jacks on the motor shield. I have nothing connected to the “Vin” pin on the Arduino/motorshield.

Here is a link to the motor shield: http://www.seeedstudio.com/wiki/Motor_Shield_V2.0

raschemmel:

I then connected the setup using 12V external power supply to the motor shield (with no motor connected) and saw 9v at the motor jacks, reversing polarity as intended.

If by “saw” , you mean “read on a DMM” , are you aware that using a DMM to measure a PWM signal is only going to give you the average voltage because there is no steady state voltage since PWM by definition means switching from Vcc to GND ?
Comparing your steady state power supply voltage with the average voltage on the motor terminals is all but useless (pointless). If you put a scope on the motor terminals you will “see” the signal.

When I hooked up a 12V (0.6A max) motor, i’m seeing reversing polarity as intended, but only at 2.7V.

This statement tells us practically nothing since you have not given the specs for the 12V power supply and we don’t know that it can source 600 mA. It would help to see a vendor link or datasheet for the motor but more importanctly , what do mean by 12V power supply (exactly) ?

I do not own a scope. However, My DMM is capable of measuring frequency. I read on the DMM 490Hz. I was under the impression that if I did not use all 4 terminals (see above link), and only used one channel (2 terminals), that the MC would not produce a PWM signal by default. Since I am reading 490Hz, this means that it must be a PWM signal, correct?

I wish I had a datasheet for the motor I’m intending to drive. I called the supplier and he could not provide me with one.

I appreciate the help guys!

Post your code. The "4 terminals" you refer to are Motor -A (2 terminals) and Motor-B (2 terminals) (center terminals are "-" (GND)) Your statement here:

I was under the impression that if I did not use all 4 terminals (see above link), and only used one channel (2 terminals), that the MC would not produce a PWM

Does not mention what you did with the Enable inputs or if the Enable leds were lit or what code you used or what arduino pin you used. Without that information I can't answer your question but if it means anything to you, read this:

The frequency of the PWM signal on most pins is approximately 490 Hz.

http://arduino.cc/en/Reference/analogWrite

Wouldn't that make you suspect that it is running in PWM mode ?

Code:

#include “MotorDriver.h”
float Signal=A1;

void setup()
{
motordriver.init();
Serial.begin(9600);
pinMode(Signal, INPUT);
pinMode(12, OUTPUT);
pinMode(9, OUTPUT);
motordriver.setSpeed(200,MOTORA);
}

void loop()
{
int sensorValue = analogRead(Signal);
float voltage = sensorValue*(5.0/1023);
Serial.println(voltage);
delay(1000);

if(voltage >= 0.300 && voltage <= 0.350){
motordriver.goForward();
}
else if(voltage >=0.800 && voltage <= 0.900){
motordriver.goBackward();
}
else{
motordriver.stop();
}
}

I understand that it is running in PWM mode now. I attempted to use motordriver.setSpeed(255,MOTORA); to change the PWM signal to 100% duty cycle. This should provide maximum voltage (as supplied from power jacks), or 12V in my case, correct? When I read the DMM, 42% duty cycle was present, at 490Hz. The enable LED’s were lit at the appropriate times ( i think).

I got it to work. I could not figure out why the motor control library functions weren't working, so I just went and turned on the H-bridge leads using digitalWrite.

You'll need to tell us where you got MotorDriver.h, the only one's I can find are different interface.

Better still post the library code here.

I never heard of MotorDriver library.

In the future please use the “#” CODE TAGS toolbutton when you post your code so it looks like this:
You can edit it if by clicking the Modify button, highlighting the code and clicking on the “#” button.

 #include "MotorDriver.h"
float Signal=A1;

void setup()
{
   motordriver.init();
        Serial.begin(9600);
        pinMode(Signal, INPUT);
        pinMode(12, OUTPUT);
        pinMode(9, OUTPUT);
        motordriver.setSpeed(200,MOTORA);
}
 
void loop()
{
  int sensorValue = analogRead(Signal);
  float voltage = sensorValue*(5.0/1023);
  Serial.println(voltage);
  delay(1000);   

  if(voltage >= 0.300 && voltage <= 0.350){
      motordriver.goForward();
      }
  else if(voltage >=0.800 && voltage <= 0.900){
      motordriver.goBackward();
      } 
   else{
      motordriver.stop();
      }
}
#include <MotorDriver.h>
float Signal=A1;
float timedelay = 2500;
long timer;

void setup()
{
        motordriver.init();
        Serial.begin(9600);
        pinMode(Signal, INPUT);     
}
 
void loop()
{
 timer=0; 
 int sensorValue = analogRead(Signal);
 float voltage = sensorValue*(5.0/1023);
 delay(500);
 timer = millis();	
  

  if(voltage >= 0.300 && voltage <= 0.350 && timer >=300){
   timer=0;
   analogWrite(9,255);
   digitalWrite(8,LOW);
   digitalWrite(11,HIGH);
   delay(timedelay);
      }
  else if(voltage >=0.800 && voltage <= 0.900 && timer >=300){
   timer=0;
    analogWrite(9,255);
   digitalWrite(8,HIGH);
   digitalWrite(11,LOW);
   delay(timedelay);
      } 
   else{
      digitalWrite(8,LOW);
      digitalWrite(11,LOW);
      }
}

There is the new code. I found the original information for the Seeed Motor Shield V1. http://www.seeedstudio.com/wiki/Motor_Shield_V1.0

Seed must have left the wiring the same for the v2.0 shield that I have. I took some of their code to turn off/on the parts of the H-bridge to rotate the motor as needed. HOWEVER, it turns out that all I needed to do was change the line #include “MotorDriver.h” to include<MotorDriver.h>. D’OH!

Can you post a link to the library ?