Skip to content

Commit

Permalink
motors
Browse files Browse the repository at this point in the history
  • Loading branch information
97hackbrian committed Nov 21, 2023
1 parent 1d773ab commit 07bf4af
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 37 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -392,46 +392,39 @@ void timer3A_handler(void)
*/
if(vel[1]<0){
GPIOPinWrite(GPIO_PORTH_BASE, 0x02, 0x02);


if (flagmainMotor1==1){
if(vel[1]<0){
GPIOPinWrite(GPIO_PORTH_BASE, 0x02, 0x02);

PWMPulseWidthSet(PWM0_BASE,PWM_OUT_1,interpolar(vel[1]*-1,0,100,10000,1));
PWMPulseWidthSet(PWM0_BASE,PWM_OUT_2,0);
}
else{
GPIOPinWrite(GPIO_PORTH_BASE, 0x02, 0x02);
PWMPulseWidthSet(PWM0_BASE,PWM_OUT_1,0);
PWMPulseWidthSet(PWM0_BASE,PWM_OUT_2,interpolar(vel[1],0,100,10000,1));
}
PWMPulseWidthSet(PWM0_BASE,PWM_OUT_1,interpolar(vel[1]*-1,0,100,10000,1));
PWMPulseWidthSet(PWM0_BASE,PWM_OUT_2,0);
}
else{
GPIOPinWrite(GPIO_PORTH_BASE, 0x02, 0x02);
PWMPulseWidthSet(PWM0_BASE,PWM_OUT_1,0);
PWMPulseWidthSet(PWM0_BASE,PWM_OUT_2,interpolar(vel[1],0,100,10000,1));
}


if(vel[0]<0){
GPIOPinWrite(GPIO_PORTH_BASE, 0x01, 0x01);
PWMPulseWidthSet(PWM0_BASE,PWM_OUT_3,interpolar(vel[0]*-1,0,100,10000,1));
PWMPulseWidthSet(PWM0_BASE,PWM_OUT_4,0);
}
else{
GPIOPinWrite(GPIO_PORTH_BASE, 0x01, 0x01);
PWMPulseWidthSet(PWM0_BASE,PWM_OUT_3,0);
PWMPulseWidthSet(PWM0_BASE,PWM_OUT_4,interpolar(vel[0],0,100,10000,1));
}
if(vel[0]<0){
GPIOPinWrite(GPIO_PORTH_BASE, 0x01, 0x01);
PWMPulseWidthSet(PWM0_BASE,PWM_OUT_3,interpolar(vel[0]*-1,0,100,10000,1));
PWMPulseWidthSet(PWM0_BASE,PWM_OUT_4,0);
}
else{
GPIOPinWrite(GPIO_PORTH_BASE, 0x01, 0x01);
PWMPulseWidthSet(PWM0_BASE,PWM_OUT_3,0);
PWMPulseWidthSet(PWM0_BASE,PWM_OUT_4,interpolar(vel[0],0,100,10000,1));
}


if(vel[0]==0){
GPIOPinWrite(GPIO_PORTH_BASE, 0x01, 0x00);
PWMPulseWidthSet(PWM0_BASE,PWM_OUT_3,0);
PWMPulseWidthSet(PWM0_BASE,PWM_OUT_4,0);
}
else if(vel[1]==0){
GPIOPinWrite(GPIO_PORTH_BASE, 0x02, 0x00);
PWMPulseWidthSet(PWM0_BASE,PWM_OUT_1,0);
PWMPulseWidthSet(PWM0_BASE,PWM_OUT_2,0);
}
}



if(vel[0]==0){
GPIOPinWrite(GPIO_PORTH_BASE, 0x01, 0x00);
PWMPulseWidthSet(PWM0_BASE,PWM_OUT_3,0);
PWMPulseWidthSet(PWM0_BASE,PWM_OUT_4,0);
}
else if(vel[1]==0){
GPIOPinWrite(GPIO_PORTH_BASE, 0x02, 0x00);
PWMPulseWidthSet(PWM0_BASE,PWM_OUT_1,0);
PWMPulseWidthSet(PWM0_BASE,PWM_OUT_2,0);
}
}

0 comments on commit 07bf4af

Please sign in to comment.