Accel Stepper Library Help
hello,
i working on rfid enabled door unlocker using arduino uno pololu drv8825 stepper driver, , rc522 rfid module. im struggling getting stepper motors turn. the code long post entirely here im going post chunks of important parts question here:
important note: i have following code working on arduino:
now not working code:
first include accelstepper library
and tell library pins hooked up:
accelstepper stepper1(1, 4, 3);
then under void setup();
i set max speed, acceleration, , distance
then on main loop. this check eeprom see if card stored.
warning: i beginner coder code no means close perfect. i trying best work optimize it.
now functions defined open door: arduino runs wakedriver() function sets slp (sleep pin) high. the stepper motor under holding torque. unfortunately dosent anthing else h
any , appreciated
tyler
i working on rfid enabled door unlocker using arduino uno pololu drv8825 stepper driver, , rc522 rfid module. im struggling getting stepper motors turn. the code long post entirely here im going post chunks of important parts question here:
important note: i have following code working on arduino:
code: [select]
// constantspeed.pde
// -*- mode: c++ -*-
//
// shows how run accelstepper in simplest,
// fixed speed mode no accelerations
/// \author mike mccauley (mikem@airspayce.com)
// copyright (c) 2009 mike mccauley
// $id: constantspeed.pde,v 1.1 2011/01/05 01:51:01 mikem exp mikem $
#include <accelstepper.h>
accelstepper stepper(1, 4, 3);
int slp = 8;
void setup()
{
digitalwrite(slp, high);
//attachinterrupt(buttonint, unlock, rising);
stepper.setmaxspeed(100000);
stepper.setacceleration(100*4);
stepper.moveto(50*8);
}
void loop()
{ fun();
}
void fun()
{stepper.run();
}
now not working code:
first include accelstepper library
and tell library pins hooked up:
accelstepper stepper1(1, 4, 3);
then under void setup();
i set max speed, acceleration, , distance
code: [select]
stepper1.setmaxspeed(10000);
stepper1.setacceleration(100*4);
stepper1.moveto(50*8);
then on main loop. this check eeprom see if card stored.
code: [select]
if ( findid(readcard) ) { // if not, see if card in eeprom
serial.println("welcome, shall pass");
opendoor(); // open door lock
}
else { // if not, show id not valid
serial.println("you shall not pass");
delay(10);
warning: i beginner coder code no means close perfect. i trying best work optimize it.
now functions defined open door: arduino runs wakedriver() function sets slp (sleep pin) high. the stepper motor under holding torque. unfortunately dosent anthing else h
code: [select]
void wakedriver()
{
digitalwrite(slp, high); //power driver sleep
delay(10); // pause while driver wakes up
}
void opendoor()
{
wakedriver(); //run wake driver i have driver waking , @ holding torque
stepper1.run(); //make stepper run based on done in setup
if (stepper1.distancetogo()==0) //if motors have moved designated amount
{door();} //run door else have steppers continue running. not sure if needed.
else
stepper1.run();
}
void door()
{
if (digitalread(doorswitch)==high); //check see if switch pushed
lockdoor(); // if lock door
}
void lockdoor()
{
stepper1.moveto(-50*8); //move steppers in opposite direction lock door.
digitalwrite(slp, low); //put driver in sleep mode power down stepper.
}
any , appreciated
tyler
first, need post code can see overall picture. can add attachment. problems in parts don't look.
the thread stepper motor basics may helpful. simple stepper code not need library.
...r
the thread stepper motor basics may helpful. simple stepper code not need library.
...r
Arduino Forum > Using Arduino > Motors, Mechanics, and Power (Moderator: fabioc84) > Accel Stepper Library Help
arduino
Comments
Post a Comment