Show Posts
Pages: 1 ... 9 10 [11] 12 13 14
151  Using Arduino / Motors, Mechanics, and Power / Anyone know how to connect a SparkFun PWM shield to drive servos? on: November 26, 2012, 09:15:37 pm
Hi all,

I've got a SparkFun PWM shield that I would like to use to drive 8 servos and maybe some lights, and am unsure how to wire it up correctly.

It came with no documentation, and my online searches have not yielded any useful results. I thought I'd try here for some real experts!  I'm sure one of you have used one successfully.

I'll write the code later, but first I'd like to understand how to wire it up correctly to make sure my project will be feasible.

I have some small 5 gram 3-6V Hextronix HTX500 servos.  I'll be using 8 of them in this project, and will need to power them separately from my Arduino.

Has anyone successfully used one of these boards to drive a number of servos?

Pat.
152  Using Arduino / Motors, Mechanics, and Power / Re: Help with dual servos on: November 26, 2012, 08:34:29 pm
A whole lot easier in the loop.  Just delay for an hour at the end of the loop:

  delay(3600000);  // wait one hour

Pat.
153  Using Arduino / Motors, Mechanics, and Power / Re: Help with dual servos on: November 26, 2012, 01:54:41 pm
Do you mean that this action is timer driven, rather than respectively in a loop?
154  Topics / Robotics / Re: Inconsistent stepper motors! on: November 26, 2012, 01:44:04 pm
Hi murf83,

I don't have any actual code to share, but have a few things for you to check:

1. You set the enable pin LOW.  Verify that LOW enables the motor.
2. You loop 3230 times for 1 rotation.  In that loop all you do is set the DIR pin to high.  It is never set LOW.  Also, should you pulse the STEP pin instead?
3. When you do pulse the STEP pin (after the if statement), you don't give the pulse a duration.

This is what I would expect (Caveat - I have not compiled this or tested it. The real details depend on your specific motor.):

Code:
#define STEP_PIN         54
#define DIR_PIN          55
#define ENABLE_PIN       38

const int ROTATION = 3230; // pulses in 1 rotation
const int PULSEWIDTH = xxx;  // each pulse is xxx ms long
const int BETWEEN = xxx; // ms between pulses

void setup() {
  pinMode(STEP_PIN, OUTPUT);
  pinMode(DIR_PIN, OUTPUT);
  pinMode(ENABLE_PIN, OUTPUT);
 
  digitalWrite(ENABLE_PIN, LOW);  // low  = enable motor control
  digitalWrite(DIR_PIN, HIGH);  // high = direction xxx
}

void loop(){

  for (int pulseCnt=0; pulseCnt<ROTATION; pulseCnt++)
  {
    digitalWrite(STEP_PIN    , HIGH);
    delay(PULSEWIDTH);
    digitalWrite(STEP_PIN    , LOW);
    delay(BETWEEN);
  }
}
155  Using Arduino / Project Guidance / Re: temperature sensor problem on: November 25, 2012, 11:11:09 pm
Hi haha,

I'm not sure which GLCD you are using, or if it is on a shield, but make sure that it doesn't use the same pin you are using for the temp sensor.  Just a thought...
156  Using Arduino / Programming Questions / Re: While loops not stopping when condition is false? on: November 25, 2012, 10:45:19 pm
Hi JackSac67,

You are correct about loops.  They do what you say, and unfortunately they also do what you code them to do!

I assume you are referring to the while loop.  It looks like you want to repetitively perform 2 maneuvers whenever the sensor returns 0.00V, until the sensor detects light.

Here's the likely culprit:  your sensor is not returning exactly 0.00 volts in the dark. The values may be very close to zero, but will never be exactly zero for a number of reasons.  I suggest that you do something more like:

while (val < 0.1) {    //while in a pitch black room
   ...
}

Of course, you'll need to determine the correct value for what constitutes a dark room.

... Also, as a general rule, you shouldn't use an equality comparison for floating point values. Rounding errors, due to the fact that the value is represented with a finite number of bits, makes equality near impossible.  Always check using the floating point absolute value function like this to see if the two values are close enough to be equal:

if (fabs(var1 - var2) < 0.01) ...

