Show Posts
Pages: 1 ... 3 4 [5] 6 7 ... 10
61  Using Arduino / Programming Questions / Re: PWM to limit current to bipolar stepper on: March 28, 2013, 03:00:26 pm
I have two of these https://solarbotics.com/product/k_cmd/ I wanted for another project but, if they are appropriate, I'll have to sacrifice them. What do you think?
62  Using Arduino / Programming Questions / Re: PWM to limit current to bipolar stepper on: March 28, 2013, 01:12:02 pm
Since I have so many motors, can this be built from scratch or will I need a bunch of prefab drivers?
63  Using Arduino / Programming Questions / Re: PWM to limit current to bipolar stepper on: March 28, 2013, 11:52:22 am
So would a more complex PWM get around this problem? http://www.flickr.com/photos/50454200@N06/8597337363/ is a crude drawing of the project.
64  Using Arduino / Programming Questions / Re: PWM to limit current to bipolar stepper on: March 28, 2013, 11:00:21 am
Can a simple delay microseconds do the trick or something more complicated?
65  Using Arduino / Programming Questions / Re: PWM to limit current to bipolar stepper on: March 28, 2013, 05:17:41 am
The 8amp, 12v power supply is running three servos, three DC motors, the two steppers, LED's, etc., so I thought it was necessary but now I face the dilemma of controlling current. The unipolar on an ULN2003 is running but extremely hot, even with the three servos, and DC motors running simultaneously. What current limiting circuit can handle this?
66  Using Arduino / Programming Questions / PWM to limit current to bipolar stepper on: March 27, 2013, 10:12:07 pm
The SN754410 driver I am using works fine on a breadboard powered by a 12v, 500ma wall wort but burns very hot and fails to run the bipolar stepper when wired to my project board, which has a 12v, 8amp supply. I am assuming that the current must be limited?  If so, can this be accomplished with PWM?  A search of this topic offers a number of discussions, none of which I fully understand.  The same board uses a ULN2003 to drive a unipolar stepper without a problem. 
67  Using Arduino / Motors, Mechanics, and Power / Re: SN754410 bipolar stepper problem on: March 27, 2013, 04:06:40 pm
Sorry, the motor is rated at 10~12v, 259ma, 7.5 ohm., four wires.
68  Using Arduino / Motors, Mechanics, and Power / Re: SN754410 bipolar stepper problem on: March 27, 2013, 03:05:59 pm
I should have mentioned the breadboard was powered by a 12v, 500ma wall wort. Do I need a regulating circuit to feed this driver?
69  Using Arduino / Motors, Mechanics, and Power / SN754410 bipolar stepper problem on: March 27, 2013, 02:40:47 pm
I am using an SN754410 to drive a bipolar stepper using the typical 4 pin setup. On a breadboard, it works fine. On the project board, it doesn't and overheats. The stepper rattles but does not respond to switches. This http://www.flickr.com/photos/50454200@N06/8595069215/  photo of the very poorly designed board will hopefully illustrate the problem. The Mega is powered by a 6v dc to dc converter from an 8amp, 12v power supply.  The lower chip is an ULN2003 driving a unipolar stepper without a problem. I am hoping the photo will suffice. My schematics are amateurish as best.
70  Using Arduino / Programming Questions / Re: Unipolar stepper - one direction on: March 24, 2013, 04:59:50 pm
I should have mentioned the ULN2003 to drive the motors. The sketch above I assume will run the stepper without this chip or the library. Fortunately, I adapted a much shorter sketch which works well. Thanks. 
71  Using Arduino / Programming Questions / Unipolar stepper - one direction on: March 23, 2013, 09:10:20 pm
Is this sketch the most direct method to run a unipolar stepper in one direction? Using the stepper library would seem to involve less code but I haven't been successful using it for a single direction.
Code:
int motorPin1 = 8;
int motorPin2 = 9;
int motorPin3 = 10;
int motorPin4 = 11;
int delayTime = 10;

