Programátor jsem mírně pokročilý a elektronik začatečník.
https://www.youtube.com/watch?v=9ymhIb9-6B8
zapojení
https://aws1.discourse-cdn.com/arduino/ ... 24x688.png
driver je IR2112
https://www.infineon.com/dgdl/Infineon- ... c81cb71685
Jaké byste dali bootstrapovy kondiky? od par hz do 32Khz
Nemam tam D2 a D3 diodu měla by tam být?
Co říkáte na ten kod co byste řešily jinak?
PWM se dá řešit i nějak jinak než analogwrite?
je to styl něco někde zkopíruju a pak upravím =)
Kód: Vybrat vše
int aL = 6;//faze A LOW mosfet
int aH = 9;//faze A HIGH mosfet
int bL = 7;
int bH = 10;
int cL = 8;
int cH = 11;
int t;//pauza
int pw;//pwm
unsigned long a=0;
float ot=0;//otacky
byte bin2;//hall sondy
byte bin;
void setup() {
Serial.begin(9600);
DDRD = 0b11011100; //pin 0-7
DDRB = 0b00101111; //pin 8-13
// Set PWM for pins 9,10 to 32 kHz
//First clear all three prescaler bits:
int prescalerVal = 0x07; //create a variable called prescalerVal and set it equal to the binary number "00000111" number "00000111" number "00000111"
TCCR1B &= ~prescalerVal; //AND the value in TCCR0B with binary number "11111000"
//Now set the appropriate prescaler bits:
int prescalerVal2 = 1; //set prescalerVal equal to binary number "00000001"
TCCR1B |= prescalerVal2; //OR the value in TCCR0B with binary number "00000001"
// Set PWM for pins 3,11 to 32 kHz (Only pin 11 is used in this program)
//First clear all three prescaler bits:
TCCR2B &= ~prescalerVal; //AND the value in TCCR0B with binary number "11111000"
//Now set the appropriate prescaler bits:
TCCR2B |= prescalerVal2; //OR the value in TCCR0B with binary number "00000001"//First clear all three prescaler bits:
pinMode(A0, INPUT);
PORTD = 0b00011100;
}
void loop() {
pw = map (analogRead(A0), 0, 1024, 64, 255);
t=1500; //muze byt i 0 a jede ale spotřeba na prazdno je 3x taková asi se mosfet nestačí vypnout
bin2=bin;
bin = digitalRead(4) + (2*digitalRead(3)) + (4*digitalRead(2));
/* ukazatel rychlosti
if(a+999 <= millis()){
a=millis();
Serial.println(ot/14*0.625*3.6);
ot=0;
}
*/
if (pw > 70 & bin!=bin2) {
analogWrite(9,0);
analogWrite(10,0);
analogWrite(11,0);
PORTB = 0b00000000;
PORTD = 0b00011100;
delayMicroseconds(t);
switch (bin){
case 4:
ot++;
analogWrite(9,pw);
PORTD = 0b10011100;
break;
case 5:
PORTB = 0b00000001;
analogWrite(9,pw);
break;
case 1:
PORTB = 0b00000001;
analogWrite(10,pw);
break;
case 3:
analogWrite(10,pw);
PORTD = 0b01011100;
break;
case 2:
analogWrite(11,pw);
PORTD = 0b01011100;
break;
case 6:
analogWrite(11,pw);
PORTD = 0b10011100;
break;
}
}
else if(pw < 69) {
PORTB = 0b00000000;
PORTD = 0b00011100;
analogWrite(9,0);
analogWrite(10,0);
analogWrite(11,0);
}
}