Show Posts
Pages: [1] 2 3 ... 81
1  Using Arduino / Motors, Mechanics, and Power / Re: VarSpeedServo - a modified Servo library with speed control on: March 22, 2012, 09:06:36 am
Thanks for the pointer. I'll produce an updated version in a few days.

2  Using Arduino / Motors, Mechanics, and Power / Re: VarSpeedServo - a modified Servo library with speed control on: November 25, 2011, 05:38:23 am
One question I have as you seem the guru in all things servoish....

Sorry to disappoint you here, we have no guru here. The last thing that made guru-guru ended after a short sting in the oven on the table at thanksgiving.

what happens in situations when there is alot of other code processing going on, and the servo gets "noisy".
I used a simple for command to slowly raise the servo output.

Hi John,

as long as you have just one single interrupt going on the the servo is pretty stable, no matter what you do in your main loop.  To test that out, create a program that leaves the servo in a fixed position and does other processing meanwhile. The servo should only have occasional minimal movements. Check that out with various servo positions, not only the extremes.

In my experience, the servos start to get jittery once you have multiple interrupt functions or you have functions that disable interrupts periodically. Then the pulse length isn't constant in the situations where another interrupt (or cli / sei instructions) are delaying the servo interrupt and thus lengthening the PWM impulse. This can be a hairy problem.

If the rpm-counter is bothering your servo, you might want to look into using your rpm-signal as an external clock reference so that you can use timer2 as a counter. (This is all from memory, I don't have the Atmel datasheet on me at the moment). For very high frequencies, consider adding an external counter chip you then can read at your leisure. As usual, the problem lies in the details.

 When I'm back at home, I will have a closer look at the matter.

3  Using Arduino / Motors, Mechanics, and Power / Re: VarSpeedServo - a modified Servo library with speed control on: November 22, 2011, 08:58:15 am
Thanks Terry, that'll be interesting to know. If I understand it right, if you use slowmove with different speed parameters but the same position for each wheel, the robot should accelerate in a spiral.

4  Using Arduino / Motors, Mechanics, and Power / Re: VarSpeedServo - a modified Servo library with speed control on: November 21, 2011, 10:16:10 am
Question: would this work as acceleration control on continuous-rotation servos?? Newpos sets top speed, speed sets acceleration?

Terry, it well could be, but to be honest I don't know. The library just increases continuously the position of the target until the set target value is reached. The consequence is that the PWM pulse increases or decreases in length over time. If the speed on continuous rotation servos is the same as the position for  a regular servo, the speed parameter would be the acceleration.

Perhaps someone with access to such a servo could try that out?

5  Using Arduino / Motors, Mechanics, and Power / Re: VarSpeedServo - a modified Servo library with speed control on: November 21, 2011, 06:23:26 am
There might be one, you'd have to check. Here's the test-code I use for this library. It should be fairly simple to extend.

This little program controls a servo with a potentiometer.
The button moave the servo from one end to the other, the potentiometer
sets the speed. 0 = full speed, 1 slowest, 255 fastest.
When pressing the button, the led is turned on to exercise it a little.
Every few seconds the current postion of the servos is reported on the
serial line and whenever the button is pressed.
 The circuit:
* LED attached from pin 13 to ground: Button led
* Pushbutton attached to pin 2 from GND
* Linear Potentiometer attached to analog pin 2 from GND and +5V acting
  as a voltage splitter. Any value from 10 kOhm to 100 kOhm will work.
* Servo control line attached to pin 12.
 * Note: on most Arduinos there is already an LED on the board
 attached to pin 13.

#include <VarSpeedServo.h>

const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin =  13; // the number of the LED pin
const int potPin =  16; // the number of the potentiometer pin (Analog 0)
const int mainPin = 12; // Main servo control line
const int ServoMin = 1000; // Minimum pulse width for servos in ms.
const int ServoMax = 2000; // Maximum pulse width for servos in ms.
const int PotiMin = 0; // Minimum value read from potentiometer
const int PotiMax = 1023; // Maximum value read from potentiometer
const int ButtonDelay = 100; // Time in ms to press button to activate tuning mode

VarSpeedServo myServo; // Servo

void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);     

