Hello. I have got a task to design a control firmware for a stepper motor. It needs to rotate to one direction (close the door) when it receives signal, and rotate to another direction(open the door) when it receives another signal. I have been given some stepper motor and a driver:
I wasnt even able to find any information about this motor.
I am running a driver with 12V and 0.6A current and the motor seems to rotate in both direction using this sketch:
Since I require to rotate this stepper motor certain distance , would you recommend me using some library or build my own functions?
I also need to make this stepper rotate in accelerating manner. I have tried using accellstepper library
I am though confused about how exactly this library works : https://www.airspayce.com/mikem/ard...tepper.html#ace236ede35f87c63d18da25810ec9736
For example, how does moveTo function works? What value do I need to pass. Since the description mentions target position, how does a number that I pass refer to target position? What would happen if I pass 100 or -100?
I wasnt even able to find any information about this motor.
I am running a driver with 12V and 0.6A current and the motor seems to rotate in both direction using this sketch:
Code:
#define directionPin 3
#define stepPin 2
#define speedDelay 40 // change this to change the speed, the lower it is the faster it will go
void setup() {
// Initialize the Serial port:
Serial.begin(9600);
// set up the driver pins:
pinMode(stepPin, OUTPUT);
pinMode(directionPin, OUTPUT);
}
void loop() {
// Step forward 800 steps:
Serial.println("Forward");
digitalWrite(directionPin, HIGH);
for (int i=0; i<100; i++) {
digitalWrite(stepPin, HIGH);
digitalWrite(stepPin, LOW);
delay(speedDelay);
}
delay(500);
// Step backward 800 steps:
digitalWrite(directionPin, LOW);
for (int i=0; i<100; i++) {
digitalWrite(stepPin, HIGH);
digitalWrite(stepPin, LOW);
delay(speedDelay);
}
}
I also need to make this stepper rotate in accelerating manner. I have tried using accellstepper library
Code:
// ProportionalControl.pde
// -*- mode: C++ -*-
//
// Make a single stepper follow the analog value read from a pot or whatever
// The stepper will move at a constant speed to each newly set posiiton,
// depending on the value of the pot.
//
// Copyright (C) 2012 Mike McCauley
// $Id: ProportionalControl.pde,v 1.1 2011/01/05 01:51:01 mikem Exp mikem $
#include <AccelStepper.h>
// Define a stepper and the pins it will use
AccelStepper stepper(AccelStepper::DRIVER, 2, 3);
//direction d3
//pull d2
// This defines the analog input pin for reading the control voltage
// Tested with a 10k linear pot between 5v and GND
#define ANALOG_IN A0
void setup()
{
stepper.setMaxSpeed(200);
stepper.setSpeed(1);
}
void loop()
{
// Read new position
int analog_in = analogRead(ANALOG_IN);
stepper.moveTo(analog_in);
//stepper.setSpeed(1);
//stepper.set();
stepper.run();
//stepper.runSpeedToPosition();
}
For example, how does moveTo function works? What value do I need to pass. Since the description mentions target position, how does a number that I pass refer to target position? What would happen if I pass 100 or -100?
Attachments
-
806.5 KB Views: 13
-
1,018.7 KB Views: 13