TeensyStep library assistance requested #141
EAL727Capt
started this conversation in
General
Replies: 2 comments 1 reply
-
What is Stepper.h and why are you using it? |
Beta Was this translation helpful? Give feedback.
1 reply
-
I answered in the Teensy forum... |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello, all. Longtime lurker, first time poster.
I posted the following in the PJRC.COM forum as well…
(Like a good fisherman…just trying to get as many ‘lines’ in the water as possible)
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)----
/*==========================================================================
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.
/*
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
(My channel which highlights some of my work)
Beta Was this translation helpful? Give feedback.
All reactions