Show Posts
Pages: [1] 2 3 ... 18
1  Using Arduino / Motors, Mechanics, and Power / Re: Control 48v Go Kart motor on: May 11, 2014, 01:00:09 pm
You have to be a little careful with your motors because the rated 1000 Watts of power is probably the continuous rating. The motors will have a stall current of well over the rated 27 Amps. That's why the Pololu controllers would not work. The Pololu and Adafruit boards are great, but your motors are a little big for them.

I think the scooter motor controller would have a tough time handling the current for your motors as well. Its technical specs suggest it for a 350 to 600 Watt motor, not a 1000 Watt motor like yours. (Though it does say peak current of 40 Amps, so it may work with your motors -- hard to say.)

If you can run both motors with the same controller, a golf cart controller like this one might work at a relatively cheap price: That controller should be heavy duty enough to handle any current your motors pull.

But that controller does not switch directions (forward and reverse). To enable that, you would need a reversible contactor like this one:

You can easily control the above motor controller with an Arduino PWM output pin. The contactor is harder to control electronically. You would need to wire up a circuit with a transistor or relay.
2  Using Arduino / General Electronics / Re: Help me improve my dire first attempt at soldering on: April 30, 2014, 07:31:47 pm
Thanks for the help guys.  So, I won't get away with leaving it as it is?

I have some desilder braid but I struggle to get the molten solder to soak into it.

You can probably get away with leaving it the way it is. I did not see any places where the solder bridged the gap between pins. The main problem with your soldering job is that you wasted solder. But practice makes perfect. Or at least practice makes you better. So I would just try to improve next time.

I'm surprised that you are having trouble with the desoldering braid. That stuff usually works pretty well.

Just put the braid on top of the solder you want to remove and press down on the braid with the tip of your soldering iron. Make sure you press down firmly, or the heat will not make it  through the braid to melt the solder. And be sure to move to a new spot on the braid when the old spot has turned silver with solder.
3  Using Arduino / Programming Questions / Re: Compile errors when trying to use interrupt.h with a Pololu A-Star 32U4 Micro on: April 26, 2014, 04:01:47 pm
I'm not sure exactly what is going on, but I found out that the problem is not with using the libraries with an ATmega32u4 board. They seem to work fine. The trouble was that I was trying to use Timer2, which apparently doesn't work on those boards. I switched to Timer3, and the code compiles fine now.
4  Using Arduino / Programming Questions / Re: Compile errors when trying to use interrupt.h with a Pololu A-Star 32U4 Micro on: April 26, 2014, 01:29:30 pm
I see that the definitions that I need (TCNT2, TCCR2A, TCCR2B, WGM21, CS22, etc.) are defined in a header file that gets selected in avr/io.h.

But when I look at the header file io.h it seems to be a version from 12/4/2008. Are there no newer versions of avr/io.h? Or am I reading that date wrong?

Assuming that there is no version of io.h that will work for my board, I guess I can create a new version that I can include in. But any suggestions would be appreciated.
5  Using Arduino / Programming Questions / Re: Compile errors when trying to use interrupt.h with a Pololu A-Star 32U4 Micro on: April 26, 2014, 12:36:39 pm
Why does that surprise you?

Because I haven't worked much with libraries. I didn't realize that many of them are not going to work with the Arduino Leonardo or similar boards. Now I know.

The 32u4 has three timers. I'll try to make my way through the code libraries and see where the timer-related variables are defined, and define them for the 32u4 chip.
6  Using Arduino / Programming Questions / Re: Compile errors when trying to use interrupt.h with a Pololu A-Star 32U4 Micro on: April 25, 2014, 08:57:21 pm
Yes, I know it is not an Arduino. But it does run in the Arduino environment. I thought the program I wrote might not run on this board, but was surprised to find that it would not even compile. But I tried to compile the program for an Arduino Leonardo, which uses the same 32U4 chip, and got the same error.

