TeensyStep and X-Plane interfacing question....

EAL727Capt

Well-known member
Hello!

Yesterday, I discovered the TeensyStep library and was very excited to learn of its existence.
Thankfully, I have two (2) spare Teensy 3.2s laying around so I started to play with some coding.

Backround:
I'm building a home cockpit of a Boeing 727-200 aircraft with X-Plane as the flight sim engine.
I have converted OEM engine indicators from the real aircraft using X27.168 stepper motors to drive the indicator needles.
I am also using VID6606 IC boards (also new to me).

I have a sketch right now but it isn't doing what I want it to do....its not moving in sync with what is happening in X-Plane. In fact, I can't get the stepper to move at all...just a little jittering which tells me I've got power going to the stepper so wiring is okay with the VID6606 board.

In my sketch (attached), on X-Plane start-up, I'd like to have the stepper move from whatever position its currently on (in its powered down state) backwards to the ZERO position, pause a moment and then read the X-Plane data ref based on that particular engine's values and move the stepper to that 'actual' position.
I am using the FlightSimControls already loaded on my Teensy 3.2...hasn't failed me yet in my other indicators and is highly recommended.
I did not find much reference material on the TeensyStep library (I'm probably not searching correctly), thus my reason for posting here.

My current sketch (not working.....yet)----

Code:
/*==========================================================================
   N1 TESTING with TeensyStep, Teensy 3.2, VID6606 and X27.168 stepper motor
  ===========================================================================
*/

#include "TeensyStep.h"
#include "Stepper.h"

Stepper E1N1(2, 3);       // STEP pin: 2, DIR pin: 3
StepControl controller;    // Use default settings

FlightSimFloat e1n1;

float E1N1_pos; // Eng 1 N1 position

const long STEPS_PER_REVOLUTION = 635;
const float STEPS_PER_DEGREE = ((float) STEPS_PER_REVOLUTION) / 360.0;

void setup()
{
  Serial.begin(9600);
  E1N1.setAcceleration(50000);
  E1N1.setMaxSpeed(50000);
  E1N1.setTargetRel(0);
  controller.move(E1N1);
  e1n1 = XPlaneRef("FJS/727/Eng/N11Needle");
}

void loop() {
  FlightSim.update();
  E1N1_pos = e1n1 * STEPS_PER_DEGREE;
  E1N1.setPosition(E1N1_pos);
  E1N1.setTargetRel(E1N1_pos);
  controller.move(E1N1);

}



Yesterday, I was able to get six (6) indicators to move to their full maximum and minimum limits using a Teensy 3.2 (and later a Teensy 4.1) and understand that a TeensyStep library for Teensy 4.1 is under development.
My sketch from yesterday works flawlessly in moving the six (6) indicators with the 'one revolution at-a-time' example, tweaked of course.

Code:
/*
  Stepper library
  Teensy 4.1 (and Teensy 3.2---just change pin assignments)
  X27.168 steppers (6)

*/

#include <Stepper.h>

const int stepsPerRevolution = 635;  // change this to fit the number of steps per revolution
// for your motor

Stepper E1N1(stepsPerRevolution, 0, 1, 2, 3);
Stepper E2N1(stepsPerRevolution, 4, 5, 6, 7);
Stepper E3N1(stepsPerRevolution, 11, 10, 9, 8);
Stepper E1N2(stepsPerRevolution, 13, 14, 15, 16);
Stepper E2N2(stepsPerRevolution, 20, 19, 18, 17);
Stepper E3N2(stepsPerRevolution, 38, 39, 40, 41);

void setup() {

  E1N1.setSpeed(35);
  E2N1.setSpeed(35);
  E3N1.setSpeed(35);
  E1N2.setSpeed(35);
  E2N2.setSpeed(35);
  E3N2.setSpeed(35);
  E1N1.step(-635);  // runs the stepper backwards to 'zero'
  E2N1.step(-635);
  E3N1.step(-635);
  E1N2.step(-635);
  E2N2.step(-635);
  E3N2.step(-635);
  delay(500);
  // initialize the serial port:
  Serial.begin(9600);
}

void loop() {
  // step one revolution  in one direction:
  Serial.println("clockwise");
  E1N1.step(stepsPerRevolution);
  E2N1.step(stepsPerRevolution);
  E3N1.step(stepsPerRevolution);
  E1N2.step(stepsPerRevolution);
  E2N2.step(stepsPerRevolution);
  E3N2.step(stepsPerRevolution);
  delay(500);

  // step one revolution in the other direction:
  Serial.println("counterclockwise");
  E1N1.step(-stepsPerRevolution);
  E2N1.step(-stepsPerRevolution);
  E3N1.step(-stepsPerRevolution);
  E1N2.step(-stepsPerRevolution);
  E2N2.step(-stepsPerRevolution);
  E3N2.step(-stepsPerRevolution);
  delay(500);
}


If you're familiar with using a VID6606 board along with the TeensyStep library and can offer advice, I would certainly appreciate it. What is missing in my sketch?

Thanking you very much in advance.

Jay
www.youtube.com/EAL727Capt
 
Last edited:
My current sketch (not working.....yet)----
Did you try some of the library examples to check if the hardware is working? E.g. the HelloStepper.ino? Does it work as intended? Always good to start from some firm ground...

I did not find much reference material on the TeensyStep library (I'm probably not searching correctly)
Documentation is here: https://luni64.github.io/TeensyStep/

f you're familiar with using a VID6606 board along with the TeensyStep library and can offer advice, I would certainly appreciate it.
I'm not familiar with this board. But, as long as it accepts 3.3V step/dir signals it should be fine. Have a look at the max step rate it accepts. You are stepping with 50kHz which might be too high.

What is missing in my sketch?
On a first glance it should work. Why do you call setPosition in loop? This will set the internal step counter to a value which you normaly only do in some homing sequence. It shouldn't do any harm in this code but try to remove it anyway.
 
Did you try some of the library examples to check if the hardware is working? E.g. the HelloStepper.ino? Does it work as intended? Always good to start from some firm ground...

I had just started to when my neighborhood had a power failure—-and it is hot, hot, hot here in Las Vegas!!! I need my air-conditioning!!!

Documentation is here: https://luni64.github.io/TeensyStep/

Thank you. I had discovered that weblink about 45 minutes after my initial posting.

I'm not familiar with this board. But, as long as it accepts 3.3V step/dir signals it should be fine. Have a look at the max step rate it accepts. You are stepping with 50kHz which might be too high.

The VID6606 IC is specifically for the X27.168 steppers and it’s my understanding they work incredibly well. They are powered by 5V onboard using only STEP and DIRECTION coming from the Teensy (or Arduino). Each of these boards can operate a maximum of four (4) steppers.


On a first glance it should work. Why do you call setPosition in loop? This will set the internal step counter to a value which you normaly only do in some homing sequence. It shouldn't do any harm in this code but try to remove it anyway.

I was attempting to replicate the results I had gotten in my sketch…to first (on start-up) run each stepper CCW to ‘home’ or zero position. Then, read the values on each aircraft engine’s data ref from X-Plane and move the steppers to those positions. Being my first attempt using the library, I was surprised it compiled, although didn’t work in sim operation. No worries—it’ll happen. If I can get a single stepper to duplicate what X-Plane is showing, writing coding/sketches for the rest will be easy.
I have been experimenting with a few stepper libraries (e.g., SwitcX25.h, Stepper.h) and couldn’t get the coding/sketches to work. I probably confused myself along the way, cutting from here—pasting to there, etc.
I’m confident we’ll get it together.

Thank you so much for your kind reply.
 
You're welcome. Let me know if you need some support after you got the basic examples running.
 
After my power came back on (and the house cooled-down!!!), I tested the 'HELLO STEPPER' and couldn't get it to work with the VID6606 board....very disappointing.

So, in the interest of education here, on my Teensy 3.2, where do the stepper motors wires go? I get the pins 2 and 3 for STEP and DIRECTION but what actually powers the actual steppers (X27.168s in this case)?

Thanks again.

Jay
 
Could you give some more detail about "VID6606 board". I tried a quick google search and found at least 2 different products matching this description, plus a number of vendors selling the bare chip.

https://www.tindie.com/products/propwashsim/vid6606-sti6606-4x-stepper-driver-for-x27168/

https://www.poscope.com/product/vid6606-stepper-motor-driver-postepvid6606/

Clear info or a photo of exactly which hardware you have, and a link to its technical documentation, would really enable us to better help you.
 
Back
Top