Part 2 nýjir kóðar, fyrir STOP og Fault kerfi

This commit is contained in:
2026-09-30 11:52:06 +00:00
parent 7ca9c51268
commit d96da75bdf
8 changed files with 154 additions and 4 deletions
+13 -1
View File
@@ -12,10 +12,16 @@ void MotorDriver::begin()
{
// Arduino D3 = PD3 = AIN1
// Arduino D11 = PB3 = AIN2
// Arduino D4 = PD4 = FLT
DDRD |= (1 << DDD3);
DDRB |= (1 << DDB3);
DDRD &= ~(1 << DDD4);
PORTD |= (1 << PORTD4); // Enable pull-up resistor on D4 for part 2
// Timer2 Fast PWM
TCCR2A = 0;
TCCR2B = 0;
@@ -107,4 +113,10 @@ void MotorDriver::set(double pwm)
{
stop();
}
}
}
bool MotorDriver::fault_active()
{
return !(PIND & (1 << PIND4));
}