Show Posts
Pages: [1] 2 3 4
1  Using Arduino / Interfacing w/ Software on the Computer / Arduino + Stepper motor + puredata on: September 13, 2011, 04:52:41 pm
Hi, I'm working again on a stepper motor with a Rugged driver to control it with Arduino trough PureData

Now, I need to transcode in the PD language this sequence to work with TWO DIGITAL OUTPUT PINS:
 
     D1 - D2
1 - 0     1
2 - 1     1
3 - 1     0
4 - 0     0

This is the basic sequence for a stepper motor, did someome know how can i transcode it ??

best and thanks

KinoLab
2  Using Arduino / Motors, Mechanics, and Power / Re: Problem with Stepper Library on: August 04, 2011, 01:12:22 pm
Found the Solution......

this is the final code..
Code:
#include <StepperHighSpeed.h>
// Define how many steps there are in 1 revolution of your motor
#define STEPS_PER_REVOLUTION 200

#define BOARD  0   /* Arduino Duemilanove/Uno (ATmega328P) */
//#define BOARD  1   /* Arduino Mega (ATmega1280) */
//#define BOARD  2   /* Rugged Circuits Gator (ATmega324P) */

/**********************************************************/
/* YOU SHOULDN'T HAVE TO CHANGE ANYTHING BELOW THIS POINT */
/**********************************************************/
// In case no board is defined, guess from the processor
#ifndef BOARD
#  if defined(__AVR_ATmega328P__)
#    define BOARD 0
#  elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
#    define BOARD 1
#  elif defined(__AVR_ATmega324P__)
#    define BOARD 2
#  else
#    error You must define BOARD near the top of this file
#  endif
#endif

#if (BOARD!=0) && (BOARD!=1) && (BOARD!=2)
#error Unknown board
#endif

// Enable (PWM) outputs
#define EN1_PIN 3
#define EN2_PIN 11

// Direction outputs
#define DIR1_PIN 12
#define DIR2_PIN 13

StepperHighSpeed stepper(STEPS_PER_REVOLUTION, DIR1_PIN, DIR2_PIN);
// Set initial default values
unsigned RPM = 180;
unsigned PWM = 230;
unsigned DIR = -1;

// ---------- PIN FOR TRANSFER ----------------
int ledPin = 10; // LED per inviare segnale alla camera
int inPin = 4;   // Lettura sensore


void setup()
{
 
  // Configure all outputs off for now
  pinMode(EN1_PIN, OUTPUT); digitalWrite(EN1_PIN, LOW);
  pinMode(EN2_PIN, OUTPUT); digitalWrite(EN2_PIN, LOW);
  pinMode(DIR1_PIN, OUTPUT); digitalWrite(DIR1_PIN, LOW);
  pinMode(DIR2_PIN, OUTPUT); digitalWrite(DIR2_PIN, LOW);


   TCCR2B = _BV(CS21);

  // Now enable PWM and start motion
  analogWrite(EN1_PIN, PWM);
  analogWrite(EN2_PIN, PWM);
  stepper.setSpeed(RPM);
 
// --------- SETUP FOR TRANSFER ------------- 
pinMode(ledPin, OUTPUT);      // sets the digital pin 2 as output
pinMode(inPin, INPUT);      // sets the digital pin 1 as input
}


void loop()
{
// This is a busy-wait loop until the inter-step time passes
 stepper.step(DIR);
   
// --------- TRIGGER FOR CAMERA -------------     
    digitalWrite(ledPin, digitalRead(inPin));
}

thanks

Best

KinoLab
3  Using Arduino / Motors, Mechanics, and Power / Problem with Stepper Library on: August 03, 2011, 05:59:47 pm
Hi, I've a problem with the stepper library and i don't know how can i solve it :

So the arduino Board is driving a stepper motor with a rugged board motor driver, this is the code :

Code:
#include <StepperHighSpeed.h>
// Define how many steps there are in 1 revolution of your motor
#define STEPS_PER_REVOLUTION 200

#define BOARD  0   /* Arduino Duemilanove/Uno (ATmega328P) */
//#define BOARD  1   /* Arduino Mega (ATmega1280) */
//#define BOARD  2   /* Rugged Circuits Gator (ATmega324P) */

