Run checks on real hardware and fixed booster

Added onboard-led as output
master
Railz 6 years ago
parent 6990bff184
commit 900874aeae

@ -20,7 +20,7 @@ uint16_t boost_frequency = 2000; // 2kHz frequency
uint16_t signalOutput_time = 200; // 200ms
uint8_t boost_highVoltage_nextHigh = 1;
uint16_t boost_highVoltage_nextTick = 0;
uint16_t boost_highVoltage_nextTick = 1;
uint8_t signalOutput_nextHigh = 1;
uint16_t signalOutput_nextTick = 0;
@ -42,6 +42,7 @@ int main()
DDRD |= (1 << PORTD4);
DDRD |= (1 << PORTD5);
DDRD |= (1 << PORTD6);
DDRB |= (1 << PORTB5); // Onboard-Led
// Interrupt for INT0 Pin-D2 High-voltage check
EICRA |= (0 << ISC01)|(1 << ISC00); // On at any edge [Code: 01]
@ -77,7 +78,7 @@ int main()
PORTD |= (0 << PORTD4);
boost_highVoltage_nextHigh = 1; // Next is high
}
// Calculate when next high/low should be set
boost_highVoltage_nextTick = (uint16_t)TCNT1 + F_CPU/timer1_prescaler * 1/(boost_frequency/2); // Half of time it should be high/low
if(boost_highVoltage_nextTick == 0) boost_highVoltage_nextTick++; // If its 0, it stops, we dont want that
@ -159,12 +160,16 @@ ISR(INT0_vect)
{
// Below ~400V, activate booster
boost_highVoltage_nextTick = 1; // Run as soon as possible
PORTB |= (1 << PORTB5); // Onboard-Led
}
else // Rising edge
{
// Reached ~400V, deactivate booster
boost_highVoltage_nextTick = 0;
PORTB |= (0 << PORTB5); // Onboard-Led
// reset state
PORTD |= (0 << PORTD4); // pin on low
boost_highVoltage_nextHigh = 1; // next is high

Loading…
Cancel
Save