Loading...
  Show Posts
Pages: 1 [2]
16  Forum 2005-2010 (read only) / Interfacing / Re: Servos and timing (delay()). on: December 21, 2008, 03:24:30 pm
If I replace the loop in your working code with this then it also doesn't work:

Code:
 for (int i = 25; i <= 165; i += 21)
   {
    digitalWrite(ledPin, (i % 2) ? HIGH : LOW);
    servo1.write(i);
    delay(3000);
   }
17  Forum 2005-2010 (read only) / Interfacing / Re: Servos and timing (delay()). on: December 21, 2008, 03:19:27 pm
This gets weirder and weirder... I tried your code (but with Servo.h instead - using arduino 0012) and it worked! Why do you do stuff with pin 2 btw?

And this code also works:

Code:
void loop()
{
  for(pos = 40; pos < 140; pos += 20)  // goes from 0 degrees to 180 degrees
  {                                  // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    for (int i = 0; i < 1000; ++i)
      delay(1);                       // This works by delay(1000) doesn't. Must b
  }
}

But if I replace the inner loop with delay(1000); it goes all random again. Very odd.
18  Forum 2005-2010 (read only) / Interfacing / Re: Servos and timing (delay()). on: December 21, 2008, 09:10:41 am
OK I'm getting really confused! I connected a regulated 5V power supply that says it can supply 2.5A to the 5V socket on the arduino. So now the 2.5A power supply directly powers the servo and the arduino, but it still doesn't work! If I disconnect either the PWM servo controller wire, or its power wires then the code works (i.e. the LED flashes on and off every three seconds).

Any idea what is going on? Basic servos don't use more than 2.5A do they?

Also, if I try using USB to power the arduino and a power adapter to power the servo will that cause issues with the different grounds, or is the control lead of servos isolated from the power leads?
19  Forum 2005-2010 (read only) / Interfacing / Re: Servos and timing (delay()). on: December 21, 2008, 07:26:46 am
Yeah but how do you connect the arduino itself to the 5V supply (assuming it is already regulated)? I don't want to have to use two power supplies...

Hmm perhaps the easiest way is to make a USB<->power connector. I think USB provides regulated 5V so that must bypass arduino's regulator...
20  Forum 2005-2010 (read only) / Interfacing / Re: Servos and timing (delay()). on: December 20, 2008, 08:31:36 pm
Actually I tried it without the servo attached and it worked. I think the problem was that I was using the regulated 5V on the arduino to drive the servo. I guess the regulator can't supply that much current and the voltage dropped too low for the arduino.

Is there any way to bypass the regulator? E.g. if I'm running off an already regulated 5V supply (or 5V of batteries)?
21  Forum 2005-2010 (read only) / Interfacing / Servos and timing (delay()). on: December 20, 2008, 11:29:09 am
Hi, I've got a 'hobby' servo that I'm trying to control with the ServoTimeTimer1 library (very similar to the Servo library) but it doesn't seem to work well with the delay() function. Here's the code:

Code:
#include <inttypes.h>
#include <avr/io.h>
#include "WProgram.h"

#include <ServoTimeTimer1.h>

#define servoPin1 9

ServoTimeTimer1 servo1;

 int ledPin = 13;                // LED connected to digital pin 13

void setup()
{
  servo1.attach(servoPin1);
  pinMode(ledPin, OUTPUT);      // sets the digital pin as output
}

void loop()
{
  digitalWrite(ledPin, HIGH);   // sets the LED on
    servo1.write(1600);
    delay(3000);
  digitalWrite(ledPin, LOW);    // sets the LED off
    servo1.write(1500);
    delay(3000);
}

What happens is that it often moves to the second position and then goes straight back. I guess it's because the servo library uses the same timer as the delay function. Anyone know of a way around this?

Two other small questions:
1. Should the servo vibrate when it is use? Even when it isn't moving? Seems like bad feedback circuitry if it should...
2. Where can I find a reference to all the registers and stuff needed to write things like the Servo library? Is it GCC stuff or is this info provided by Atmel somewhere?

Thanks.
22  Forum 2005-2010 (read only) / Exhibition / Re: SD card read/write with Arduino on: December 13, 2008, 03:23:34 pm
So back on topic... SD mode IO? SDHC support?
23  Forum 2005-2010 (read only) / Exhibition / Re: SD card read/write with Arduino on: December 10, 2008, 01:38:44 pm
I don't think it will work with microSD. According to wikipedia the SPI mode that this library uses is optional for microSD but required for SD:

http://en.wikipedia.org/wiki/MicroSD

How hard would it be to use the SD mode instead of SPI? And what about SDHC support?
Pages: 1 [2]