Show Posts
Pages: [1] 2
1  Using Arduino / Motors, Mechanics, and Power / Re: VarSpeedServo - a modified Servo library with speed control on: June 20, 2013, 10:00:32 am
Glad to hear it!!
2  Using Arduino / Motors, Mechanics, and Power / Re: VarSpeedServo - a modified Servo library with speed control on: June 19, 2013, 11:43:20 am
What ide are you using??
Download the latest and try again...
I am using 1.0.5 and it compiles on mine just fine.
Did you install the library correctly?
Did you point your IDE to look in the the correct directory?

Sorry I do not have an extra arduino to run the code right now
but like I said  it compiles....
3  Using Arduino / Motors, Mechanics, and Power / Re: VarSpeedServo - a modified Servo library with speed control on: June 17, 2013, 11:03:20 pm
not exactly sure, but where you have your servo1.attach (4);

your are going to need something like : servo1.attach (4, 0, 180);

4 is the pin you are attaching to
0 is the minimum rotation
180 is the maximum rotation

If  your problem is that you cannot get it to compile read earlier in this thread about
editing varspeedservo.cpp

replace WProgram.h in the varspeedservo.cpp to Arduino.h
4  Using Arduino / Motors, Mechanics, and Power / Re: VarSpeedServo - a modified Servo library with speed control on: May 09, 2013, 10:17:39 pm
I seem to notice getting full range out of the servo seems tricky..
Maybe it is my hobby people servos but unless I put:


servo1.attach(5,555,180); this is the only way I can get 180 degrees.
but the speeds work fine.

I am trying to make a pan and tilt camera for on top of a rover.
5  Using Arduino / Programming Questions / Re: trouble with ELSE statement in servo project on: May 06, 2013, 08:45:31 pm
all right seems there was an error in the min max setting for servo1.attach() and servo2.attach()....
oi.
6  Using Arduino / Programming Questions / Re: trouble with ELSE statement in servo project on: May 06, 2013, 08:02:24 pm
Okay here is the whole code:
Code:
    XBOX CONTROLLER CONNECTIVITY WTH USB SHIELD
  This Started off as an Example sketch for the Xbox Wireless Reciver library - developed by Kristian Lauszus
 For more information about Xbox controller connectivity  to the USB host shield see the blog post:
 http://blog.tkjelectronics.dk/2012/12/xbox-360-receiver-added-to-the-usb-host-library/ or  send him an e-mail:
 kristianl@tkjelectronics.com

This has been modified by me Tim Bates(timcki)
 It supports up to four controllers wirelessly using the microsoft PC Dongle (I only use one)
 Since this will be used to move a pan and tilt camera mount, I have used the VarSpeedServo.h library to
 controll the servo speed so you dont vomit while watching the video
 */

#include <XBOXRECV.h>                // XboX library   
#include <VarSpeedServo.h>           // servo Speed library
USB Usb;                       
XBOXRECV Xbox(&Usb);                 // Create instances of type Servo. servo1 is the steering servo and servo2 is the ESC.
VarSpeedServo servo1;                // Create physical servo 1   
VarSpeedServo servo2;                // Create physical servo 2

//**************************************************************************************************************************
void setup(){
  pinMode(3, OUTPUT);                // Assign pin 3 as an output
  pinMode(5, OUTPUT);                // Assign pin 5 as an output   
  servo1.attach(5,555,1555);         // signal to servo on digital pin 5
  servo2.attach(3,555,1555);         // signal to servo2 on digital pin 3
  servo1.slowmove(90,100);           // tells servo1 where to go at startup and how fast to get there
  servo2.slowmove(90,100);           // tells servo2 where to go at startup and how fast to get there
  {
   
    Serial.begin(115200);            // Starts the serial communication   
   
    if (Usb.Init() == -1) {          // Starts the Xbox receiver library
      Serial.print(F("\r\nOSC did not start"));
      while(1); //halt
    }
    Serial.print(F("\r\nXbox Wireless Receiver Library Started"));
  }
}
//***************************************************************************************************************************

