This commit is contained in:
Tim Leuschner 2019-09-07 14:09:44 +02:00
parent 5eac2dd939
commit 8350be64a0
4 changed files with 13 additions and 13 deletions

View File

@ -16,7 +16,7 @@ doMove KEYWORD2
doRotate KEYWORD2
setRPM KEYWORD2
setSPR KEYWORD2
setMIC KEYWORD2
setMIS KEYWORD2
version KEYWORD2
#######################################

View File

@ -20,7 +20,7 @@
#include <stdlib.h>
A4988_Stepper::A4988_Stepper( int m_spr
, int m_rpm
, short m_mic
, short m_mis
, short m_dir_pin
, short m_stp_pin
, short m_ena_pin
@ -30,7 +30,7 @@ A4988_Stepper::A4988_Stepper( int m_spr
last_time = 0; // time stamp in us of the last step taken
motor_SPR = m_spr; // StepsPerRevolution
motor_RPM = m_rpm; // RoundsPerMinute
motor_MIC = m_mic; // Microsteps w/o effect if MS1-MS3 not connected - then full steps anyway
motor_MIS = m_mis; // Microsteps w/o effect if MS1-MS3 not connected - then full steps anyway
motor_dir_pin = m_dir_pin;
motor_stp_pin = m_stp_pin;
motor_ena_pin = m_ena_pin;
@ -61,7 +61,7 @@ void A4988_Stepper::adjustPins(void) {
void A4988_Stepper::adjustMicrosteps() {
if ((motor_ms1_pin<99)&&(motor_ms2_pin<99)&&(motor_ms3_pin<99)) {
switch (motor_MIC){
switch (motor_MIS){
case 1:
digitalWrite(motor_ms1_pin, LOW);
digitalWrite(motor_ms2_pin, LOW);
@ -100,12 +100,12 @@ void A4988_Stepper::adjustMicrosteps() {
motor_delay = 60L * 1000L * 1000L / motor_SPR / motor_RPM / motor_MIC;
}
void A4988_Stepper::setMIC(short oneToSixteen) {
void A4988_Stepper::setMIS(short oneToSixteen) {
motor_MIC = oneToSixteen;
adjustMicrosteps();
}
short A4988_Stepper::getMIC(void) {
short A4988_Stepper::getMIS(void) {
return motor_MIC;
}
@ -158,7 +158,7 @@ void A4988_Stepper::doMove(long howManySteps)
void A4988_Stepper::doRotate(long howManyDegrees)
{ long lSteps = 0;
lSteps = motor_SPR*motor_MIC*howManyDegrees/360;
lSteps = motor_SPR*motor_MIS*howManyDegrees/360;
doMove(lSteps);
}

View File

@ -35,8 +35,8 @@ class A4988_Stepper {
void setRPM (int whatRPM );
int getRPM (void );
void setMIC (short OneToSixteen);
short getMIC (void );
void setMIS (short OneToSixteen);
short getMIS (void );
void setSPR (int howMany );
int getSPR (void );

View File

@ -52,11 +52,11 @@ void A4988Init(void)
A4988_ms3_pin = pin[GPIO_A4988_MS3];
A4988_spr = 200;
A4988_rpm = 30;
A4988_mic = 1;
A4988_mis = 1;
myA4988 = new A4988_Stepper( A4988_spr
, A4988_rpm
, A4988_mic
, A4988_mis
, A4988_dir_pin
, A4988_stp_pin
, A4988_ena_pin
@ -65,7 +65,7 @@ void A4988Init(void)
, A4988_ms3_pin );
A4988_spr = myA4988->getSPR();
A4988_rpm = myA4988->getRPM();
A4988_mic = myA4988->getMIC();
A4988_mis = myA4988->getMIS();
if ((A4988_ms1_pin < 99)&&(A4988_ms2_pin < 99)&&(A4988_ms3_pin < 99)&&(A4988_ena_pin<99)) {
AddLog_P2(LOG_LEVEL_INFO, PSTR("STP: A4988-Driver initialized (%dSPR, %dRPM,%dMIC). Pins: Dir[%d] Stp[%d] Ena[%d] MS1[%d] MS2[%d] MS3[%d]"),A4988_spr, A4988_rpm, A4988_mic, A4988_dir_pin,A4988_stp_pin,A4988_ena_pin,A4988_ms1_pin,A4988_ms2_pin,A4988_ms3_pin);
} else {
@ -229,7 +229,7 @@ void CmndSetSPR(void)
ResponseCmndDone();
}
void CmndSetMic(void)
void CmndSetMIS(void)
{
if ((pin[GPIO_A4988_MS1] < 99) && (pin[GPIO_A4988_MS2] < 99) && (pin[GPIO_A4988_MS3] < 99)) {
short micPlease = 1;