proyecto 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 <= MAXPOS) 00022 return int(750+coord*1900/50);// u6 00023 return 750; 00024 00025 } 00026 00027 00028 00029 00030 00031 void mover_ser(uint8_t motor, uint8_t pos){ 00032 00033 int pulseX = coord2us(pos); 00034 00035 myServo1.pulsewidth_us(pulseX); 00036 00037 00038 } 00039 00040 void init_servo() 00041 { 00042 myServo1.period_ms(20); 00043 myServo2.period_ms(20); 00044 myServo3.period_ms(20); 00045 00046 00047 }
Generated on Fri Jul 15 2022 05:03:45 by
1.7.2
