dspic33_pwm_test.X/axis.c
/**
 * \brief   executes axis motion<forward, reverse, stop, etc...> commands
 *
 * \param 	_axis_command dir - motion command to be executed
 *
 * \returns  
 */
\brief   executes axis motion commands
\param       _axis_command dir - motion command to be executed

\returns
\ brief executes axis motion commands \ param _axis_command dir - motion command to be executed \ returns
void axis_motion_handler( _axis_command dir )
{   
    if( dir == kAxisIdle )
        return;
    switch( dir )
    {
        case kAxisForward:
            set_pwm_duty_cycle(3, axis.velocity);
            set_pwm_duty_cycle(1, axis.velocity);
P1DC1 = 0x0137;
P1DC3 = 0x0137;
            break;
        case kAxisReverse:
            set_pwm_duty_cycle(1, ( 1 - axis.velocity ) );
            set_pwm_duty_cycle(3, ( 1 - axis.velocity ) );
            __delay_ms(10);
P1DC1 = 0x0137;
P1DC3 = 0x0137;
            break;
        case kAxisStop:
            P1TCONbits.PTEN = 0;
            break;
        default:
            EnableUSBUARTTransmit;
            printf( "\n\rinvalid axis direction" );
            EnableUSBUARTReceive;
            return;
            break;
    }
     //start pwm
}
void axis_motion_handler ( _axis_command dir ) { if ( dir == kAxisIdle ) return ; switch ( dir ) { case kAxisForward : set_pwm_duty_cycle ( 3 , axis . velocity ) ; set_pwm_duty_cycle ( 1 , axis . velocity ) ; break ; case kAxisReverse : set_pwm_duty_cycle ( 1 , ( 1 - axis . velocity ) ) ; set_pwm_duty_cycle ( 3 , ( 1 - axis . velocity ) ) ; __delay_ms ( 10 ) ; break ; case kAxisStop : P1TCONbits . PTEN = 0 ; break ; default : EnableUSBUARTTransmit ; printf ( " \n \r " ) ; EnableUSBUARTReceive ; return ; break ; } }
\brief   executes axis motion<forward, reverse, stop, etc...> commands
 \param       _axis_command dir - motion command to be executed
\ brief executes axis motion<forward reverse stop etc ... > commands \ param _axis_command dir - motion command to be executed
//PWM1CON1bits.PWM_A4954_IN2 = 0; //PWM1CON1bits.PWM_A4954_IN1 = 1; //P1TCONbits.PTEN = 1; //set_pwm_duty_cycle(2, axis.velocity); //            __delay_ms(10); //             //            P1DC1 = 0x0137; //            P1DC3 = 0x0137; //set_pwm_duty_cycle(1, 0.50 ); //set_pwm_duty_cycle(2, axis.velocity); //set_pwm_duty_cycle(3, 0.50 ); //P1TCONbits.PTEN = 0; //PWM1CON1bits.PWM_A4954_IN2 = 1; //PWM1CON1bits.PWM_A4954_IN4 = 0; //LATBbits.LATB10  = 1;       //ENABLE1_IN1     	Output  pin10    PWM1H2 //LATBbits.LATB11  = 1;       //ENABLE2_IN3		Output  pin14    PWM1H1 //PWM1CON1bits.PWM_A4954_IN1 = 0; //PWM1CON1bits.PWM_A4954_IN2 = 1; //PWM1CON1bits.PWM_A4954_IN4 = 1; //P1TCONbits.PTEN = 1; //set_pwm_duty_cycle(2, axis.velocity); //  //            P1DC1 = 0x0137; //            P1DC3 = 0x0137; //set_pwm_duty_cycle(1, 0.50); //set_pwm_duty_cycle(2, axis.velocity); //set_pwm_duty_cycle(3, 0.50 ); //P1TCONbits.PTEN = 0; //PWM1CON1bits.PWM_A4954_IN1 = 1; //LATBbits.LATB12  = 1;       //ENABLE1_IN1     	Output  pin10    PWM1H2 //LATBbits.LATB14  = 1;       //ENABLE2_IN3		Output  pin14    PWM1H1 //PWM1CON1bits.PWM_A4954_IN1 = 1; //PWM1CON1bits.PWM_A4954_IN3 = 0; //PWM1CON1bits.PWM_A4954_IN2 = 1; //PWM1CON1bits.PWM_A4954_IN4 = 0; //axis_direction = kAxisIdle; //P1TCONbits.PTEN = 1; //start pwm