void setup() {
pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
pinMode(motorPin3, OUTPUT);
pinMode(motorPin4, OUTPUT);
}

void loop() {
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);
delay(delayTime);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);
delay(delayTime);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, LOW);
delay(delayTime);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, HIGH);
delay(delayTime);
}
72  Using Arduino / Programming Questions / FSM (was dysfunctional function) on: March 23, 2013, 01:35:30 pm
This sketch has two problems; while fast to start, it is very slow to escape the loop after the sensor value is beyond the threshold. Secondly, the stepper runs one revolution, then stops rather than continuous until the threshold is met.

Code:
#include <Servo.h>
#include <Stepper.h>

#define STEPS1 200
#define STEPS2 200
#define STOP2 0

int leftSwitchPin = 2;
int rightSwitchPin = 3;
int buttonState1 = 0;
int buttonState2 = 0;


//const int stepsPerRevolution1 = 44;
Stepper myStepper1(STEPS1, 44,42,40,38);
int stepCount = 0;

//const int stepsPerRevolution2 = 44;
Stepper myStepper2(STEPS2, 53,51,49,47);

//LED's
int ledLeft = 35;
int ledMiddle = 36;
int ledRight = 37;
int ledFrontRow [10] = {
  20,21,22,23,24,25,26,27,28,29};

//Motors
int motorLeft = 29; //dc motors
int motorMiddle = 31;
int motorRight = 33;

//Servo
Servo myservo1;
Servo myservo2;
Servo myservo3;

unsigned int duration = 0;             

int lasttime1 = 0;
int lasttime2 = 0;
int randstart = 0;
int randend = 0;

int pos1 = 0;
int pos2 = 0;
int pos3 = 0;

int sonarPin = A1;
int sonarVal =0;

void setup()
{


  pinMode (leftSwitchPin,INPUT);               //shift to pin 2
  pinMode (rightSwitchPin,INPUT);               //shift to pin 3

  myStepper1.setSpeed(60);
  myStepper2.setSpeed(60);

  pinMode(motorLeft, OUTPUT);  //dc motors
  pinMode(motorMiddle, OUTPUT);
  pinMode(motorRight, OUTPUT);

  //pinMode(sonarVal,INPUT);

  myservo1.attach(9);
  myservo2.attach(10);
  myservo3.attach(11);

  Serial.begin(9600);
  pinMode(sonarPin,INPUT); 
}
void loop()
{
  static int state1 = 1;
  static int state2 = 1;
  sonarVal = analogRead (sonarPin);
  Serial.println (sonarVal);
 
  switch (state1)
  {
  case 1:
    if (sonarVal < 20)
    {
      myStepper2.step(STEPS2);  // [color=red]Turns one revolution ONLY[/color]


      digitalWrite (motorLeft, HIGH);
      digitalWrite (motorMiddle,HIGH);
      digitalWrite (motorRight, HIGH);

      lasttime1 = millis();
      randstart =  random(554, 1054);
      randend =  random(500, 2400);

      while(pos1 <= randend) 
      {     
        pos1 += 1;
        myservo1.writeMicroseconds(pos1);   
        delay(2);   //2                 
      }
      while(pos2 <= randend) 
      {     
        pos2 += 1;
        myservo2.writeMicroseconds(pos2);
        delay(2);   //2                 
      }
      while(pos3 <= randend) 
      {
        pos3 += 1;
        myservo3.writeMicroseconds(pos3);   
        delay(2);   //2                 
      }
      duration = millis() - lasttime1;
      lasttime2 = millis();

      while(pos1 >= randstart)   
      {                               
        pos1-=1;
        myservo1.write(pos1);   
        delay(2);                     
      }
      while(pos2 >= randstart)   
      {                               
        pos2-=1;
        myservo2.write(pos2);   
        delay(2);                     
      }
      while(pos3 >= randstart)   
      {                               
        pos3-=1;
        myservo3.write(pos3);   
        delay(2);                     
      }
      duration = millis() - lasttime2;
      duration = millis() - lasttime1;
    }
    else
    {
      state1=2;
      {
      }
      // break;

    case 2:
      if (sonarVal > 20)
      {

        myStepper2.step(STOP2 ); //   [color=red]Should turn the stepper off[/color].
        digitalWrite (motorLeft, LOW);
        digitalWrite (motorMiddle,LOW);
        digitalWrite (motorRight,LOW);
        myservo1.write(0);
        myservo2.write(0);
        myservo3.write(0);
      }
      else
      {
        state1 = 1;
        {

          break;

          break;
        }
        break;
      }
      break;
    }

  }
}

