Jitter Problems

Still having jitter problems. I’ve tried all sorts of capacitor sizes and configurations trying to fix the problem but it doesn’t work.  My only significant progress is that I moved the servo attachment into the  individual ‘if’ statements so that the jitter doesn’t start until I actually hit a IR remote button. When I had the servo attachment at the beginning of the loop,  the servo would start jittering as soon as the Arduino powered up.  I think I can still figure out some kind of software solution by powering down the 5v power and restarting, but my attempts so far haven’t been successful.

still working on it.

Hardware: bad servo

Well, it looks like the micro servo is bad. For whatever reason, it doesn’t work right with the same sketch that I’m using on the bigger one…not only that but if I run the template “Sweep” program, it only turns about 90ish degrees, vs. the 180ish degrees that the big servo turns.

So I’m at a pause till I get either the capacitors or another servo.

BTW, Adafruit was super responsive on their forum and getting an RMA# was very painless…Thanks Adafruit!

Hardware: Second Servo Connection

While I’m waiting for my capacitors, I figure I’ll go ahead and connect the second servo to try to get both working at the same time. Considering each servo needs the majority of the juice coming out of the Arduino, I’m hoping to stagger them so that when I hit the remote button, servo one will move, THEN servo two, etc (so not all at the same time as I’m pretty sure this would be too much of a power drain).  Here’s how I have servo two set up:

2 servo

Software: Controlling the first Servo (jitter problems)

I’m referencing this site again. Here’s the code I’m using:

#include <Servo.h>
#include <IRremote.h>

unsigned long Value2 = 0x7B8; // RED button where 7B8 is on our your remote’s values.
unsigned long Value1 = 0x78B; // YELLOW button where 78B is another button on your remote

int RECV_PIN = 3;
IRrecv irrecv(RECV_PIN);
decode_results results;
 
 
Servo servo1;

// the setup routine runs once when you press reset:
void setup() {              

Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver

  // initialize the digital pin as an output.

servo1.attach(12); // attach servo to digital pin 12
}
// the loop routine runs over and over again forever:
void loop() {

if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
  }

if(results.value == Value1) {
servo1.write(2);
}

if(results.value == Value2) {
servo1.write(178);
}

}

Note that it still has the code to continue to print the hex values.

If you look at the site and compare it to my code, you’ll note there’s a typo on the site when it references Value1 and Value2 at the bottom of the code (site references Value1 both times).

And it works!  one button turns it one way, and the other button turns it the other way.

The only problem I’m having is that there’s significant jitter that I know it would bug me. I’ve Googled around it likes like an issue with the Arduino’s timer (above my head really). I tried the smaller servo just to see what would happen and I have the same jitter. There’s someone out there on this site who suggests using a 100pF capacitor (here’s another site that talks about it). Guess I need to buy some. I can get 50 for $1.60 on ebay (from China) or 100 for $3.00 (from the US). I need like 5 of them – ha.  Considering my last China purchase took about 40 days to get to me, I’m going with the $3.  I’m not terribly sure they’ll work for me, but for $3, its a decent gamble.

Hardware: Connecting the First Servo

This is fairly straight forward also:

  • Brown wire to Arduino Ground
  • Red wire to Arduino 5v
  • Yellow wire to Arduino pin 12

2

Hardware: IR Remote

Here’s the IR remote I’m using, which I also use for the TV controls. I’ll be using the red and yellow buttons (which don’t actually seem to have any other purpose when I press them – so they’re perfect options).

IMG_20140826_095259

Software: Finding the values for the remote buttons

I’m referencing this site. I’m starting with this sketch as it gives me values for any IR remote buttons. The only thing that needs to be tweaked is whatever pin # you’re using. When I look at the serial monitor, I see a value pop up each time I hit a button on the remote. I’m picking two buttons that I don’t really use for anything else (just so happens to be a plain yellow button and a plain red button) – and the values I get are 7B8 (yellow button) and 78B (red button).

 

/*
* IRremote: IRrecvDemo – demonstrates receiving IR codes with IRrecv
* An IR detector/demodulator must be connected to the input RECV_PIN.
* Version 0.1 July, 2009
* Copyright 2009 Ken Shirriff
* http://arcfn.com
*/
#include <IRremote.h>
int RECV_PIN = 3; // set to the pin number that you’re using
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
}
}

Hardware: Connecting the IR sensor

The setup for just the IR sensor is pretty straightforward as shown in the below pic. 

  • IR pin 1 to Arduino pin 3.
  • IR pin 2 to Arduino Ground.
  • IR pin 3 to Arduino 5v.

 

1

Software: IRremote library

My first step was to include the IR remote library using this site (I guess the IR libraries are no longer included with the Arduino sketch software by default.

I then unzipped and installed to the library folder. I also then have to add the library under Sketch | Import Library.

My next step was to do the correction listed in the comments – and that is to open the IRremoteInt.h file and change this #include <WProgram.h> to #include <Arduino.h>

 

Hardware: Servos and IR Sensor

I have 5 windows and plan on controlling them with servos. I only purchased two at the moment and I’m hoping the smaller one will work (both smaller and cheaper) – the blinds are heavy and just rotating them takes a little oompf (so actually I’m hoping that even the big one works – let alone the small one). So here’s my first purchase:

I already have the Arduino, wires, and IR remote.

Neither servo arms are quite the full 1 1/2″ distance needed to fully open and close the blinds…but they’re pretty close and either should work fine for what I want.

Follow

Get every new post delivered to your Inbox.