Pat.
157  Community / Exhibition / Gallery / Re: Photo-finish timer - First project on: November 25, 2012, 10:21:32 pm
Very nice!  Looks like something out of a MythBuster show!

I'm glad to see that you found a reason to use your Arduino and I love to hear about family projects like that.  Have you handed over the keys to him yet? (Keyboard keys, not car keys!)

You have a good project writeup.  Please post the code so we can look it over to get some new ideas for our projects.  And what was the result of the experiment?
158  Using Arduino / Programming Questions / Re: Programming Scrolling Question on: November 25, 2012, 10:03:17 pm
Without knowing how your motors are wired up, I really can't say.  I'm curious, How are they configured, how are you controlling them (outputs driving transistors? a shield?), and how are you powering them (separate batteries?)?

From looking at the code, you are turning them on and off digitally -- full speed on / complete stop.

Alternatively, you can drive them using pulse-width modulation (PWM) and output a lower "voltage" to slow them down.  If you are not sure how, do a quick google on "Arduino PWM" to get what you need.  Its fairly easy to do.

Pat.
159  Using Arduino / Programming Questions / Re: Problem with conditional #include on: November 25, 2012, 09:51:06 pm
Quote
I get one #error or the other, not both.

That implies that the preprocessor is handling the conditionals correctly.  Hmmmmm.

Do you have code somewhere else, like in another tab, that might be compiling too?
160  Using Arduino / Programming Questions / Re: Programming Scrolling Question on: November 25, 2012, 09:26:19 pm
How are you powering the motors?  One common mistake is to power them from the Arduino board.  They'll need their own power supply or battery pack (always connect the grounds together).

It sounds like you might be drawing too much power when you put load on the motors.  This makes the Arduino reboot.
161  Topics / Robotics / Re: need help, Dc motor control using single switch on: November 25, 2012, 09:17:09 pm
Welcome!

I see Lefty beat me to it...  As he says, an H-bridge is the simplest way to go, especially for a new programmer (I assume you are also new at electronics, too).

Google H-bridges and see how to connect them to motors and to see how to use a switch.  They both should be fairly easy to understand.

Look online for the parts.

162  Using Arduino / Programming Questions / Re: Programming Scrolling Question on: November 25, 2012, 09:09:45 pm
You probably mean: delay(500);
163  Using Arduino / Programming Questions / Re: Programming Scrolling Question on: November 25, 2012, 08:52:09 pm
Great!  Good luck with your project.  LCDs are fun, but can be a challenge.  Enjoy.
164  Using Arduino / Programming Questions / Re: Problem with conditional #include on: November 25, 2012, 08:50:02 pm
At a quick glance it looks ok. Unless one library includes the other in error (doubt it).

Try this to see what the preprocessing is doing.  Change the #define to see what happens...  (I would, but I'm not near my compiler)

Code:
#if RTC_TYPE == 1
#include <DS1307RTC.h>      //http://www.arduino.cc/playground/Code/Time
#error DS1307RTC
#else
#include <MCP79412RTC.h>    //https://github.com/JChristensen/MCP79412RTC
#error DS1307RTC
#endif
165  Using Arduino / Programming Questions / Re: Programming Scrolling Question on: November 25, 2012, 08:35:16 pm
Got it... It's doing exactly what you told it to do!

You might want to make them else ifs instead of sequential ifs.  When you change shape to 1 in the first if statement block, it triggers the logic for the second, which triggers the logic for the third (shape3)...

Try something like this:

Code:
void loop()                     // run over and over again
{
  ...

   if ((button == TOP_BUTTON) && (shape == 0))     // display the button that was pressed
    {shape = 1;
    lcd.clear();
    lcd.print("shape1");
    }
   
  else if ((button == TOP_BUTTON) && (shape == 1))     // display the button that was pressed
    {
      shape = 2;
    lcd.clear();
    lcd.print("shape2");
    }

  else if ((button == TOP_BUTTON) && (shape == 2))     // display the button that was pressed
    {shape = 0;
    lcd.clear();
    lcd.print("shape3");
    }
   ...
}
Pages: 1 ... 9 10 [11] 12 13 14