Hello, all. Long time lurker, first time poster.
Am seeking help with the following:
I'm building a Boeing 727-200 home cockpit using OEM indicators/gauges/instruments and currently am working on the engine instrument indicators.
I'm using X27.168 automotive-type stepper motors inside these 2" instruments.
I have a sketch written and functioning but want to have the steppers (all 15 of them, eventually) go to a 'home' position of ZERO at start-up. I've tried the moveTo(0) position and runToPosition(0) as well as moveTo(-500) and runToPosition(-500) calls in the VOID SETUP (as I only want to do this once) to no avail.
The X27.168 stepper has an internal stop which will match my zero position on the indicator. Once SETUP takes the stepper to its ZERO (or home) position, it will then go to the LOOP section and update as the values in the simulator (X-Plane 11, in this case) change.
My sketch, thus far, is as follows:
[code]
/*
E1N1 TEST
Teensy 3.2, AccelStepper, EasyDriver and X27.168
1/8 microstepping (default setting)
*/
#include <AccelStepper.h>
AccelStepper E1N1(1, 14, 15); // 1=Library function, 14=Step, 15=Direction
FlightSimFloat e1n1;
float E1N1_pos; // Eng 1 N1
const long STEPS_PER_REVOLUTION = 13500;
const float STEPS_PER_DEGREE = ((float) STEPS_PER_REVOLUTION) / 315.0;
void setup() {
Serial.begin(9600);
E1N1.setMaxSpeed(900);
E1N1.setAcceleration(900);
e1n1 = XPlaneRef("FJS/727/Eng/N11Needle");
}
void loop() {
FlightSim.update();
E1N1_pos = e1n1 * STEPS_PER_DEGREE;
E1N1.moveTo(E1N1_pos);
E1N1.run();
}
[/code]
For this sketch, I'm trying to get the X27.168 stepper to move in concert with what the flight sim's indicator is showing....and it does, for the most part, but I want to get the indicator needle to cycle through to ZERO and then go to whatever value is displayed on the flight sim. This particular sketch is for the Engine 1 N1 (front fan) indicator and is only in a testing phase. Each engine has an EPR, (Exhaust Pressure Ratio), N1, EGT (Exhaust Gas Temp), N2 and Fuel Flow indicator....for three (3) engines.
Is there a way to always get the stepper to 'go home' (ZERO step position) and then go to the actual value?
Any help is certainly appreciated.
Thank you very much.
Jay
Las Vegas