73  Using Arduino / Programming Questions / Re: FSM (was dysfunctional function) on: March 20, 2013, 10:03:39 am
I assumed the immediate delay (500) was necessary to read the serial monitor? As for those within the servo statements, I pirated that part of the sketch and, frankly, don't completely understand it.
74  Using Arduino / Programming Questions / Re: FSM (was dysfunctional function) on: March 19, 2013, 07:56:36 pm
I have searched far and wide but can't find an example of multiple FSM in a single loop. Both these FSM function in separate sketches, but not together here. The motors respond, the servos don't. Guesswork has proven futile.

Code:
void loop()
{
  static int state1 = 1;
  static int state2 = 1;
  sonarVal = analogRead (sonarPin);
  Serial.println (sonarVal);
  delay(500);
  switch (state1)
  {
  case 1:
    if (sonarVal < 11)
    {
      digitalWrite (motorLeft, HIGH);
      digitalWrite (motorMiddle,HIGH);
      digitalWrite (motorRight, HIGH);
    }
    else
    {
      state1=2;
    }
    break;

  case 2:
    if (sonarVal > 11)
    {
      digitalWrite (motorLeft, LOW);
      digitalWrite (motorMiddle,LOW);
      digitalWrite (motorRight,LOW);
    }
    else
    {
      state1 = 1;
    }
    break;
    // default:
    // break;
    switch (state2)
    case 3:
      if (sonarVal < 11)
      {

        Serial.println(sonarVal);
        delay(250);//50

          lasttime1 = millis();
        randstart =  random(554, 1054);
        randend =  random(500, 2400);

        while(pos1 <= randend) 
        {     
          pos1 += 1;
          myservo1.writeMicroseconds(pos1);   
          delay(2);   //2                 
        }
        while(pos2 <= randend) 
        {     
          pos2 += 1;
          myservo2.writeMicroseconds(pos2);
          delay(2);   //2                 
        }
        while(pos3 <= randend) 
        {
          pos3 += 1;
          myservo3.writeMicroseconds(pos3);   
          delay(2);   //2                 
        }
        duration = millis() - lasttime1;
        lasttime2 = millis();

        while(pos1 >= randstart)   
        {                               
          pos1-=1;
          myservo1.write(pos1);   
          delay(2);                     
        }
        while(pos2 >= randstart)   
        {                               
          pos2-=1;
          myservo2.write(pos2);   
          delay(2);                     
        }
        while(pos3 >= randstart)   
        {                               
          pos3-=1;
          myservo3.write(pos3);   
          delay(2);                     
        }
        duration = millis() - lasttime2;
        duration = millis() - lasttime1;

      } 
      else
      {
        state2 =4;
      } 
    break;

  case 4:
    if (sonarVal > 11)
    {
      myservo1.write(0);
      myservo2.write(0);
      myservo3.write(0); 
    }
    else
    {
      state2 = 3;
    }
    break;
  default:
    break;

  }
}
75  Using Arduino / Programming Questions / Re: FSM (was dysfunctional function) on: March 19, 2013, 02:00:36 pm
The motors (dc, servos, and steppers) are intended to activate parts of the piece when the viewer approaches the sculpture, continuously until the the sensor no longer detects their presence.
Pages: 1 ... 3 4 [5] 6 7 ... 10