/**********************************************************/
/* YOU SHOULDN'T HAVE TO CHANGE ANYTHING BELOW THIS POINT */
/**********************************************************/
// In case no board is defined, guess from the processor
#ifndef BOARD
#  if defined(__AVR_ATmega328P__)
#    define BOARD 0
#  elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
#    define BOARD 1
#  elif defined(__AVR_ATmega324P__)
#    define BOARD 2
#  else
#    error You must define BOARD near the top of this file
#  endif
#endif

#if (BOARD!=0) && (BOARD!=1) && (BOARD!=2)
#error Unknown board
#endif

// Enable (PWM) outputs
#define EN1_PIN 3
#define EN2_PIN 11

// Direction outputs
#define DIR1_PIN 12
#define DIR2_PIN 13

StepperHighSpeed stepper(STEPS_PER_REVOLUTION, DIR1_PIN, DIR2_PIN);
// Set initial default values
unsigned RPM = 180;
unsigned PWM = 230;
unsigned DIR = -1;

void setup()
{
 
  // Configure all outputs off for now
  pinMode(EN1_PIN, OUTPUT); digitalWrite(EN1_PIN, LOW);
  pinMode(EN2_PIN, OUTPUT); digitalWrite(EN2_PIN, LOW);
  pinMode(DIR1_PIN, OUTPUT); digitalWrite(DIR1_PIN, LOW);
  pinMode(DIR2_PIN, OUTPUT); digitalWrite(DIR2_PIN, LOW);


   TCCR2B = _BV(CS21);

  // Now enable PWM and start motion
  analogWrite(EN1_PIN, PWM);
  analogWrite(EN2_PIN, PWM);
  stepper.setSpeed(RPM);
 
}


void loop()
{
// This is a busy-wait loop until the inter-step time passes
 stepper.step(DIR);
}

With this code everything is ok... but...
I need to connect to the same board an infrared sensor that each time that the motor make a 360ยบ, can read-it and send a digital output to another object....

so I'm triyng to insert this code in the master and i've a problem with the void loop ()
Code:
#include <StepperHighSpeed.h>
// Define how many steps there are in 1 revolution of your motor
#define STEPS_PER_REVOLUTION 200

#define BOARD  0   /* Arduino Duemilanove/Uno (ATmega328P) */
//#define BOARD  1   /* Arduino Mega (ATmega1280) */
//#define BOARD  2   /* Rugged Circuits Gator (ATmega324P) */

/**********************************************************/
/* YOU SHOULDN'T HAVE TO CHANGE ANYTHING BELOW THIS POINT */
/**********************************************************/
// In case no board is defined, guess from the processor
#ifndef BOARD
#  if defined(__AVR_ATmega328P__)
#    define BOARD 0
#  elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
#    define BOARD 1
#  elif defined(__AVR_ATmega324P__)
#    define BOARD 2
#  else
#    error You must define BOARD near the top of this file
#  endif
#endif

#if (BOARD!=0) && (BOARD!=1) && (BOARD!=2)
#error Unknown board
#endif

// Enable (PWM) outputs
#define EN1_PIN 3
#define EN2_PIN 11

// Direction outputs
#define DIR1_PIN 12
#define DIR2_PIN 13

StepperHighSpeed stepper(STEPS_PER_REVOLUTION, DIR1_PIN, DIR2_PIN);
// Set initial default values
unsigned RPM = 180;
unsigned PWM = 230;
unsigned DIR = -1;

// ----------  SETUP FOR TRANSFER SYSTEM ----------------
int ledPin = 2; // LED per inviare segnale alla camera
int inPin = 1;   // Lettura sensore
int val = 0;     // variable to store the read value
int count = 0;

void setup()
{
 
  // Configure all outputs off for now
  pinMode(EN1_PIN, OUTPUT); digitalWrite(EN1_PIN, LOW);
  pinMode(EN2_PIN, OUTPUT); digitalWrite(EN2_PIN, LOW);
  pinMode(DIR1_PIN, OUTPUT); digitalWrite(DIR1_PIN, LOW);
  pinMode(DIR2_PIN, OUTPUT); digitalWrite(DIR2_PIN, LOW);


   TCCR2B = _BV(CS21);

  // Now enable PWM and start motion
  analogWrite(EN1_PIN, PWM);
  analogWrite(EN2_PIN, PWM);
  stepper.setSpeed(RPM);
 
// --------- SETUP FOR TRANSFER SYSTEM ------------- 
pinMode(ledPin, OUTPUT);      // sets the digital pin 2 as output
pinMode(inPin, INPUT);      // sets the digital pin 1 as input

}


