Show Posts
Pages: [1]
1  Using Arduino / Interfacing w/ Software on the Computer / Re: Servos do not work when controlled by Processing and Standard Firmata on: February 07, 2013, 06:42:10 pm
Yes I can do things like turning things off and on.  I have run the examples that come for processing and all of them work. They do not, however, give an example to control the servos. 

Thanks for the reply.
2  Using Arduino / Interfacing w/ Software on the Computer / Re: Servos do not work when controlled by Processing and Standard Firmata on: February 07, 2013, 12:14:06 am
I want to add one more piece of information about this if anyone has any clue why it is not working.  Today I substituted the signal wire for where the servos were with an led, and there was no output at all.

Has anyone successfully used standard firmata, servos, and processing? Were there any changes from using the servo firmata?
3  Using Arduino / Interfacing w/ Software on the Computer / Servos do not work when controlled by Processing and Standard Firmata on: February 05, 2013, 12:26:57 am
I  am working on creating a biped robot.  I have function running in Processing that output motor positions to the servos on the robot.  Currently I am using the Servo Firmata loaded onto my arduino uno.  This works fine with the Standard Version of Processing 1.5.1.  I am using a MacBook Pro.  I have an initial successful walking gait, but I would like to add an accelerometer so I want to use the standard firmata.  When the standard firmata is loaded onto the arduino the same program no longer functions.  I have used a stand alone firmata tester application downloaded from the firmata website and I can control the servos and i/o pins fine.

I am not sure where the problem is. Is this common that the standard firmata does not work with servos?  I have tried a different computer with different code and still it does not work.

The Processing sketch is as follows:
Code:
import processing.serial.*;

import cc.arduino.*;

Arduino arduino;

float y1f, y2f, y3f, y4f, y5f, y6f;
int y1i, y2i, y3i, y4i, y5i, y6i;

float x1;
float s = 4.0;
//Right Knee
float A1 = -60.0;//39.084;
float B1 = 10.0;//26.434;
float C1 = 6.00;//5.1762;
float D1 = 90.0;//109.2;
//Left Knee
float A2 = 60.00;//-38.612;
float B2 = 30.00;//5.3432;
float C2 = 6.000;//4.9554;
float D2 = 90.00;//90.392;

float A3 = 20.00;//90;//74.808;
float B3 = 0.1571;//-2.9442;
float C3 = 5.284;//2.142;//0.15928;
float D3 = 70.00;//-0.0021288;


float A4 = 20.00;//90;//74.808;
float B4 = 0.1571;//-2.9442;
float C4 = 5.284;//2.142;//3.142;//0.15928;
float D4 = 110.00;//-0.0021288;

float A5 = 20.00;
float B5 = 0.1571;
float C5 = 0;//3.142;
float D5 = 85.00;

float A6 = 15.00;
float B6 = 0.1571;
float C6 = 0;
float D6 = 90.00;

void setup() {
  size(470, 200);
  
  println(Arduino.list());
  arduino = new Arduino(this, Arduino.list()[4], 57600);
  
//  arduino.pinMode(14, Arduino.INPUT);
//  arduino.pinMode(15, Arduino.INPUT);
  arduino.pinMode(8, Arduino.SERVO);
  arduino.pinMode(9, Arduino.SERVO);
  arduino.pinMode(10, Arduino.SERVO);
  arduino.pinMode(11, Arduino.SERVO);
  arduino.pinMode(12, Arduino.SERVO);
  arduino.pinMode(7, Arduino.SERVO);
}

void draw(){

  line(1,250,50,250);
  for(float i=1.0; i<41.0; i=i+s){
    x1 = i;
    y2f = A1*exp(-pow((x1-B1),2)/pow(C1,2))+D1;
    y1f = A2*exp(-pow((x1-B2),2)/pow(C2,2))+D2;
    y3f = A3*sin(B3*x1+C3)+D3;
    y4f = A4*sin(B4*x1+C4)+D4;
    y5f = A5*sin(B5*x1+C5)+D5;
    y6f = A6*sin(B6*x1+C6)+D6;
    //y3f = A3+B3*x1+C3*pow(x1,2)+D3*pow(x1,3);
   // y4f = A4+B4*(-1*x1+41.000)+C4*pow((-x1+41.000),2)+D4*pow((-x1+41.000),3);
    
    println("Y values");
    println(y1f);
    println(y2f);
    println(y3f);
    println(y4f);
    println(y5f);
    
    y1i = int(y1f);
    y2i = int(y2f);
    y3i = int(y3f);
    y4i = int(y4f);
    y5i = int(y5f);
    y6i = int(y6f);
    
    arduino.analogWrite(7, y6i);
    delay(15);
    arduino.analogWrite(8, y1i);
    delay(15);
    arduino.analogWrite(12, y2i);
    delay(15);
    arduino.analogWrite(9, y3i);
    delay(15);
    arduino.analogWrite(11, y4i);
    delay(15);
    arduino.analogWrite(10, y5i);
    delay(15);
//    delay(50);
    y1i = -1*y1i+250;
    y2i = -1*y2i+250;
    y3i = -1*y3i+250;
    y4i = -1*y4i+250;
    point(x1,y1i);
    point(x1,y2i);
    point(x1,y3i);
    point(x1,y4i);
  }
}
4  Using Arduino / Programming Questions / Re: adding math.h to library on: March 14, 2012, 04:56:53 pm
Quote
You already have math.h.