void loop() {
  Usb.Task();

  if(Xbox.XboxReceiverConnected) {
    for(uint8_t i=0;i<4;i++)

    {
      if(Xbox.Xbox360Connected[i]) {
        if(Xbox.getButtonPress(i,L2) || Xbox.getButtonPress(i,R2)) {
          Serial.print("L2: ");
          Serial.print(Xbox.getButtonPress(i,L2));
          Serial.print("\tR2: ");
          Serial.println(Xbox.getButtonPress(i,R2));
          Xbox.setRumbleOn(i,Xbox.getButtonPress(i,L2),Xbox.getButtonPress(i,R2));
        }
       if(Xbox.getAnalogHat(i,LeftHatX) > 7500 || Xbox.getAnalogHat(i,LeftHatX) < -7500 || Xbox.getAnalogHat(i,LeftHatY) > 7500 || Xbox.getAnalogHat(i,LeftHatY) < -7500 || Xbox.getAnalogHat(i,RightHatX) > 7500 || Xbox.getAnalogHat(i,RightHatX) < -7500 || Xbox.getAnalogHat(i,RightHatY) > 7500 || Xbox.getAnalogHat(i,RightHatY) < -7500)
       {

          /////////////////////////////////////////////////////////////////////////////////////////////////////////
          if(Xbox.getAnalogHat(i,LeftHatX) > 7500 || Xbox.getAnalogHat(i,LeftHatX) < -7500) {
            servo1.slowmove(map(Xbox.getAnalogHat(i,LeftHatX), 0, 1024, 0, 180),60);
            // servo1.slowmove(90,100);
            Serial.print(F("LeftHatX: "));
            Serial.print(Xbox.getAnalogHat(i,LeftHatX));
            Serial.print("\t");
          }
          else
          {
           servo1.write(90);
          }
          if(Xbox.getAnalogHat(i,LeftHatY) > 7500 || Xbox.getAnalogHat(i,LeftHatY) < -7500) {
            servo2.slowmove(map(Xbox.getAnalogHat(i,LeftHatY), 0, 1024, 180, 0),60);
            Serial.print(F("LeftHatY: "));
            Serial.print(Xbox.getAnalogHat(i,LeftHatY));
            Serial.print("\t");
          }
         else
        {
         servo2.write(90);
        }
          if(Xbox.getAnalogHat(i,RightHatX) > 7500 || Xbox.getAnalogHat(i,RightHatX) < -7500) {
            Serial.print(F("RightHatX: "));
            Serial.print(Xbox.getAnalogHat(i,RightHatX));
            Serial.print("\t");     
          }
          if(Xbox.getAnalogHat(i,RightHatY) > 7500 || Xbox.getAnalogHat(i,RightHatY) < -7500) {
            Serial.print(F("RightHatY: "));
            Serial.print(Xbox.getAnalogHat(i,RightHatY)); 
          }
          Serial.println();
         
          //servo1.write(90);
          //servo2.write(90);
       
       }
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        if(Xbox.getButtonClick(i,UP)) {
          servo1.slowmove(90,100);
          servo2.slowmove(135,100);
          Xbox.setLedOn(i,LED1);
          Serial.println(F("Up"));
        }     
        if(Xbox.getButtonClick(i,DOWN)) {
          servo1.slowmove(90,100);
          servo2.slowmove(90,100);
          Xbox.setLedOn(i,LED4);
          Serial.println(F("Down"));
          Serial.println(F("Starting Position"));
        }
        if(Xbox.getButtonClick(i,LEFT)) {
          servo1.slowmove(45,100);
          servo2.slowmove(90,100);
          Xbox.setLedOn(i,LED3);
          Serial.println(F("Left"));
        }
        if(Xbox.getButtonClick(i,RIGHT)) {
          servo1.slowmove(135,100);
          servo2.slowmove(90,100);
          Xbox.setLedOn(i,LED2);
          Serial.println(F("Right"));
        }       

        if(Xbox.getButtonClick(i,START)) {
          Xbox.setLedMode(i,ALTERNATING);
          Serial.println(F("Start"));
        }
        if(Xbox.getButtonClick(i,BACK)) {
          Xbox.setLedBlink(i,ALL);
          Serial.println(F("Back"));
        }
        if(Xbox.getButtonClick(i,L3))
          Serial.println(F("L3"));
        if(Xbox.getButtonClick(i,R3))
          Serial.println(F("R3"));

        if(Xbox.getButtonClick(i,L1))
          Serial.println(F("L1"));
        if(Xbox.getButtonClick(i,R1))
          Serial.println(F("R1"));
        if(Xbox.getButtonClick(i,XBOX)) {
          Xbox.setLedMode(i,ROTATING);
          Serial.print(F("Xbox (Battery: "));
          Serial.print(Xbox.getBatteryLevel(i)); // The battery level in the range 0-3
          Serial.println(F(")"));
        }
        if(Xbox.getButtonClick(i,SYNC))
          Serial.println(F("Sync"));

        if(Xbox.getButtonClick(i,A))
          Serial.println(F("A"));
        if(Xbox.getButtonClick(i,B))
          Serial.println(F("B"));
        if(Xbox.getButtonClick(i,X))
          Serial.println(F("X"));
        if(Xbox.getButtonClick(i,Y))
          Serial.println(F("Y"));
    }
     
    }
  } 
  delay(15);
}
The goal is to have the joystick move the camera left and right, when I let go it will return to a home position.
additionally I would like a couple of buttons to go to the 45 degrees left and right.
Thanks for any help.

