Alternative switching pattern for better bootstraping
This commit is contained in:
parent
cfc583a8cf
commit
afa987c506
|
@ -14,14 +14,16 @@ int main(void) {
|
|||
|
||||
|
||||
while(1) {
|
||||
//hbridge_set_l1();
|
||||
|
||||
for(uint8_t speed = 0; speed <= 250; speed++) {
|
||||
for(uint16_t i = 0; i < 250; i++) {
|
||||
for(uint8_t speed = 50; speed <= 255; speed++) {
|
||||
for(uint16_t i = 0; i < 1000; i++) {
|
||||
pwm_cycle_forwards(speed);
|
||||
}
|
||||
}
|
||||
|
||||
for(uint16_t i = 0; i < 10000; i++) {
|
||||
pwm_cycle_forwards(255);
|
||||
}
|
||||
|
||||
hbridge_unset_h2();
|
||||
hbridge_unset_h2();
|
||||
hbridge_set_l1();
|
||||
|
@ -30,12 +32,18 @@ int main(void) {
|
|||
hbridge_unset_l2();
|
||||
hbridge_unset_l2();
|
||||
|
||||
for(uint8_t speed = 0; speed <= 250; speed++) {
|
||||
for(uint16_t i = 0; i < 250; i++) {
|
||||
|
||||
|
||||
for(uint8_t speed = 50; speed <= 255; speed++) {
|
||||
for(uint16_t i = 0; i < 1000; i++) {
|
||||
pwm_cycle_backwards(speed);
|
||||
}
|
||||
}
|
||||
|
||||
for(uint16_t i = 0; i < 10000; i++) {
|
||||
pwm_cycle_forwards(255);
|
||||
}
|
||||
|
||||
hbridge_unset_h2();
|
||||
hbridge_unset_h2();
|
||||
hbridge_set_l1();
|
||||
|
|
|
@ -41,39 +41,62 @@ static inline void hbridge_unset_l2(void) {
|
|||
PORTB &= ~(1 << PB4);
|
||||
}
|
||||
|
||||
const double delay_time = 2.0;
|
||||
const double delay_time = 1;
|
||||
|
||||
static inline void pwm_cycle_backwards(uint8_t speed) {
|
||||
PIND |= (1 << PD1);
|
||||
|
||||
hbridge_unset_l2();
|
||||
hbridge_set_l1();
|
||||
for(uint8_t i = 0; i < 8; i++) {
|
||||
if((speed & (1 << i)) != 0) {
|
||||
hbridge_unset_h1();
|
||||
hbridge_set_h2();
|
||||
hbridge_set_l1();
|
||||
hbridge_unset_l2();
|
||||
}
|
||||
else {
|
||||
hbridge_unset_h1();
|
||||
hbridge_unset_h2();
|
||||
hbridge_unset_l1();
|
||||
hbridge_set_l2();
|
||||
}
|
||||
for(uint8_t j = 0; j < (1 << i); j++) {
|
||||
_delay_us(delay_time);
|
||||
}
|
||||
hbridge_unset_h2();
|
||||
}
|
||||
|
||||
hbridge_unset_h1();
|
||||
hbridge_unset_h2();
|
||||
hbridge_unset_l1();
|
||||
hbridge_unset_l2();
|
||||
}
|
||||
|
||||
|
||||
static inline void pwm_cycle_forwards(uint8_t speed) {
|
||||
PIND |= (1 << PD1);
|
||||
|
||||
hbridge_unset_l1();
|
||||
hbridge_set_l2();
|
||||
|
||||
for(uint8_t i = 0; i < 8; i++) {
|
||||
if((speed & (1 << i)) != 0) {
|
||||
hbridge_set_h1();
|
||||
hbridge_unset_h2();
|
||||
hbridge_unset_l1();
|
||||
hbridge_set_l2();
|
||||
}
|
||||
else {
|
||||
hbridge_unset_h1();
|
||||
hbridge_unset_h2();
|
||||
hbridge_set_l1();
|
||||
hbridge_unset_l2();
|
||||
}
|
||||
for(uint8_t j = 0; j < (1 << i); j++) {
|
||||
_delay_us(delay_time);
|
||||
}
|
||||
hbridge_unset_h1();
|
||||
}
|
||||
|
||||
hbridge_unset_h1();
|
||||
hbridge_unset_h2();
|
||||
hbridge_unset_l1();
|
||||
hbridge_unset_l2();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue