ll

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers OutputToMotor.h Source File

OutputToMotor.h

00001 PwmOut LeftWheelPWM(D7);
00002 PwmOut LeftWheelPWMn(D11);
00003 PwmOut RightWheelPWM(D8);
00004 PwmOut RightWheelPWMn(A3);
00005 
00006 PwmOut FrontHandPWM(PB_10);
00007 
00008 float LeftWheelPower, RightWheelPower;
00009 
00010 void Catch_Release();
00011 
00012 void OutputInit()
00013 {
00014     LeftWheelPWM.period_us(50);
00015     //LeftWheelPWM.pulsewidth_ms(1); 
00016     LeftWheelPWM.write(0.5);//duty cycle 0.5 = 50%
00017     TIM1->CCER |= 0x4;
00018     
00019     ///
00020     RightWheelPWM.period_us(50);
00021     RightWheelPWM.write(0.5);
00022     TIM1->CCER |= 0x40;
00023     //
00024     FrontHandPWM.period_ms(20);
00025     Catch_Release();
00026     //FrontHandPWM.write(0.5);
00027     
00028     ///////////////////////////////////////////
00029     LeftWheelPower = 0;
00030     RightWheelPower = 0;
00031     
00032 }
00033 
00034 void OutputLeftWheel(float Power)
00035 {
00036     Power *= -1;
00037     LeftWheelPWM.write(0.5 + Power);
00038     TIM1->CCER |= 0x4;
00039 }
00040 void OutputRightWheel(float Power)
00041 {
00042     
00043     RightWheelPWM.write(0.5 + Power);
00044     TIM1->CCER |= 0x40;
00045 }
00046 void Catch_Hold()
00047 {
00048     FrontHandPWM.write(0.105);
00049 }
00050 void Catch_Release()
00051 {
00052     FrontHandPWM.write(0.06);
00053     //FrontHandPWM.write(0.105);
00054 }
00055