hi All
i have been plugging away trying to learn programming with arduino and have learned a lot but im kind of stuck now
i found a simple acceleration sketch for stepper motors and i really like the way it works and the simplicity of use, so i am trying to create a library to use on multiple steppers each with a few different parameters with each call to the function (steps)
I keep getting errors when trying to verify and am not sure all the syntax and variables are in the proper places
I know its a lot and a really big mess but any help would be great
here is the sketch calling the function to move 6000 steps
im not sure if im declaring it properly or missing key parts
int steps = 6000;
byte step_Pin = 3;
stepper_Accel cell_Pickup = stepper_Accel(steps, step_Pin);
void setup() {
pinMode(step_Pin, OUTPUT);
}
void loop() {
cell_Pickup.simple_Accel(steps, step_Pin);
}
*this is a copy of the source file again im not really sure it is proper
// Source file
#include "arduino.h"
#include "accel.h"
stepper_Accel::stepper_Accel(int steps, byte step_Pin) {
_steps = steps;
_step_Pin = step_Pin;
}
void stepper_Accel::simple_Accel(void) {
int lowSpeed = 2000; // Adjust for lowest speed
int highSpeed = 300; // Highest speed is 200 with 400 steps per revolution
int change = 2;
int rampUpStop = (lowSpeed - highSpeed) / change;
if ( rampUpStop > _steps / 2 )
rampUpStop = _steps / 2;
int rampDownStart = _steps - rampUpStop;
int d = lowSpeed;
for (int i = 0; i < _steps; i++) {
digitalWrite(_step_PIN, HIGH);
digitalWrite(_step_PIN, LOW);
delayMicroseconds(d);
if ( i < rampUpStop )
d -= change;
else if ( i > rampDownStart )
d += change;
} // close for loop
} // close function
- And here is a copy of the header file
// Header file
#ifndef accel_h
#define accel_h
#include "Arduino.h"
class stepper_Accel {
private:
int _steps;
byte _step_Pin;
public:
stepper_Accel(int steps, byte step_Pin);
void simple_Accel(void);
};
#endif