CONTROL ARAÑA
Fork of 01-04EntregaPrimerCorte by
Embed:
(wiki syntax)
Show/hide line numbers
mover.cpp
00001 00002 #include "mover.h" 00003 #include "mbed.h" 00004 #include "math.h" 00005 00006 00007 PwmOut myServo1(PB_3); 00008 PwmOut myServo2(PB_4); 00009 PwmOut myServo3(PB_5); 00010 00011 00012 uint8_t ss_time=50; // tiempo de espera para moverse 1 mm en microsegundos 00013 00014 void put_sstime(uint8_t vtime){ 00015 ss_time=vtime; 00016 00017 } 00018 00019 int coord2us(float coord) 00020 { 00021 if(0 <= coord <= 180) 00022 return int(750+coord*1900/180);// u6 00023 return 750; 00024 00025 } 00026 00027 00028 00029 00030 00031 void mover_ser(uint8_t nmotor, uint8_t grados){ 00032 int pulseX = coord2us(grados); 00033 switch(nmotor){ 00034 case 0x01: 00035 myServo1.pulsewidth_us(pulseX); 00036 break; 00037 case 0x02: 00038 myServo2.pulsewidth_us(pulseX); 00039 break; 00040 case 0x03: 00041 myServo3.pulsewidth_us(pulseX); 00042 break;} 00043 } 00044 00045 00046 void init_servo() 00047 { 00048 myServo1.period_ms(20); 00049 myServo2.period_ms(20); 00050 myServo3.period_ms(20); 00051 00052 00053 }
Generated on Sun Jul 17 2022 01:59:23 by
1.7.2
