Alright everyone,I'm in need of some help.
My code is listed below the input frequency is pictured below as well. The stepper doesn't move like i expect (or at all). Did I miss and or code something wrong? I I am using a transistor H bridge to drive a bipolar stepper. I have verified functionality of the stepper and the stepper code used to eliminate hardware failure. Any suggestions?
/*
*/
#include <AccelStepper.h>
volatile int TachPosition;
int CurrentState;
int PreviousState;
int TachIn = 2;
int ignition = 4;
int CurrentIgnition;
int PreviousIgnition;
AccelStepper Tach(AccelStepper::FULL4WIRE, 6, 7, 8, 9);
void setup(){
attachInterrupt(digitalPinToInterrupt(TachIn), Interrupt, RISING);
Tach.setMaxSpeed(270);
Tach.setSpeed(250);
Tach.setAcceleration(1000);
}
void loop() {
//Check ignition
CurrentIgnition = digitalRead(ignition);
{
if(CurrentIgnition == HIGH && PreviousIgnition == LOW)
{
PreviousIgnition = HIGH;
Tach.runToNewPosition(-20);
Tach.setCurrentPosition(0);
Tach.runToNewPosition(480);
Tach.runToNewPosition(20);
}
else if (CurrentIgnition == LOW && PreviousIgnition == HIGH)
{
Tach.runToNewPosition(0);
PreviousIgnition = LOW;
}
}
//Tach Movement
Tach.runToNewPosition(TachPosition);
}
void Interrupt()
{ static int Pulse;
static int tempo;
static int freq;
++Pulse;
tempo = millis();
if(tempo%500==0)
{
freq = Pulse * 2;
TachPosition = (2/3 * freq);
Pulse=0;
}
}
