NagaokaRoboticsClub_mbedTeam / ikarashiMDC

Dependents:   quadOmni_yanagi NHK2017_octopus ikarashiMDCmaster NHK2017_octopus2 ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ikarashiMDC.h Source File

ikarashiMDC.h

Go to the documentation of this file.
00001 #ifndef IKARASHIMDC_H
00002 #define IKARASHIMDC_H
00003 
00004 #include "mbed.h"
00005 #include "algorithm"
00006 
00007 #define LAP 0
00008 #define SM 1
00009 /**
00010  * @file   ikarashiMDC.h
00011  * @Author Wataru Nakata
00012  * @date   August, 2017
00013  * @brief  ikarashi MDC class header file.
00014  *
00015  * MDC control libraly. creates object for each motors.
00016  */
00017   
00018 /** Ikarashi MDC class
00019 *   MDC libraly
00020 *Example :
00021 *@code
00022 #include "mbed.h"
00023 #include "ikarashiMDC.h"
00024 Serial serial(PC_10,PC_11);
00025 DigitalOut serialcontrol(D2);
00026 *
00027 ikarashiMDC ikarashi[]{
00028 *    ikarashiMDC(&serialcontrol,2,2,SM,&serial),
00029 *    ikarashiMDC(&serialcontrol,2,3,LAP,&serial),
00030 };
00031 PwmOut pwm(LED1);
00032 *
00033 int main() {
00034 *    serial.baud(38400);
00035 *    float i = -1;
00036 *    while(1) {
00037 *        ikarashi[0].setSpeed(i);
00038 *        ikarashi[1].setSpeed(i);
00039 *        i += 0.01;
00040 *        pwm = fabs(i);
00041 *        wait_ms(20);
00042 *        if(i >= 1) i = -1;
00043 *    }
00044 }
00045 *@endcode    
00046 **/
00047 class ikarashiMDC
00048 {        
00049 public:
00050     /** Create ikarashiMDC inctance
00051     * @param address of cs pin for rs485
00052     * @param addr for MDC
00053     * @param ch for motor
00054     * @param mdc mode (LAP or SM)
00055     * @param  address of serial object
00056     **/
00057     ikarashiMDC(DigitalOut* serialcontrol,uint8_t taddr,uint8_t tmotorNum,bool tmode,Serial *tserial);
00058     
00059     /** drive motor
00060     * @param speed of motor -1 to 1
00061     **/
00062     int setSpeed(const double& speed);
00063     bool braking;
00064 
00065 protected:   
00066     uint8_t addr;
00067     uint8_t motorNum;
00068     bool mode;
00069     Serial* serial;
00070     DigitalOut *serialControl;
00071     
00072 };
00073 void estop(Serial *serial);
00074     
00075 #endif