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.
Revision 6:24f37d9e0c57, committed 2019-02-25
- Comitter:
- fabeltranm
- Date:
- Mon Feb 25 13:38:05 2019 +0000
- Parent:
- 5:115f329c72ab
- Commit message:
- solucin con un motor
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Feb 25 12:31:53 2019 +0000
+++ b/main.cpp Mon Feb 25 13:38:05 2019 +0000
@@ -8,7 +8,7 @@
| INITCMD | N_motor | N_grados |
| 0xff | 0x01- 0x04 | 0x00 - 0xb4 |
-para enviar los comandos usar el programa Coolterm
+para enviar los comandos usar el programa Coolterm http://freeware.the-meiers.org/
# para el servo motor se debe modificar el ciclo util del PWM SEGUN:
# ________ ________
@@ -26,7 +26,7 @@
Serial command(USBTX, USBRX);
PwmOut myservo1(PB_4);
-/*INGRESE L A CONFIGURACION DE LOS MOTORES*/
+/*INGRESE LA CONFIGURACION DE LOS MOTORES*/
#define INITCMD 0xFF
#define DEGREES_MAX 180
@@ -42,7 +42,7 @@
void setup_servo();
void mover_servo(uint8_t motor, uint8_t gradss);
-uint32_t degrees2usec(uint8_t grados){
+uint32_t degrees2usec(uint8_t grados);
void leer_datos();
@@ -67,7 +67,7 @@
void setup_servo(){
myservo1.period_ms(20);
- myservo1.pulsewidth_us(1000);
+ myservo1.pulsewidth_us(2000);
}
void leer_datos(){
@@ -78,7 +78,16 @@
}
+uint32_t degrees2usec(uint8_t grados){
+// Retorna el valor en microsegundos, donde
+// y − y1 = m(x − x1 )
+// y= b + mx
+ if(grados <= DEGREES_MAX)
+ return int(750+grados*1900/180);// u6
+ return 750;
+
+}
void mover_servo(uint8_t motor, uint8_t grados){
@@ -88,17 +97,10 @@
tip: deben pasar grados a microsegundo */
-// dpulse=degrees2usec(grados);
-// myservo1.pulsewidth_us(dpulse);
+ dpulse=degrees2usec(grados);
+ if (motor==1)
+ myservo1.pulsewidth_us(dpulse);
}
-uint32_t degrees2usec(uint8_t grados){
-// Retorno el valor en usegundos, donde
-// y − y1 = m(x − x1 )
- if(grados <= DEGREES_MAX)
- return int(750+grados*1900/180);// u6
- return 750;
-
-}
\ No newline at end of file