void loop()
{
// This is a busy-wait loop until the inter-step time passes
 stepper.step(DIR);
 
 // ---------- LOOP FOR TRIGGER CAMERA ---------
for (int i = 0; i < 1; ++i) {
   // Wait for input to go HIGH
   while (digitalRead (inPin) == LOW) {
   }
   // Wait for input to go LOW
   while (digitalRead (inPin) == HIGH) {
   }
}
digitalWrite (ledPin, HIGH);
delay (150);
digitalWrite (ledPin, LOW);

// ----------- FINE LOOP FOR TRIGGER CAMERA ------------------
}

I know that maybe is complicate to explain for me, but i don't know how can i create a loop inside the void loop () without the interference to the stepper.step (DIR) function...

Thanks and best

KinoLab
4  Using Arduino / Motors, Mechanics, and Power / Re: Problem Stepper Library High Speed on: May 12, 2011, 10:01:35 pm
HI Johnwasser, thanks for your answer, i'm trying different option and nothing with this motor... I'm looking around of the ACEELSTEPPER LIBRARY...
Anyway, the project is to modify a 16mm projector and be able to control it trough a Laptop... is for that the stepper motor... Cinema running at 24 images per second...

Anyway, i don't understand the Rubenjohnson answer ???

thanks again
5  Using Arduino / Motors, Mechanics, and Power / Re: Problem Stepper Library High Speed on: May 12, 2011, 12:50:53 pm
Hi Thanls for your answer,
I think that we have to look for others solutions....
I've try with your idea and when I arrived around 345 RPM the motor start to work in a strange way....

In the datasheet of the motor they speek of 4000 pps...
This is the link : http://www.cnsoyo.com/product_show_e.asp?id=8
and this is the model : SY42STH47-1206A

I don't know...
I'm loose...
6  Using Arduino / Motors, Mechanics, and Power / Re: Problem Stepper Library High Speed on: May 12, 2011, 11:43:47 am
SO, this is the code of the stepper library:

/*
  Sets the speed in revs per minute

*/
void StepperHighSpeed::setSpeed(long whatSpeed)
{
  this->step_delay = 60L * 1000L / this->number_of_steps / whatSpeed;
}

/*
  Moves the motor steps_to_move steps.  If the number is negative,
   the motor moves in the reverse direction.
 */
void StepperHighSpeed::step(int steps_to_move)

  int steps_left = abs(steps_to_move);  // how many steps to take
 
  // determine direction based on whether steps_to_mode is + or -:
  if (steps_to_move > 0) {this->direction = 1;}
  if (steps_to_move < 0) {this->direction = 0;}
   
   
  // decrement the number of steps, moving one step each time:
  while(steps_left > 0) {
  // move only if the appropriate delay has passed:
  if (millis() - this->last_step_time >= this->step_delay) {
      // get the timeStamp of when you stepped:
      this->last_step_time = millis();
      // increment or decrement the step number,
      // depending on direction:
      if (this->direction == 1) {
        this->step_number++;
        if (this->step_number == this->number_of_steps) {
          this->step_number = 0;
        }
      }
      else {
        if (this->step_number == 0) {
          this->step_number = this->number_of_steps;
        }
        this->step_number--;
      }
      // decrement the steps left:
      steps_left--;
      // step the motor to step number 0, 1, 2, or 3:
      stepMotor(this->step_number % 4);
    }
  }
}

I've found in the code a millis() option, but there is something that i don't understand, if i try to change for micros() the motor is hiss, so how can i change things to be able to read microsecond delay step ??

Thanks for the help...

7  Using Arduino / Motors, Mechanics, and Power / Re: Problem Stepper Library High Speed on: May 12, 2011, 11:08:43 am
Hi I found the AccelStepper Library here : http://www.open.com.au/mikem/arduino/AccelStepper/index.html
But When I try it, I can't go up to 1000 step per second.... so that i can't use it...

someone have others ideas ???

I'll try the Microseconds idea to see what happen..

