Control de velocidad y dirección de giro de un motor PAP con la tarjeta F407. Se incluyen las librerías con la clase Motor.

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Motor.cpp Source File

Motor.cpp

00001 #include "mbed.h"
00002 #include "Motor.h"
00003 
00004 
00005 MotorContinuo::MotorContinuo(PinName L1, PinName L2, PinName speedPin) : 
00006 _L1(L1), _L2(L2), _speedPin(speedPin)
00007 {
00008     _speedPin.period_ms(5);
00009     _speedPin.write(0);
00010 };
00011  
00012 
00013 void MotorContinuo::Forward()   { _L1=1;  _L2=0;}
00014 void MotorContinuo::Back()      { _L1=0;  _L2=1;}
00015 void MotorContinuo::Stop()      { _L1=0;  _L2=0;}
00016 void MotorContinuo::StopT()     { _L1=1;  _L2=1;}
00017 void MotorContinuo::SpeedDuty(int v) { _speedPin.write(float(v/100.0));}
00018 void SpinLength_ms(float t)    { t++;}// Duración del giro en ms
00019 void SpinLength(float t)       { t++;}
00020     
00021  /*   
00022 void scolor_TCS3200::SetMode(uint8_t mode) {
00023     switch (mode){
00024         case SCALE_100:  _s0= 1; _s1=1; break;
00025         case SCALE_20:   _s0=1 ; _s1=0; break;
00026         case SCALE_2:    _s0=0 ; _s1=1; break;
00027         case POWER_DOWN: _s0=0 ; _s1=0; break;
00028     } 
00029 };
00030  
00031  
00032 long  scolor_TCS3200::pulsewidth() {
00033     while(!_s_in);
00034     timer.start();
00035     while(_s_in);
00036     timer.stop();
00037     float pulsewidth_v = timer.read_us();
00038     timer.reset();
00039     return pulsewidth_v;
00040 };
00041 */          
00042