Note: here is described how to use some stepper motors with SimVim Interface. For basic principles and construction of stepper motors (bipolar/unipolar), controlling types (full step, half step, etc.), you can find a lot of information in Internet.
X27.168 and similar motors are considered as main in SimVimCockpit firmware program. These motors are suitable to replicate most of aircraft pointer instruments and can be driven with controllers, designed specifically for these very low-current motors.
28BYJ-48 (5V power) stepper motor with gearbox can be used in SimVimCockpit with the A3967 controller in full-step mode. This motor is much slower, but cheap and easyly accessible and can be used for many aircraft pointer instruments.
Also it is possible to use other stepper motors with SimVimCockpit. Be aware, though, that most of them require much more power to run, in terms of current consumption or operating voltage. Use only appropriate controllers and power supply for powerful steppers!
SimVimCockpit plugin monitors simulator parameters and translates them into signal sequences for every connected stepper motor. Firmware receives that data and converts them into specific stepping pattern for every motor, keeping track of amplitude and speed of change, simulator FPS rate and code loop timing, to eliminate jumps and ensure smooth movement.
Any stepper motor in SimVimCockpit should only be used with a special controller (driver) that is capable to drive the selected stepper motor and must have the required output current, operating voltage, step frequency.
Be noted, that these controllers are NOT simple drivers like ULN2003, which is just a current amplifier used between the low-current microcontroller outputs and high-current motor.
Only those controller chips or boards that include STEP and DIR control inputs (also can be marked as Clock and CW/CCW) - can be used with SimVimCockpit.
Most aircraft gauges have a partial, sectoral dial, when the needle can only rotate in the range of less than full 360 degrees. Other important instruments have continuous 360-degree rotation (heading, navigation instruments).
To set stepper-driven instrument pointer to the start (zero) position two method can be used - either mechanical stopper or zero-position sensor. On SimVim start or reconnection, the firmware program moves the motor shaft until the needle/card cross the position sensor or stops against the mechanical limiter, then resets position counter and moves the pointer to a position defined by simulator.
For sectoral gauge both methods are suitable, and for instrument with continuous rotation only position sensor can be used (IR optocoupler, or switch).
X25.xx - X27.xx stepper motors have an internal mechanical limiter (stop pin), that allow you to use these steppers for any instrument with rotation up to 315 degrees without any modification.
Any other stepper motors with unlimited rotation can be used for sectoral gauges, with the addition of a small pin that stops the needle rotation in the leftmost position.
Even if the motor has high torque, you can still use the stop pin for the needle. Just fix the needle to the shaft freely enough to let the shaft to continue its rotation when the needle is stopped by the pin.
Also, for high-torque motor you can add the momentary limit switch (button) as a simple position sensor. It can be placed on the other end of the stepper motor shaft, as it's shown in the right picture
A good way to make a position sensor for X27 stepper is to use an optical (infra-red) sensor - a pair of infrared LED and IR photodiode, as shown in the picture, using the white instrument needle as the "mirror" that deflects the light from the LED onto the sensor.
As an optical pair the TCRT5000 sensor is good to use - it's simple and cheap. It should be connected as on the diagram and work fine with a resistor of about 360 Ohm (you may need to test various resistors).
Note: Place the sensor behind non-reflecting, not transparent material that has a thin (1-2 mm) vertical slit, to exclude unwanted reaction or too wide detection window. Don't make the slit it in the exact "zero" position, it may be shifted slightly CCW by half of the needle width, because it will "catch" the moment when the needle just starts to cross the sensor window.
For instruments that have no needle but have a rotating disc (card) you should paint the back side of this card black-matte. Only thin (0.5mm) white strip of paper or other good reflecting surface should be place on the back of the disc or cylinder in "zero" or "north" position.
In current versions of SimVimCockpit you can control stepper motors using additional "SimVimStepper" controller board. It is simply one Uno or Nano Arduino board with special SimVim stepper control firmware onboard (that you need to upload from the SimVim plugin menu).
This "slave" board is connected with the Master controller board, getting data intendent for the steppers. The internal code of the slave board is fully dedicated to generate correct positioning, speed/acceleration move for multiple stepper motors.
The "slave" controller board (Uno, Nano) is linked with the Master controller board using serial interface, when Tx output signal of one board is connected to the Rx iput of another board.
For the stepper control the Tx1,Rx1 ports are used in SimVim. So, you should always connect the Tx pin (#1) of the slave board with Rx1 pin (#19) of the master board, and "slave" Rx (pin 0) - with the "master" Tx1 (pin #18).
Note 1. Never forget to connect the GNDs of each board ( and other devices as well) to the common GND wire.
Note 2: When you need to upload stepper control firmware to the slave board you need to disconnect the Rx,Tx wires before uploading! To simplify this you simply can add a "shut-off" switch breaking this two wires.
Another option - you can leave the Rx/Tx connected, but press the Reset button on the master board and hold it while uploading stepper firmware to the slave board.
The slave board receives all data from the master controller board only. So, you don't need to keep it connected to USB port after the SimVimStepper firmware upload. You can use any +5V source connected to the slave board using USB connector, or +5V pin. It can be the same source that is used for feeding the stepper motor controllers (AX1201728SG or VID6606, STI6608).
Choose a parameter for stepper output in the configurator and select the stepper controller output number for it. If your gauge has an initial position sensor, mark the "Position Sensor" checkbox when configuring it (for 360-degree rotation gauges it is set as default).
Any stepper gauge can be "linked" with any electric bus and make it work dependant on this bus voltage. For example you gauge may stop working (and be moved to the zero position) if the bus voltage drops below assigned value.
You can assign two parameters for output to one particular stepper gauge and make it dependant on some input (switch) state or specific parameter value. For example you gauge may show voltage from different sources.
Before using the "sectoral" stepper driven instrument in the cockpit you need to calibrate it. Use the convenient Calibration Tool in the SimVim plugin to correctly map the data value range on the gauge dial.
! No calibration is needed for continuous (full-circle) rotation instrument. Just assign it and start your plane!