So I guess the Arduino libraries only work for the 328 and 168 boards, or at least the libraries that use the timers. And I guess the environment is set up so that the libraries do not load, thus generating a compiler error to let people like me know that the libraries don't work. Is that right?
7  Using Arduino / Programming Questions / [Solved] Compile errors trying to use interrupt.h with Pololu A-Star 32U4 Micro on: April 25, 2014, 05:39:55 pm
I wanted to try out the Pololu A-Star 32U4 Micro. I have a program written for the Arduino Uno that compiles and runs fine for it. But I get compiler errors when I select as my board "Pololu A-Star 32U4" instead of "Arduino Uno." It seems like the variable names in the libraries are not being loaded. My code is below:

#include <ServoTimer2.h>
#include "DualVNH5019MotorShield.h"
#include <io.h>
#include <interrupt.h>

#define BuzzerPin 5
#define LeftServoPin 11
#define RightServoPin 3

unsigned char cmd, value;
float Steering;
int throttle;
DualVNH5019MotorShield md;

ServoTimer2 leftServo;  // create servo object to control a servo
                // a maximum of eight servo objects can be created
ServoTimer2 rightServo;

int posLeft = 0;    // variable to store the servo position
int posRight = 0;

void setup() {

  // set up Arduino motor shield

  // set up servos for steering
  pinMode(BuzzerPin, OUTPUT);
  pinMode(RightServoPin, OUTPUT);
  pinMode(LeftServoPin, OUTPUT);
  // set compare match register to desired timer count:
//  OCR2A = 150624;
  // start serial port at 115,200 bits per second
  // wait until serial contact is made
  while (Serial.available() <= 0) {

// this interrupt service routine for timer 2 toggles the horn buzzer

  digitalWrite(BuzzerPin, !digitalRead(BuzzerPin));

  // reset counter 2
  TCNT2 = B00000000;

void loop() {

  // if we get a valid byte, read throttle signal:
  if (Serial.available() > 0) {

    // get an incoming byte:

       cmd =;

// If it's not a command character, ignore it and wait for the next one
if(cmd != 'F' && cmd != 'B' && cmd != 'H' &&
          cmd != 'R' && cmd != 'L')return;
// got the command, now wait for the data char
while(Serial.available() == 0);
value =;
// got the command and value, now do the command
switch(cmd) {

    case 'F':
            value = constrain(value, 0, 255);
            throttle = map(value, 0, 255, 0, 400);
//            Serial.println(throttle);
          case 'B':
            value = constrain(value, 0, 255);
            throttle = map(value, 0, 255, 0, -400);
   case 'H':
            if (value == 0) {
              cli();         // disable global interrupts

              // turn Timer2 off
              cli();         // disable global interrupts
              TCCR2A = 0;    // set entire TCCR2A register to 0
              TCCR2B = 0;
              // turn off CTC mode:
              TIMSK2 |= 0;
              sei();          // enable global interrupts

            } else {

              // initialize Timer2
              cli();         // disable global interrupts
              TCCR2A = 0;    // clear entire TCCR2A register
              TCCR2B = 0;
              // turn on CTC mode:
              TCCR2B |= (1 << WGM21);

              // Set timer clock speed:

              TCCR2B |= (1 << CS22);

              // enable timer compare interrupt:
              TIMSK2 |= (1 << OCIE2A);

              sei();          // enable global interrupts

    case 'R':
            value = constrain(value, 0, 255);
            Steering = float(value - 127);
            if (Steering > 0) {
              posRight = 103 - int(Steering * 0.258);  // divide by 128 and times by 33
            } else {
              posRight = 103 + int(Steering * -0.449);  // divide by -127 and times by 57
            posRight = map(posRight, 0, 180, 544, 2400);
    case 'L':
            value = constrain(value, 0, 255);
            Steering = float(value - 127);
            if (Steering > 0) {
              posLeft = 68 - int(Steering * 0.453); // divide by 128 and times by 58
            } else {
              posLeft = 68 + int(Steering * -0.252); // divide by -127 and times by 32
            posLeft = map(posLeft, 0, 180, 544, 2400);


The error messages I get are things like TCNT2 is not declared in this scope.

Does the problem lie in my trying to use these libraries with the A-Star 32U4? Or have I just somehow not put the libraries in the right place?

Thank you.
8  Using Arduino / Programming Questions / Re: how do i make motors run for a set amount of time on: April 21, 2014, 05:15:45 pm
If you want your motors to turn on and stay on for 25 minutes, and then turn off and continue with your code, you can do something like this:

const unsigned X_AXIS_PIN = 0;
const unsigned Y_AXIS_PIN = 1;
const unsigned Z_AXIS_PIN = 2;
const int motor1 = 3;
const int motor2 = 5;
const int motor3 = 10;
int motorState = LOW;
long delay25minutes = 1500000;    // delay for 25 minutes, which is 1500 seconds

void setup()
  pinMode(motor1, OUTPUT);
  pinMode(motor2, OUTPUT);
  pinMode(motor3, OUTPUT);

  int x,
void loop()
    Serial.print(" ");
    x = analogRead(X_AXIS_PIN);
    Serial.print(" ");
    y = analogRead(Y_AXIS_PIN);
    z = analogRead(Z_AXIS_PIN);
    if( x < 700 && y < 700 && z < 700)
        if (motorState == LOW)
        motorState = HIGH;
        motorState = LOW ;
        digitalWrite(motor1, motorState);
        digitalWrite(motor2, motorState);
        digitalWrite(motor3, motorState);

        motorState = LOW;
        digitalWrite(motor1, motorState);
        digitalWrite(motor2, motorState);
        digitalWrite(motor3, motorState);

If you want your Arduino to be doing some other code during the 25 minutes, then you need the blink without delay approach.
9  Using Arduino / General Electronics / Re: Intermittent problem with battery -- pulling too much current or too much noise? on: April 13, 2014, 04:38:32 pm
Have you got good decoupling on your supply?

No, I had no decoupling on my supply. There are two USB ports on the battery. The line to the servos came out of one port while the line to the Raspberry Pi came out of the other. I'm not sure whether the two USB ports are decoupled inside the battery, but I added no decoupling.

To solve the problem without using an extra battery, I think I'll get a UBEC to power the servos off the 9.6 Volt traction battery.
10  Using Arduino / General Electronics / Intermittent problem with battery -- pulling too much current or too much noise? on: April 13, 2014, 03:37:04 pm
I stripped down and replaced the electronics on a model car. Now I've got a Raspberry Pi on the car, which communicates with a laptop computer via a Wi-Fi adapter to get steering and throttle signals. (There are no brakes.) The Pi then sends a signal to an Arduino Uno which drives two Hitec HS-325HB servos to steer the front wheels (one servo for each wheel) and controls a Pololu Dual VNH5019 motor driver shield that drives the rear wheels.

I have two batteries on board. One battery is a 9.6 Volt nickel metal hydride battery that drives the rear wheels, through the motor drive shield. The other is a Duracell Powermat GoPower Longhaul backup battery, which is a 5 Volt, 8800 mAh lithium ion battery that says it can put out 2.1 Amps over 2 USB ports. I use the Duracell battery to power the Raspberry Pi through one USB port and the two servos through the other USB port. The Pi then powers the Arduino Uno and the Wi-Fi adapter through the Pi's USB port.

The problem is that the Raspberry Pi will sometimes reset while I'm driving the car. It usually happens after two or three minutes. The car will stop working, and it looks like the Pi reboots itself. (It's hard to tell exactly what the Pi is doing, since I am monitoring it on the laptop using Window's Remote Desktop Connection and the Wi-Fi connection simply goes dead.)

To see what causes the problem, I added a third battery. That battery, also a lithium ion 5V battery with a USB port, powers just the servo motors. So the servo motors are now powered by a separate battery from the Raspberry Pi. That seems to solve the problem. I can now run the car for many minutes with no problem.

To me, that indicates that the problem is one of two things: I'm pulling too much current from the battery so the Raspberry Pi resets, or I'm getting too much noise on the line so the Pi resets. If it is one of those problems, I wonder which one. I'm not sure how to tell.

As far as current drain, the servo specs say that the current drain at 4.8V is 7.4mA/idle and 160mA no load operating. With the two of them, that's maybe 500 mA max. The Raspberry Pi pulls less than 700 mA. The Wi-Fi adapter is a TP-LINK TL-WN823N 300Mbps Wireless Mini USB Adapter that seems to pull less than 100 mA. I think the Arduino Uno also pulls less than 100 mA. So I would think the current draw should be well below 2.1 Amps.

So the problem may be noise. I know that motors can make a power line very noisy, but could the line noise from two servos be enough to cause the Raspberry Pi to reset?

Any thoughts?

Thank you.
11  Using Arduino / Programming Questions / Re: Servo library and motor controller library fighting over pins 9 and 10 on: April 12, 2014, 05:06:45 pm
Robin2, thanks for suggesting ServoTimer2. I tried it out and it didn't work as a drop-in replacement for Servo.

Then I realized that ServoTimer2 takes microseconds of pulse width instead of degrees like Servo. So I had to write a line of code that would convert the degrees to microseconds:
            posLeft = map(posLeft, 0, 180, 544, 2400);
where 0 degrees equals 544 microseconds and 180 degrees equals 2400 microseconds.

The code now works like a charm. I can now use my two servos (which steer independently the two front wheels of a toy car) and my motor shield (which drives the back wheels) at the same time. Thanks again.
12  Using Arduino / Programming Questions / Servo library and motor controller library fighting over pins 9 and 10 [solved] on: April 12, 2014, 02:30:37 pm
I'm using an Arduino Uno with a Pololu Dual VNH5019 Motor Shield. The library for that motor shield uses pins 9 and 10 as PWM pins, one for each of the two motors it drives.

I'm also using the Uno to control two servo motors, using the Servo library. I found out that the Servo library disables the PWM function on pins 9 and 10, even though I am using pins 11 and 13 to control the two servos.

So both libraries are fighting over pins 9 and 10. The motor shield library lets me re-map all pins but 9 and 10. I can't figure out how to modify it to let me use other pins.

But the Servo library seems to suggest that timer pins other than pins 9 and 10 can be used. It seems that Timer1 uses pins 9 and 10, but Timer2 uses pins 3 and 11, which would work for me. So I want to have the Servo library use Timer2 instead of Timer1. So far, I have not figured out how to do that. Anyone know?

Thank you.
13  Using Arduino / General Electronics / Re: How can I find out why a small DC motor won't work? on: April 06, 2014, 11:39:21 pm
I'll try to take apart the motor tomorrow to see what what happened. I suspect the motor is toast, though, and destined for the garbage can.

I need to be more careful. Not only have I burned out a motor, but I seem to have burned out a 1 1/2" speaker as well. It was working fine (I added it to the car for a horn) until I suddenly saw a wisp of smoke. I seem to have fried it. Perhaps I needed a resistor on it.
14  Using Arduino / General Electronics / Re: How can I find out why a small DC motor won't work? on: April 06, 2014, 04:55:50 pm
I see. When my motor is burned out, does that mean that the brushes are no longer in contact with the rotor? With this small a motor I suspect that is irreparable.

I ask because I'm surprised that this motor burned out, and wonder what caused it. These little motors seem to be indestructible in the various toys I've scavenged them from. I wonder if I abused it somehow. Maybe too high a voltage. Or too much current (stall current) for too long. Those are the two possibilities I've thought of.
15  Using Arduino / General Electronics / Re: How can I find out why a small DC motor won't work? on: April 06, 2014, 02:20:13 pm
That is very high, are you sure that is not just your skin resistance? Were you touching both terminals of the meter when you made the measurements?

I get varying results, but it's usually above at least 80 k Ohms, and I am not touching the probes. It's funny, though. I can get the meter to settle on a resistance with the faulty motor, even though I get a little different reading every time. But with a similar motor that works fine the meter will not settle on a resistance, but jumps around from 20 or so Ohms to 200 or 300 Ohms. Almost always less than 0.5 k Ohms, but I thought it would settle down to a small number.

It sounds like it is open circuit and quite burned out.

Yes, I'm afraid the motor is burned out. That's a shame, since I have no idea how to replace it. I wonder if the 9.6 Volts I used (which usually measured out at well over 10 Volts) was too high for this motor. Though it did work for quite a long time.
Pages: [1] 2 3 ... 18