Dependencies:   mbed Motordriver QEI

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers library.h Source File

library.h

00001 #include         "mbed.h"
00002 #include          "QEI.h"
00003 #include "ClockControl.h"
00004 
00005 //Number of pulses in one revolution
00006 #define  PULSE 6144  //12(encorder_plse) * 16(gear_head) * 32(wheel)
00007 #define LENGTH    4  //servo_number
00008 
00009 Serial        device( p28, p27 );   //serial_PC
00010 Serial         servo( p9, p10 );    //serial_servo
00011 QEI            r_enc(  p6,  p5, NC, PULSE, QEI :: X4_ENCODING );    //encorder(right_motor)
00012 QEI            l_enc( p18, p17, NC, PULSE, QEI :: X4_ENCODING );    //encorder(left_motor)
00013 PwmOut     right_pwm( p22 );    //PWM(right_motor)
00014 PwmOut      left_pwm( p21 );    //PWM(left_motor)
00015 DigitalOut   right_P( p7 );     //H bridge(right_motor)
00016 DigitalOut   right_N( p8 );     //H bridge(right_motor)
00017 DigitalOut    left_P( p15 );    //H bridge(left_motor)
00018 DigitalOut    left_N( p16 );    //H bridge(left_motor)
00019 DigitalOut    enable( p19 );    //Enable_pin(motor_driver)
00020 PwmOut          led1( p23 );    //LED for observation of the robot
00021 PwmOut          led2( p24 );    //LED for observation of the robot
00022 
00023 //motor.h
00024 void    qei( void );
00025 void   move_f( double, double );
00026 void   move_b( double, double );
00027 void   turn_r( double, double );
00028 void   turn_l( double, double );
00029 void   stop( void );
00030 
00031 //servo.h
00032 short ID_num[LENGTH] = { 0x01, 0x02, 0x03, 0x04 };
00033 short degree[LENGTH] = { 0, 1500, -1500, 0 };
00034 
00035 void control_servo( void );
00036 void       cal_deg( short, short *, short * );
00037 void          save( short );
00038 short      cal_sum( short *, int );
00039 void        id_set( void );