This must be something I have overlooked.
Are all of the libraries already included?
I was under the impression that they needed to be downloaded.

Thanks for the clarification.
5  Using Arduino / Programming Questions / adding math.h to library on: March 14, 2012, 03:44:18 pm
I am trying to add the math.h to my library.
I'm not sure if I am not looking in the right place for a download, but I just can't seem to get it in my libraries.
[http://www.nongnu.org/avr-libc/user-manual/group__avr__math.html]

Do I have to create a new document and archive it?
Is there a download somewhere?

Any help would be appreciated.
Thanks.
6  Topics / Robotics / Re: 5 Servo Control for Robot ARm on: February 06, 2012, 06:24:06 pm
Thanks for the help.
Its looking a lot better.
7  Topics / Robotics / 5 Servo Control for Robot ARm on: January 27, 2012, 04:24:21 pm
I made a robot arm using 5 servo motors.  I'm looking for a program to run the arm.
I need to be able to control the arm.
I have 5 spst switches and one 10k potentiometer.

What I had in mind was to turn on one switch and control one servo at a time.

I am using an Arduino Uno, an 8-position DIP switch (Radio Shack), 5x 10k resistors, 5x HKSCM16-5 Single Chip Digital Servo (5V) Mini servos, and 1 10k potentiometer.

-The setup is each switch connected to the positive 5v and then to a 10 k resistor then to the ground.  In between the switch and resistor is a wire that runs to a digital input pin.
-The potentiometer is connected to the positive 5v, the ground, and an analog in.
-The servos are each connected to the positive 5v, the ground, and a pwm digital pin.

I am a beginner at writing the code so I tried to use different programs that I had seen before.

The code I used was:

Code:
#include <Servo.h>

Servo servo1;
Servo servo2;
Servo servo3;
Servo servo4;
Servo servo5;

int potpin = 0;
int switch1 = 1;
int switch2 = 2;
int switch3 = 4;
int switch4 = 7;
int switch5 = 8;
int valp;
int val1 = 0;
int val2 = 0;
int val3 = 0;
int val4 = 0;
int val5 = 0;

void setup()
{
  servo1.attach(5);
  servo2.attach(6);
  servo3.attach(9);
  servo4.attach(10);
  servo5.attach(11);
}

void loop()
{
  val1 = digitalRead(switch1);
  if (val1 == HIGH){
    valp = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023)
    valp = map(valp, 0, 1023, 0, 179);     // scale it to use it with the servo (value between 0 and 180)
    servo1.write(valp);                  // sets the servo position according to the scaled value
    delay(15);
  }
  val2 = digitalRead(switch2);
  if (val2 == HIGH){
    valp = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023)
    valp = map(valp, 0, 1023, 0, 179);     // scale it to use it with the servo (value between 0 and 180)
    servo2.write(valp);                  // sets the servo position according to the scaled value
    delay(15);
  }
  val3 = digitalRead(switch3);
  if (val3 == HIGH){
    valp = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023)
    valp = map(valp, 0, 1023, 0, 179);     // scale it to use it with the servo (value between 0 and 180)
    servo3.write(valp);                  // sets the servo position according to the scaled value
    delay(15);
  }
  val4 = digitalRead(switch4);
  if (val4 == HIGH){
    valp = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023)
    valp = map(valp, 0, 1023, 0, 179);     // scale it to use it with the servo (value between 0 and 180)
    servo4.write(valp);                  // sets the servo position according to the scaled value
    delay(15);
  }
  val5 = digitalRead(switch5);
  if (val5 == HIGH){
    valp = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023)
    valp = map(valp, 0, 1023, 0, 179);     // scale it to use it with the servo (value between 0 and 180)
    servo5.write(valp);                  // sets the servo position according to the scaled value
    delay(15);
  }
}
  
 
Any help in the code or wiring would be great.

Moderator: Code tags added.
Pages: [1]