hey guys pls i need help with this. this H bridge does not work correctly with chi ATTINY85. When i move over attiny and connect arduino pins with pins on pcb (to make arduino behave like attiny) everything works fine, regulation is continous and polarity change works well too. but with attiny chip there are current jumps while regulating pwm.Also led (not drawned on scheme, but its connected as output from pin 2 through resistor to gnd) is lightly blinking while regulating but this current jumps are only between 0-30% pwm cycle approximately. and this behaviour is only with inductive load. and ONLY with attiny chip. Program down there is for arduino connected to pcb, program for attiny is equal with only i/o pins are swapped for proper functionality .
int butt = 4; int led = 7; int pwmA = 11; int pwmB = 10;
int stav = 0; int predstav = 0; int citac = 0;
void setup() {
pinMode(led,OUTPUT);
pinMode(butt,INPUT);
pinMode(pwmA,OUTPUT);
pinMode(pwmB,OUTPUT);
}
void loop() {
int pot = analogRead(A0);
int reg = map(pot,0,1023,0,255);
stav = digitalRead(butt);
if(stav != predstav)
{
if(stav == HIGH){
citac ++;delay(500);}}
delay(100);
predstav = stav;
if(citac % 2 ==0)
{analogWrite(pwmA,reg);
digitalWrite(pwmB,LOW);
digitalWrite(led,HIGH);
}
else{analogWrite(pwmB,reg);
digitalWrite(pwmA,LOW);
digitalWrite(led,LOW);
}
}
-- Spojený príspevok 13 Feb 2018, 18:48 --