Best
8  Using Arduino / Motors, Mechanics, and Power / Re: Problem Stepper Library High Speed on: May 11, 2011, 07:31:50 pm
Thanks for your answer, I'll work on this on next days and I'll post if I can do it....
 smiley-eek-blue
9  Using Arduino / Motors, Mechanics, and Power / Problem Stepper Library High Speed on: May 11, 2011, 10:59:27 am
Hi, I'm working on a project with a Stepper Motor and I need to go up to 1400 RPM of speed.
-- To control it I'm using this board (it's really greats...) : https://shop.ruggedcircuits.com/index.php?main_page=product_info&cPath=4&products_id=14&zenid=dd070fea017add31d25eb346801f7012

-- For the power I'm using a 0-30 V, 4Amp.... using it at 24 VDC

The problem now is that I've discover that the Stepper Library is limited to 300RPM... Why ?
If you open the Stepper Library file you found this :

setSpeed() function:

void Stepper::setSpeed(long whatSpeed)
{
  this->step_delay = 60L * 1000L / this->number_of_steps / whatSpeed;
}

The problem is that if whatSpeed is 300 then the above expression becomes:

     this->step_delay = 60 * 1000 / 200 / 300;  // This equals 1!

Anything bigger than 300 and the above expression becomes 0, which causes the inter-step delay to be 0 and the whole process fails.

So, I trying to see how we can update an high speed Stepper Library, but I'm not so "programmer"....

Did someone have an idea to how change the library to be able to go up with High-Speed Stepper Motor ????


Thanks

KinoLab
10  Using Arduino / Project Guidance / Re: Advice for replacing a motor in a 16mm film projector on: March 28, 2011, 03:39:38 pm
Hi, I'm on the same project and I would like to know i someone have found how much is the MAX TORQUE that the projector need to run...

I've found some high torque motor here : http://www.anaheimautomation.com/products/stepper/stepper-motor-item.php?sID=14&pt=i&tID=75&cID=19

But i don't understand how much is the torque for the projector...

Best

KinoLab
11  Using Arduino / Sensors / Re: Red light frequency on: March 27, 2011, 03:21:28 pm
Thanks for all your answers...
In general the speed will be really precise and constant, is for a 16mm projector, so the idea is to be able if is a 24 ips or if it change to 23.90 or what else...

The ply problem is that i'm not so familiar with electronic and did you some photos on how use a PIN DIODE ?

sorry and thanks

KinoLAb

12  Using Arduino / Sensors / Re: Re(a)d light frequency on: March 25, 2011, 08:26:18 am
Upss smiley-fat  sorry I haven't see the mistake...

thanks for your answer and did you think that a photo diode can read a frequency of around 72 input for second?

best
Ki
13  Using Arduino / Sensors / Red light frequency on: March 25, 2011, 08:09:02 am
Hi, I'm looking on how can i read the speed of a shutter with a digitalread and a light sensor... The idea is to be able to know how many RPS I'm using on the shutter.

The shutter is placed in front of the light, so i can read just ON and OFF of the light and calulate how many I have in a second.. and write it on a small LCD.

So, did someone know wich sensor i can use to work on this project??

Best

KinoLab
14  Using Arduino / Motors, Mechanics, and Power / Re: Arduino + Step MOTOR + DRIVER = max rpm and torque on: March 24, 2011, 09:48:55 pm
Hi, thanks for your answer,
En reality now the first problem is to found the adapt motor like this maybe : LINK : http://www.anaheimautomation.com/products/stepper/stepper-motor-item.php?sID=14&pt=i&tID=75&cID=19

I think that when i found a motor that can respect the 1440 RPM with a Max Torque of 1.4kg/cm ( this is the torque that i need...),
I can start to look for a driver...

So I'm just looking to found the right motor for the moment and I'm loosing in the world of step motor...

best

KinoLab
15  Using Arduino / Motors, Mechanics, and Power / Re: Arduino + Step MOTOR + DRIVER = max rpm and torque on: March 23, 2011, 02:40:08 pm
Hi, can i use this board tu run this motor and have the 1440 rpm that i need without loosing enough torque ??

LINK : http://creatroninc.com/adafruit-motor-sheild-assembled-for-arduino.html

thanks

KinoLab
Pages: [1] 2 3 4