// initialize the pot and button pin as an input:
pinMode(potPin, INPUT);
pinMode(buttonPin, INPUT);

// Activate internal pull up resistor for tuning button
digitalWrite(buttonPin, HIGH);

// Initialise Servos
myServo.attach (mainPin, ServoMin, ServoMax);

// Initialise Serial communication
Serial.begin (9600);

void loop() {
static unsigned long debounce = 0;         // variable for reading the pushbutton status
static int buttonstate = HIGH;         // variable for reading the pushbutton status
static unsigned long lasttick;

// Report position;
if (millis () - lasttick > 5000) {
lasttick = millis ();
Serial.print ("Position=");
Serial.println (myServo.readMicroseconds());

// Read button and debounce.
int buttonnow = digitalRead(buttonPin);
if (millis() - debounce >= ButtonDelay
&& buttonnow != buttonstate) {
buttonstate = buttonnow;
debounce = millis();
switch (buttonstate) {
case LOW:
// Button has just been pressed
digitalWrite(ledPin, HIGH);

// Set the servos
int potlast = analogRead (potPin); // Read potentiometer
int speed = map (potlast, PotiMin, PotiMax, 1, 256) & 0xff;
myServo.slowmove ((myServo.readMicroseconds() > ServoMin + 400
? ServoMin + 100 : ServoMax - 100), speed);
// Report pot position
Serial.print ("Speed=");
Serial.println (speed);

case HIGH:
// Button has just been released
digitalWrite(ledPin, LOW);

// Slow down
// delay (50);

6  Using Arduino / Project Guidance / Re: Ethernet File Transfer on: September 09, 2011, 02:29:15 am
The data received from the client is transmitted with the speed of normal serial communication, 115200 baud and therefore 115200 bits/s. Am I right?

Yes, you're right, this is about 11520 bytes per second. This is the speed at which each byte is sent. What you don't account here for is the delay between characters, which can be anything and be caused by any component in your system. There are no easy solutions for this, you first need to understand where your program spends its time before even thinking about improving the performance. And while you're at it, don't forget that debug statements sent out on the serial take time too, so first check how your debug set-up affects the performance. Good luck.

7  Using Arduino / Project Guidance / Re: Connect old telephone rotary disk to arduino on: August 20, 2011, 08:52:38 am
One additional hint. These dials were constructed to give you impulses of even length, but you might get bouncing. So check you how long an impulse is and discard any impulses that aren't closed at least half as long. If you get an open twice as long as the usual time between impulses, consider the number done.

8  Using Arduino / Project Guidance / Re: Connect old telephone rotary disk to arduino on: August 20, 2011, 08:23:57 am
In principle you don't need any resistor, you can use the internal pull-up from the Arduino. Look at the tutorials for digital input with simple switches. Your rotary dial can be treated just like a simple switch. If you want to use your own pull-up or pull-down resistor, any value between 1kOhm and 20kOhm will do.

9  Using Arduino / Motors, Mechanics, and Power / Re: VarSpeedServo - a modified Servo library with speed control on: August 04, 2011, 07:35:14 am
To answer your question: I needed this kind of function, so I wrote the extension. From time to time, questions about moving things slowly come up, mostly for visual reasons. I think having such a function in the servo library would be a good idea if the library doesn't suffer from it.

NB: I added one more point about the speed control to my previous message.

10  Topics / Robotics / Re: Simultaneous but different servo sweeps with four servos on: August 04, 2011, 07:24:00 am
int servoSpeeds[NBR_SERVOS]      = {1,    10, 100, 255}; // sweep speed, 1 is slowest, 255 fastest)

A word of warning about high servo speeds setting - 255 in this case: The updating of the servo happens faster that the servo is actually able to move. So in this example, you might end up with switching between the extreme positions at each PWM cycle for the servo. The resulting movement won't be a servo wiping left and right at a fast speed, but a servo twitching randomly in some random position. You probably need to decrease the speed from 255 to some lower value until your servos has enough time to complete the sweep. In my tests with the little servos I had, speeds over 128 were usually above the hardware speed of the servo and all looked the same.

11  Using Arduino / Motors, Mechanics, and Power / Re: VarSpeedServo - a modified Servo library with speed control on: August 04, 2011, 07:13:14 am
Hi Mem,

it's nice to know, that you like it. Whether to add it to the main Servo-library should be considered carefully. From my point of view, you're welcome to add the code or any modification from it. However, please consider a few things first:
  • The speed control adds more memory to the servo structure. It's just a few bytes, but in large setup with many servos, you should check if this causes problems
  • The speed parameter doesn't relate to any real time measure. It's just a number and you can set some speeds but others not. For many applications, like moving something at a pleasant speed to look at, this is good enough. If some specific speeds are necessary, the model I used might not offer enough granularity.
  • I didn't really check if the interaction of the position update and attach/detach works in a reasonable manner. What happens if one detaches the servo while on a slow move and then reattaches it?
  • The method-name slowMove is clumsy and not really in line with the rest of the rest of the methods
  • The spectrum of the available speeds isn't well used. Out of the speed byte, values above 128 are usually to fast to make visible differences because of the limits of the motor speed itself. I would like it improve this, but then I'd need more bits for the ticks parameter. If the memory isn't a problem, adding a byte to the tick counter will give more slower speeds. I think, it should also be considered what kind of speeds are going to be used most.
  • Some proper documentation and samples are also necessary.

In short, it was mostly a quick hack to get landing gears on model aircraft extend and retract at a more more realistic pace. Going by the general feedback, it seems to be of use for some applications. If you think part of my work is useful to be added to the main library, feel free to go ahead.

12  Using Arduino / Networking, Protocols, and Devices / Re: Send Hex through UDP on: June 30, 2011, 04:35:23 am
Post a wireshark capture of what a working packet looks like and what the Arduino is sending. This is the easiest way to debug such troubles.

13  Using Arduino / Programming Questions / Re: Arduino Duemilanove with 8-bit atmega328 - how to read 16-BIT REGISTER CONTENTS on: June 30, 2011, 04:02:24 am
Easy: after you received 8 bits, store the byte and read another 8 bits. If you store the second byte in the right place, you can access the resulting value directly as a 16-bit integer.

14  Using Arduino / Project Guidance / Re: Arduino + Ethernet Shield - web cache on: June 30, 2011, 03:50:39 am
When you add in all the additional shields and components you need, wouldn't it be simpler to move to a platform that has enough memory and handles network access in a less dodgy way than the Arduino?

15  Using Arduino / Project Guidance / Re: Arduion Remote Webcam Station on: June 30, 2011, 02:55:42 am
As small as possbile for a camera resolution mabey 128 by 100? It will only send 1 picture every 30 minutes It can be done i need to know how to store and then convert a file to send  smiley-sweat

Lets assume for simplicity you have 1 byte per pixel. 128x100 = 12800 bytes = 12kB. Your Arduino has 2kB of RAM some are used for stack or other variables and 0.5kB of EEPROM. No way. Not every 30 minutes, not even once.

( if i could get the image to read byte by byte converting it in to a hex value from a SD card and then send it, it would work)

This could work, but you really should ask yourself if the Arduino is the right tool to use for your application and whether you'd not be better of to take a platform with more RAM and processing power. It's a bit like trying to use a children's tricicle to haul 17 tons of bricks. It might work with enough effort, but it's easier, faster and cheaper to just get a truck in the first place.

Pages: [1] 2 3 ... 81