xdrv_92_vid6608: Advanced zero routine for analog gauges, library update (#24218)
* VID6608: Add option to skip auto-zero rouitine * VID6608: Update library to version 1.0.3, add Zero control for Gauge
This commit is contained in:
parent
206216cc34
commit
272fd431ef
BIN
lib/lib_div/arduino-vid6608/doc/StepperMotor-X27-168v1.fzpz
Normal file
BIN
lib/lib_div/arduino-vid6608/doc/StepperMotor-X27-168v1.fzpz
Normal file
Binary file not shown.
BIN
lib/lib_div/arduino-vid6608/doc/vid6608-example-sketch.fzz
Normal file
BIN
lib/lib_div/arduino-vid6608/doc/vid6608-example-sketch.fzz
Normal file
Binary file not shown.
BIN
lib/lib_div/arduino-vid6608/doc/vid6608-example-sketch_bb.png
Normal file
BIN
lib/lib_div/arduino-vid6608/doc/vid6608-example-sketch_bb.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 98 KiB |
@ -13,7 +13,7 @@
|
|||||||
"email": "petro@petro.ws",
|
"email": "petro@petro.ws",
|
||||||
"url": "https://petro.ws/"
|
"url": "https://petro.ws/"
|
||||||
},
|
},
|
||||||
"version": "1.0.2",
|
"version": "1.0.3",
|
||||||
"frameworks": "arduino",
|
"frameworks": "arduino",
|
||||||
"platforms": "*"
|
"platforms": "*"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
name=vid6608
|
name=vid6608
|
||||||
version=1.0.2
|
version=1.0.3
|
||||||
author=Petr Golovachev
|
author=Petr Golovachev
|
||||||
maintainer=Petr Golovachev <petro@petro.ws>
|
maintainer=Petr Golovachev <petro@petro.ws>
|
||||||
sentence=Arduino library for driving IC VID6608 and clones for Switec X25.168 / X27.168 miniature stepper motors
|
sentence=Arduino library for driving IC VID6608 and clones for Switec X25.168 / X27.168 miniature stepper motors
|
||||||
|
|||||||
@ -48,6 +48,7 @@ vid6608::vid6608(int stepPin, int dirPin, uint16_t maxSteps /*= VID6608_MAX_STEP
|
|||||||
this->dirPinState = MOVE_NONE; // invalid state to force update on first step
|
this->dirPinState = MOVE_NONE; // invalid state to force update on first step
|
||||||
this->currentPosition = 0;
|
this->currentPosition = 0;
|
||||||
this->targetPosition = 0;
|
this->targetPosition = 0;
|
||||||
|
this->targetPositionNext = 0;
|
||||||
this->setAccelTable(defaultAccelTable);
|
this->setAccelTable(defaultAccelTable);
|
||||||
// Setup pins
|
// Setup pins
|
||||||
pinMode(this->stepPin, OUTPUT);
|
pinMode(this->stepPin, OUTPUT);
|
||||||
@ -56,16 +57,19 @@ vid6608::vid6608(int stepPin, int dirPin, uint16_t maxSteps /*= VID6608_MAX_STEP
|
|||||||
digitalWrite(this->dirPin, LOW);
|
digitalWrite(this->dirPin, LOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
void vid6608::zero(uint16_t delay /*= VID6608_DEFAULT_ZERO_SPEED*/) {
|
void vid6608::zero(uint16_t initialPos /*= VID6608_DEFAULT_MAX_STEPS/2*/, uint16_t delay /*= VID6608_DEFAULT_ZERO_SPEED*/) {
|
||||||
// We have to optimize the zeroing process to avoid bouncing on end-stops
|
// We have to optimize the zeroing process to avoid bouncing on end-stops
|
||||||
// Drive makes 1/2 move forward and 1/2 backward to reduce bouncing
|
// Drive makes 1/2 move forward and 1/2 backward to reduce bouncing
|
||||||
// This will reduce bouncing, if the last position was not a zero position
|
// This will reduce bouncing, if the last position was not a zero position
|
||||||
uint16_t halfSteps = this->maxSteps / 2;
|
if (initialPos >= this->maxSteps) {
|
||||||
// Move to halfSteps forward
|
initialPos = this->maxSteps - 1;
|
||||||
for (uint16_t x = 0; x < halfSteps; x++) {
|
}
|
||||||
|
uint16_t stepsForward = this->maxSteps - initialPos;
|
||||||
|
// Move forward to defined steps count
|
||||||
|
for (uint16_t x = 0; x < stepsForward; x++) {
|
||||||
step(MOVE_FORWARD, delay);
|
step(MOVE_FORWARD, delay);
|
||||||
}
|
}
|
||||||
// Move to halfSteps back
|
// Move full round back to 0
|
||||||
for (uint16_t x = 0; x < this->maxSteps; x++) {
|
for (uint16_t x = 0; x < this->maxSteps; x++) {
|
||||||
step(MOVE_BACKWARD, delay);
|
step(MOVE_BACKWARD, delay);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,9 +47,10 @@ class vid6608 {
|
|||||||
* Uses optimized method to reduce bouncing end-stops
|
* Uses optimized method to reduce bouncing end-stops
|
||||||
* @warning this function is blocking, execution is delayed upon done
|
* @warning this function is blocking, execution is delayed upon done
|
||||||
*
|
*
|
||||||
|
* @param initialPos initial position to assume zeroing, default is half of maxSteps. If you know the "old" gauge potision, you can provide it here to avoid end-stop bounce
|
||||||
* @param delay single step delay, controls sthe speed of motor, default is deined in VID6608_DEFAULT_ZERO_SPEED
|
* @param delay single step delay, controls sthe speed of motor, default is deined in VID6608_DEFAULT_ZERO_SPEED
|
||||||
*/
|
*/
|
||||||
void zero(uint16_t delay = VID6608_DEFAULT_ZERO_SPEED);
|
void zero(uint16_t initialPos = VID6608_DEFAULT_MAX_STEPS/2, uint16_t delay = VID6608_DEFAULT_ZERO_SPEED);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Shedules movement to defined absolute position
|
* @brief Shedules movement to defined absolute position
|
||||||
|
|||||||
@ -1132,6 +1132,7 @@
|
|||||||
//#define USE_HRE // Add support for Badger HR-E Water Meter (+1k4 code)
|
//#define USE_HRE // Add support for Badger HR-E Water Meter (+1k4 code)
|
||||||
//#define USE_A4988_STEPPER // Add support for A4988/DRV8825 stepper-motor-driver-circuit (+10k5 code)
|
//#define USE_A4988_STEPPER // Add support for A4988/DRV8825 stepper-motor-driver-circuit (+10k5 code)
|
||||||
//#define USE_VID6608 // Add support for VID6608 Automotive analog gauge driver (+0k7 code)
|
//#define USE_VID6608 // Add support for VID6608 Automotive analog gauge driver (+0k7 code)
|
||||||
|
// #define VID6608_RESET_ON_INIT true // Reset VID6608 on init (default: true), change if you control this manually
|
||||||
|
|
||||||
//#define USE_PROMETHEUS // Add support for https://prometheus.io/ metrics exporting over HTTP /metrics endpoint
|
//#define USE_PROMETHEUS // Add support for https://prometheus.io/ metrics exporting over HTTP /metrics endpoint
|
||||||
|
|
||||||
|
|||||||
@ -76,6 +76,16 @@
|
|||||||
#define VID6608_RTOS
|
#define VID6608_RTOS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reset all drives on init?
|
||||||
|
*
|
||||||
|
* Disable if you dont want to perform reset/homing operation on driver init,
|
||||||
|
* usefull for cases, where you have advanced mode (i.e. use saved values from NVRAM to restore and manual reset).
|
||||||
|
*/
|
||||||
|
#ifndef VID6608_RESET_ON_INIT
|
||||||
|
#define VID6608_RESET_ON_INIT true
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "vid6608.h"
|
#include "vid6608.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -178,7 +188,7 @@ void CmndGaugeCommand(int32_t command, uint32_t index, int32_t payload) {
|
|||||||
ResponseAppend_P(PSTR("\"%d\":{"), (int32_t)(x+1));
|
ResponseAppend_P(PSTR("\"%d\":{"), (int32_t)(x+1));
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case GAUGE_ZERO:
|
case GAUGE_ZERO:
|
||||||
driver->zero();
|
driver->zero(payload);
|
||||||
ResponseAppend_P(PSTR("\"cmd\":\"zero\",\"pos\":0"));
|
ResponseAppend_P(PSTR("\"cmd\":\"zero\",\"pos\":0"));
|
||||||
break;
|
break;
|
||||||
case GAUGE_SET:
|
case GAUGE_SET:
|
||||||
@ -287,8 +297,12 @@ void VID6608Init() {
|
|||||||
vid6608Drives[x] = new vid6608(pinStep, pinDir);
|
vid6608Drives[x] = new vid6608(pinStep, pinDir);
|
||||||
|
|
||||||
// Perform homing operation
|
// Perform homing operation
|
||||||
|
if (VID6608_RESET_ON_INIT) {
|
||||||
vid6608Drives[x]->zero();
|
vid6608Drives[x]->zero();
|
||||||
AddLog(LOG_LEVEL_DEBUG, PSTR("VID: zero %d done"), x);
|
AddLog(LOG_LEVEL_DEBUG, PSTR("VID: zero %d done"), x);
|
||||||
|
} else {
|
||||||
|
AddLog(LOG_LEVEL_DEBUG, PSTR("VID: zero %d skipped"), x);
|
||||||
|
}
|
||||||
vid6608Present = true;
|
vid6608Present = true;
|
||||||
} else {
|
} else {
|
||||||
vid6608Drives[x] = nullptr;
|
vid6608Drives[x] = nullptr;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user