Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of 01-04_Primer_Avance by
Diff: mover.cpp
- Revision:
- 3:60722da62531
- Parent:
- 2:10956b8ceffb
- Child:
- 4:ba51736778e1
--- a/mover.cpp Thu Sep 06 18:05:07 2018 +0000
+++ b/mover.cpp Fri Sep 07 03:42:26 2018 +0000
@@ -4,14 +4,14 @@
#include "math.h"
-PwmOut Servo1(PA_11);
-PwmOut Servo2(PA_11);
-PwmOut Servo3(PA_11);
-PwmOut Servo4(PA_11);
-PwmOut Servo5(PA_11);
-PwmOut Servo6(PA_11);
-PwmOut Servo7(PA_11);
-PwmOut Servo8(PA_11);
+PwmOut Servo1(PA_1);
+PwmOut Servo2(PB_8);
+PwmOut Servo3(PB_14);
+PwmOut Servo4(PB_15);
+PwmOut Servo5(PA_8);
+PwmOut Servo6(PB_6);
+PwmOut Servo7(PA_9);
+PwmOut Servo8(PA_10);
uint8_t ss_time=50; // tiempo de espera para moverse 1 mm en microsegundos
@@ -24,9 +24,13 @@
int coord2us(float coord)
{
if(0 <= coord <= MAXPOS)
- return int(750+coord*1900/50);// u6
- return 750;
-
+ return int(500+coord*2000/180);// u6
+ return 500;
+/*
+Secuencia 0, 180, 135, 90, 45, 0.
+FF 01 01 00 FE FF 01 01 B4 FE FF 01 01 87 FE FF 01 01 5A FE FF 01 01 2D FE FF 01 01 00 FE
+Grados: 180-B4, 135-87, 90-5A, 45-2D, 0-00;
+*/
}
@@ -35,17 +39,15 @@
void mover_ser(uint8_t motor, uint8_t pos){
- //int pulseX = coord2us(pos);
- int pulseX = 900;
- int pulseY = 1900;
- // myServo1.pulsewidth_us(pulseX);
+ int pulseX = coord2us(pos);
+
switch ( motor ) {
case 0x01:
Servo1.pulsewidth_us(pulseX);
break;
case 0x02:
- Servo2.pulsewidth_us(pulseY);
+ Servo2.pulsewidth_us(pulseX);
break;
case 0x03:
Servo3.pulsewidth_us(pulseX);