I thought I had a handle on this coding thing now I am lost again:(
7  Using Arduino / Programming Questions / trouble with ELSE statement in servo project on: May 05, 2013, 11:38:32 pm
I am building a pan and tilt  camera mount controlled with an Xbox controller.
I am using these two libraries:
XBOXRECV.h                // XboX library   
VarSpeedServo.h          // Variable servo speed library

Okay here is the code snippet:
Code:
//if(Xbox.getAnalogHat(i,LeftHatX) > 31500 || Xbox.getAnalogHat(i,LeftHatX) < -31500 || Xbox.getAnalogHat(i,LeftHatY) > 7500 || Xbox.getAnalogHat(i,LeftHatY) < -7500 || Xbox.getAnalogHat(i,RightHatX) > 7500 || Xbox.getAnalogHat(i,RightHatX) < -7500 || Xbox.getAnalogHat(i,RightHatY) > 7500 || Xbox.getAnalogHat(i,RightHatY) < -7500)
        {
          if(Xbox.getAnalogHat(i,LeftHatX) > 7500 || Xbox.getAnalogHat(i,LeftHatX) < -7500) {
            servo1.slowmove(map(Xbox.getAnalogHat(i,LeftHatX), 0, 1024, 0, 179),60);
         
            Serial.print(F("LeftHatX: "));
            Serial.print(Xbox.getAnalogHat(i,LeftHatX));
            Serial.print("\t");
          }
         else  /////////////////////////HERE
         {
           servo1.slowmove(90,90);
   
          }
     
         if(Xbox.getAnalogHat(i,LeftHatY) > 7500 || Xbox.getAnalogHat(i,LeftHatY) < -7500)
         {
            servo2.slowmove(map(Xbox.getAnalogHat(i,LeftHatY), 0,1024 , 179, 0),60);
            Serial.print(F("LeftHatY: "));
            Serial.print(Xbox.getAnalogHat(i,LeftHatY));
            Serial.print("\t");
          }
          else  //////////////////////////////////////////////////// HERE
          {
           servo2.slowmove(90,90);
   
           } 
   
             if(Xbox.getAnalogHat(i,RightHatX) > 7500 || Xbox.getAnalogHat(i,RightHatX) < -7500) {
            Serial.print(F("RightHatX: "));
            Serial.print(Xbox.getAnalogHat(i,RightHatX));
            Serial.print("\t");     
          }
          if(Xbox.getAnalogHat(i,RightHatY) > 7500 || Xbox.getAnalogHat(i,RightHatY) < -7500) {
            Serial.print(F("RightHatY: "));
            Serial.print(Xbox.getAnalogHat(i,RightHatY)); 
          }
          Serial.println();
         
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        if(Xbox.getButtonClick(i,UP)) {
          servo1.slowmove(90,100);
          servo2.slowmove(135,100);
          Xbox.setLedOn(i,LED1);
          Serial.println(F("Up"));
        }
 
        if(Xbox.getButtonClick(i,DOWN)) {
          servo1.slowmove(90,100);
          servo2.slowmove(90,100);
          Xbox.setLedOn(i,LED4);
          Serial.println(F("Down"));
          Serial.println(F("Starting Position"));
        }
        if(Xbox.getButtonClick(i,LEFT)) {
          servo1.slowmove(45,100);
          servo2.slowmove(90,100);
          Xbox.setLedOn(i,LED3);
          Serial.println(F("Left"));
        }
        if(Xbox.getButtonClick(i,RIGHT)) {
         // servo1.slowmove(135,100);
          //servo2.slowmove(90,100);
          Xbox.setLedOn(i,LED2);
          Serial.println(F("Right"));
        }       
If I use the else statement the servos will return to the "Home" position  but none of the other buttons on the controller will function after the else statement
If I omit the else statement  the servos stay in an arbitrary positions but the button functions work

looking for a nudge in the right direction
I can post the whole code if you need it.
8  Using Arduino / Motors, Mechanics, and Power / Re: VarSpeedServo - a modified Servo library with speed control on: May 05, 2013, 08:51:03 pm
I've used the varspeedservo library in Arduino 1.0. I just changed WProgram.h to Arduino.h in one of the library files.

Thank you... I forgot about this little trick to get the libraries going with the 1.0+ IDE
I was beating my head for an hour,wondering what I am doing wrong,  before I read your post.
9  Using Arduino / Motors, Mechanics, and Power / Re: Knob sketch and a generic digital servo problems (beginner) on: April 26, 2013, 06:07:48 pm
Stupid, stupid , stupid servo!!!!

bought a new $5.99 servo from hobby people  and it works fine!
stupid stupid stupid!!!!

Thanks for everyone's help

Tim
10  Using Arduino / Motors, Mechanics, and Power / Re: Knob sketch and a generic digital servo problems (beginner) on: April 25, 2013, 06:54:12 pm
Thanks for the code.. It is my servo
I even hood up an oscilloscope the signal is clean, but when the servo is attached everything goes haywire.

I will have to go and get a new servo and try again

Thanks for your help
11  Using Arduino / Motors, Mechanics, and Power / Knob sketch and a generic digital servo problems (beginner) on: April 24, 2013, 09:30:48 pm
Playing around with the "knob" sketch from the servo library,

I am getting some "jitter" from the servo. when the pot is at 0 it is stable, when the pot is maxed the servo is also stable.
When the pot is somewhere in between the servo will move to that position, however it will shake or jitter.

The servo is a generic digital servo I got from a R/C Helicopter shop.   actual model is : spektrum DS821 

the servo works fine with a R/C receiver.

I have powered the servo from both the arduino and an external power supply
both with the same results
also I get the same results  from both an UNO and a Leonardo.

Do I need an analog servo ?
Or do I need a better (compatible) servo from Sparkfun or Adafruit?

Thanks
12  Development / Other Software Development / trying to give something back... (IDE) IDE Themes on: February 04, 2012, 01:21:15 am
I had some spare time...
Just wanted to give something back..

You can download the file here..http://bluto.com/files/theme.zip
13  Using Arduino / Networking, Protocols, and Devices / Re: Trying to learn about SPI... on: February 01, 2012, 04:03:23 am
Thank you..
Tim
14  Using Arduino / Networking, Protocols, and Devices / Trying to learn about SPI... on: January 31, 2012, 11:51:39 pm
Okay, I've got a 7 segment  led running from a shift register using spi...
It counts from 0 to 9 and starts over

Now I want to add a button to count up or down...

Can I add an analog button to the arduino on another pin
or do I have to put the button on the SPI bus?
15  Using Arduino / Programming Questions / replace delay(xxxx) with button press?? on: September 18, 2011, 11:52:46 pm
I have a 7 segment led running through a 74hc595 counting 0-9  with a small pause in between each
next incremental digit.

I would like to change this by adding a button press to go to the next digit up
Yes I am trying to make a scoreboard...

can delay(xxxx) be replaced by by adding instead
the code snippet from the button tutorial

I think i am having trouble understanding how to pause the shift register 74hc595 and restart it.

I found this sketch on the net
but I am stuck trying to modify it...

Code:
int dataPin = 11;
int clockPin = 12;
int latchPin = 8;
 
int len = 10;
 
//holders for infromation you're going to pass to shifting function
byte dataRED;
byte dataArrayRED[10];
 
byte off = 0x00;
byte decimalpoint = 0x80;
 
 
 
void setup() {
 
  //set pins to output because they are addressed in the main loop
  pinMode(latchPin, OUTPUT);
 
  //Arduino doesn't seem to have a way to write binary straight into the code
  //so these values are in HEX.  Decimal would have been fine, too.
 
  dataArrayRED[0] = 0x3f; //00111111 - 0
  dataArrayRED[1] = 0x06; //00000110 - 1
  dataArrayRED[2] = 0x5B; //01011011 - 2
  dataArrayRED[3] = 0x4F; //01001111 - 3
  dataArrayRED[4] = 0x66; //01100110 - 4
  dataArrayRED[5] = 0x6D; //01101101 - 5
  dataArrayRED[6] = 0x7D; //01111101 - 6
  dataArrayRED[7] = 0x07; //00000111 - 7
  dataArrayRED[8] = 0x7F; //01111111 - 8
  dataArrayRED[9] = 0x67; //01100111 - 9
 
}
 
void loop() {
 
int count = 100;
int val = 10; //this is for how many digits
 
 
 
for( int i = 0; i<count; i++ )
{
  digitalWrite(latchPin, 0);
 
 
   int digit2 = i % val;
  int digit1 = ( i - digit2 ) / val;
 
    shiftOut(dataPin, clockPin, dataArrayRED[ digit2 ]);
    shiftOut(dataPin, clockPin, dataArrayRED[ digit1 ]);
 
  digitalWrite(latchPin, 1);
  delay(30);                             //code for button here#############################
  delay(10);
}
 
}
 
 
// the heart of the program
void shiftOut(int myDataPin, int myClockPin, byte myDataOut) {
  // This shifts 8 bits out MSB first,
  //on the rising edge of the clock,
  //clock idles low
 
  //internal function setup
  int i=0;
  int pinState;
  pinMode(myClockPin, OUTPUT);
  pinMode(myDataPin, OUTPUT);
 
  //clear everything out just in case to
  //prepare shift register for bit shifting
  digitalWrite(myDataPin, 0);
  digitalWrite(myClockPin, 0);
 
  //for each bit in the byte myDataOut…
  //NOTICE THAT WE ARE COUNTING DOWN in our for loop
  //This means that %00000001 or "1" will go through such
  //that it will be pin Q0 that lights.
 
  for (i=7; i>=0; i--) 
  {
    digitalWrite(myClockPin, 0);
 
    //if the value passed to myDataOut and a bitmask result
    // true then... so if we are at i=6 and our value is
    // %11010100 it would the code compares it to %01000000
    // and proceeds to set pinState to 1.
    if( myDataOut & (1<<i) )
    {
pinState= 1;
    }
    else
    {
pinState= 0;
    }
 
    //Sets the pin to HIGH or LOW depending on pinState
 
    digitalWrite(myDataPin, pinState);
    //register shifts bits on upstroke of clock pin
    digitalWrite(myClockPin, 1);
    //zero the data pin after shift to prevent bleed through
    digitalWrite(myDataPin, 0);
  }
 
  //stop shifting
  digitalWrite(myClockPin, 0);
}
Pages: [1] 2