Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CODE_OWNERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ In addition to @arendst the following code is mainly owned by:
| xdrv_89_ |
| xdrv_90_esp32_dingtian_relay | @barbudor
| xdrv_91_esp32_twai | @arendst
| xdrv_92_ |
| xdrv_92_vid6608 | @petrows
| xdrv_93_ |
| xdrv_94_ |
| |
Expand Down
43 changes: 43 additions & 0 deletions lib/lib_div/arduino-vid6608/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Dockerfile to build platformio
FROM petrows/arduino-vid6608:latest

RUN <<PKG
set -e
apt-get -qq update
apt-get install -y --no-install-recommends \
python3 \
python3-pip \
python3-venv \

apt-get -qq clean
rm -rf /var/lib/apt/lists/*
PKG

# Python virtual env
ENV VIRTUAL_ENV=/var/venv
RUN mkdir -p -m 777 $VIRTUAL_ENV
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

# Default env
ENV HOME=/opt/home
RUN mkdir -p -m 777 $HOME

RUN pip install platformio==6.1.18

# Copy config file and enforce deps installation
COPY platformio.ini /tmp/
RUN <<PIO
cd /tmp/
# Install common packages
platformio pkg install
# Install required tools
platformio pkg install -t platformio/tool-cppcheck
platformio pkg install -t platformio/tool-clangtidy
# Cleanup
rm -rf /tmp/*
# Allow this image to run under non-root
chmod -R 777 $HOME
PIO

WORKDIR /app
674 changes: 674 additions & 0 deletions lib/lib_div/arduino-vid6608/LICENSE.txt

Large diffs are not rendered by default.

93 changes: 93 additions & 0 deletions lib/lib_div/arduino-vid6608/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Gauge stepper motor Switec X25.168 driver for VID6608 and clones

![Moving example](doc/output.gif)

This library implements driver for Arduino framework
for following driver chips for analog automotive gauges (Switec X25.168, X27.168 and clones) with microstepping support:

* VID6606 (2 motors)
* VID6608 (4 motors)
* VT6608S
* AX1201728SG
* BY8920
* many others

Driver chips with microstepping is the recommended way to drive such motors,
they provide much more relailabe and smooth movement with reduced noise and
to avoid skipping steps.

This library is developed by inspiration from [SwitecX25](https://github.com/clearwater/SwitecX25) library, many thanks to author.

This library has following features:

* More precise Datasheet complaince
* Another smoothing method (requires less calculations)
* Optimized homing
* Extended API's

[![PlatformIO Registry](https://badges.registry.platformio.org/packages/petrows/library/vid6608.svg)](https://registry.platformio.org/libraries/petrows/vid6608)

## Chip documentation

See [VID6606 Datasheet (English)](doc/VID6608.pdf).

## Wiring

This library requires that two pins (per drive) are connected to two outputs.

![Datasheet scheme](doc/operation-configuration.png)

* Step pin f(scx): impulse to drive motor to one microstep;
* Direction pin CW/CCW: defines direction ov movement;
* RESET pin: does not controlled by this library. Hold to VDD to enable function (see notes below);

## RESET pin

This library does not control RESET pin, please perform this inside your firmware.

I have problems with some IC's, as they lost function after RESET pin manipulation. [Datasheet](doc/VID6608.pdf) recommends to hold it LOW during boot, and set to HIGH to enable operation, but i recommend just to connect to VDD to be safe.

## Setting zero

Motor is set to zero by moving whole scale and kept bouncing on the one of
dead positions. This library provides optimized way to perform homing: it does
1/2 of scale forward, then full scale backward. This helps to reduce bouncing
like in the classical "full scale back" method.

## Function documentation

See inline documentation in source code: [vid6608.h](src/vid6608.h).

## Basic example

Simple code to activate the library.

```cpp
#include <Arduino.h>
#include <vid6608.h>

// standard X25.168 range 315 degrees at 1/3 degree steps
#define STEPS (320 * 12)

#define PIN_STEP 26 // Pin, connected to f(scx)
#define PIN_DIR 27 // Pin. connected to CW/CCW

vid6608 motor1(PIN_STEP, PIN_DIR, STEPS);

unsigned long nextMoveTime = 0;
uint16_t nextMovePos = 0;

void setup(void)
{
// Run the motor against the stops
motor1.zero();
// Plan next move (in loop())
motor1.moveTo(100);
}

void loop(void)
{
// the motor only moves when you call update
motor1.loop();
}
```
Binary file added lib/lib_div/arduino-vid6608/doc/VID6608.pdf
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/lib_div/arduino-vid6608/doc/output.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
78 changes: 78 additions & 0 deletions lib/lib_div/arduino-vid6608/examples/RandomMove/RandomMove.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#include <Arduino.h>
#include <vid6608.h>

// standard X25.168 range 315 degrees at 1/3 degree steps
#define STEPS (320 * 12)

#define PIN_STEP 26 // Pin, connected to f(scx)
#define PIN_DIR 27 // Pin. connected to CW/CCW

// Custom Acceleration table for the X27.168
// Proposed non-linear curve by ChatGPT
static vid6608::AccelTable accelTable[] = {
{30, 3000},
{65, 2920},
{100, 2780},
{135, 2600},
{170, 2380},
{205, 2140},
{240, 1890},
{275, 1650},
{310, 1420},
{345, 1210},
{380, 1020},
{415, 860},
{450, 730},
{485, 620},
{520, 530},
{555, 460},
{590, 410},
{625, 370},
{660, 340},
{695, 320},
{730, 310},
{765, 305},
{800, 300},
};

vid6608 motor1(PIN_STEP, PIN_DIR, STEPS);

unsigned long nextMoveTime = 0;
uint16_t nextMovePos = 0;

void setup(void)
{
// Initalize debug here
Serial.begin(9600);
Serial.println("Setup");
// Set custom curve
motor1.setAccelTable(accelTable);
// run the motor against the stops
motor1.zero();
// We are done
Serial.println("Setup done");
}

void loop(void)
{
// the motor only moves when you call update
motor1.loop();

// Wait for motor to finish
if (motor1.isStopped()) {
// Plan next move here, to have real pause between moves
if (nextMoveTime == 0) {
nextMoveTime = millis() + random(500, 2000);
} else {
// Wait for next move time
if (millis() > nextMoveTime) {
// Plan next move here
nextMoveTime = 0;
nextMovePos = random(0, STEPS);
Serial.print("Moving to ");
Serial.println(nextMovePos);
motor1.moveTo(nextMovePos);
}
}
}
}
19 changes: 19 additions & 0 deletions lib/lib_div/arduino-vid6608/library.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "vid6608",
"keywords": "driver, motor, control",
"description": "Arduino library for driving IC VID6608 and clones for Switec X25.168 / X27.168 miniature stepper motors",
"homepage": "https://github.com/petrows/arduino-vid6608",
"repository":
{
"type": "git",
"url": "https://github.com/petrows/arduino-vid6608.git"
},
"authors": {
"name": "Petr Golovachev",
"email": "petro@petro.ws",
"url": "https://petro.ws/"
},
"version": "1.0.2",
"frameworks": "arduino",
"platforms": "*"
}
9 changes: 9 additions & 0 deletions lib/lib_div/arduino-vid6608/library.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name=vid6608
version=1.0.2
author=Petr Golovachev
maintainer=Petr Golovachev <petro@petro.ws>
sentence=Arduino library for driving IC VID6608 and clones for Switec X25.168 / X27.168 miniature stepper motors
paragraph=This library allows to control automotive gauge stepper motors with microstepping drivers with smooth movement
category=Device Control
url=https://github.com/petrows/arduino-vid6608
architectures=*
31 changes: 31 additions & 0 deletions lib/lib_div/arduino-vid6608/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[platformio]
default_envs = esp32doit-devkit-v1

[env:uno]
platform = atmelavr
board = uno
framework = arduino
check_tool = cppcheck
check_src_filters =
+<src/*>
+<examples/RandomMove/*>

[env:esp32doit-devkit-v1]
platform = espressif32
board = esp32doit-devkit-v1
framework = arduino

[env:d1_mini_pro]
platform = espressif8266
board = d1_mini_pro
framework = arduino
Loading