Hi
I am using ATtiny85 to issue step pulses for Stepper Driver (TB6560).
Pin 1 (digital pin 5) of ATtiny85 is configured as input, having an external 10k pull-up resistor. This pin is connected to the output of an IR sensing module based on LM358 op-amp, Tx IR LED and Rx LED.
The Stepper Driver is supplied with 15V and the remaining set-up has 5V.
The ref-voltage at (-)ve input of LM358 is set at 3.5 volts.
When nothing is sensed the voltage at Pin 1 of µC is 4.5 volts (HIGH).
When an object is sensed the voltage is 0.5 volts (LOW).
Here is the code:
// Stepper driven by ATtiny85
const int sensorPin = 5; // (pin 1) IR sensor to start Capping
const int stepPin = 0; // (pin 5) for Step
const int dirPin = 1; // (pin 6) for Direction
const int POT = 1; // (pin 7) analog pin 1
int tightSteps; // Steps required to tight cap
void setup()
{
pinMode(sensorPin, INPUT);
pinMode(dirPin, OUTPUT);
digitalWrite(dirPin, HIGH);
}
void loop()
{
if (digitalRead(sensorPin) == LOW) // Tube detected
{
delay(500);
if (digitalRead(sensorPin) == LOW) // If tube still there
{
int potVal = analogRead(POT); // Read value at POT
tightSteps = map(potVal,0,1023,10,500); // Steps required to tight cap
for (int x = 0; x < tightSteps; x++)
{
digitalWrite(stepPin, HIGH);
delayMicroseconds(800);
digitalWrite(stepPin, LOW);
delayMicroseconds(800);
}
}
}
}
The problem is that the stepper is not running. I replaced the Stepper driver with an LED + resistor to see if there are pulses. but no pulses when object is detected. All connections are ok.
Can someone point me where am I wrong.