Start v2 work
This commit is contained in:
Binary file not shown.
+17
-12
@@ -1,11 +1,5 @@
|
||||
//Config stuff
|
||||
|
||||
/* Set positions 1-4 in steps for stop locations.
|
||||
* Scaled is figured for 10 positions between 1 and 4
|
||||
* Position: 1 2 3 4 Scaled
|
||||
*/
|
||||
long shade[5] = {0,20500,41000,60000,0};
|
||||
|
||||
/* Speed Settings in Steps/Second
|
||||
* You will have to play with these values to find a
|
||||
* reliable setup. I recomend putting a small extra load
|
||||
@@ -16,6 +10,23 @@ long shade[5] = {0,20500,41000,60000,0};
|
||||
#define stepperSpeed 1100.0 //Max Speed
|
||||
#define stepperAccel 175.0 //Acceleration Rate
|
||||
|
||||
/* Drive motor selection.
|
||||
* You have choice between 2 style motors.
|
||||
*
|
||||
* 28BYJ-48 : 5v or 12v | Though slow, these motors are cheap.
|
||||
* The 5v has the advantage of being able to receive power from a
|
||||
* power bank. This could allow operation when your electricity goes out.
|
||||
*
|
||||
* Nema 17 : 12v | This motor should be faster, but will require a
|
||||
* brake or to remain powered to hold its position.
|
||||
*
|
||||
* 28BYJ will be controlled by steps, while Nema will be controlled by degrees.
|
||||
*
|
||||
* Uncomment the appropriate line below. Edit the config at the top of selected.
|
||||
*/
|
||||
#include "stepperMini.h"
|
||||
//#include "stepperNema.h"
|
||||
|
||||
int connectTimeout = 100; // How many attempts can we make before giving up on Blynk
|
||||
#define blynkRtcInterval = 30; // How often to sync the time. (Would be used for timers)
|
||||
|
||||
@@ -36,13 +47,7 @@ int stepperTime[2][2] = {};
|
||||
*/
|
||||
const int eepromSize = 512;
|
||||
|
||||
//Declare motor pins
|
||||
#define mtrPin1 D5//D5
|
||||
#define mtrPin2 D7//D7
|
||||
#define mtrPin3 D6//D6
|
||||
#define mtrPin4 D8//D8
|
||||
|
||||
const int stepPerRev = 4096; //Steps needed to make 1 revolution
|
||||
|
||||
//Button Config
|
||||
#define buttonEnable true //True to enable button controls
|
||||
|
||||
@@ -93,17 +93,10 @@ void blynkRun() {
|
||||
}
|
||||
|
||||
|
||||
//Write motor pins low to be sure the motor is unpowered
|
||||
void motorOff() {
|
||||
digitalWrite(mtrPin1,LOW);
|
||||
digitalWrite(mtrPin2,LOW);
|
||||
digitalWrite(mtrPin3,LOW);
|
||||
digitalWrite(mtrPin4,LOW);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void moveNow() {
|
||||
|
||||
void motorControl() {
|
||||
|
||||
//If motor has reached it's target location, run this
|
||||
if (stepper.distanceToGo() == 0) {
|
||||
@@ -168,4 +161,3 @@ bool timerFunc(int _comp) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* rst | Reset home position to 0
|
||||
*/
|
||||
|
||||
//version 1.2.0
|
||||
//version 2.0.0
|
||||
|
||||
#include <AccelStepper.h>
|
||||
#include <EEPROM.h>
|
||||
@@ -42,6 +42,7 @@ AccelStepper stepper(HALFSTEP, mtrPin1,mtrPin2,mtrPin3,mtrPin4);
|
||||
|
||||
|
||||
|
||||
|
||||
long int stepPosition = 0;
|
||||
int connectAttempt = 0;
|
||||
long int posNow = 0;
|
||||
@@ -262,7 +263,7 @@ void loop() {
|
||||
|
||||
stepper.run(); //AccelStepper runs here
|
||||
|
||||
moveNow();
|
||||
motorControl();
|
||||
|
||||
} //END LOOP
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
//Code for 28BYJ-48
|
||||
|
||||
|
||||
/* Config Section
|
||||
*
|
||||
*/
|
||||
|
||||
/* Set positions 1-4 in steps for stop locations.
|
||||
* Scaled is figured for 10 positions between 1 and 4
|
||||
* Position: 1 2 3 4 Scaled
|
||||
*/
|
||||
long shade[5] = {0,20500,41000,60000,0};
|
||||
|
||||
//Declare motor pins
|
||||
#define mtrPin1 D5//D5
|
||||
#define mtrPin2 D7//D7
|
||||
#define mtrPin3 D6//D6
|
||||
#define mtrPin4 D8//D8
|
||||
|
||||
const int stepPerRev = 4096; //Steps needed to make 1 revolution
|
||||
|
||||
|
||||
/* Motor Specific Functions
|
||||
*
|
||||
*/
|
||||
|
||||
//Write motor pins low to be sure the motor is unpowered
|
||||
void motorOff() {
|
||||
digitalWrite(mtrPin1,LOW);
|
||||
digitalWrite(mtrPin2,LOW);
|
||||
digitalWrite(mtrPin3,LOW);
|
||||
digitalWrite(mtrPin4,LOW);
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
//Code for Nema 17
|
||||
Reference in New Issue
Block a user