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 1:8452eddc6a3e, committed 2019-03-28
- Comitter:
- stevencastro
- Date:
- Thu Mar 28 23:53:29 2019 +0000
- Parent:
- 0:5e6b543c1179
- Commit message:
- 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 22:49:23 2019 +0000
+++ b/main.cpp Thu Mar 28 23:53:29 2019 +0000
@@ -27,18 +27,18 @@
Serial command(USBTX, USBRX);
-DigitalOut stepper_step(PB_4);
-DigitalOut steppeer_dir(PB_5);
+DigitalOut stepper_step(D12);
+DigitalOut steppeer_dir(D13);
/*INGRESE LA CONFIGURACION DE LOS MOTORES*/
-#define INITCMD 0xFF
-#define VELOCITY 5 ///en micro segundos
+#define INITCMD 0xFF // Inicialisacion del comando
+#define VELOCITY 5000 ///en micro segundos
// definición de las variables globales
uint8_t sentido_motor; // variable almacena el sentido de giro de motor en leer_datos()
-uint8_t N_pasos; // varable almacena el numero de pasos que se mueve el motor en leer_datos()
+uint8_t N_pasos; // varable almacena el numero de pasos que se mueve el motor en leer_datos(
// definición de las funciones
@@ -56,6 +56,7 @@
//command.printf("inicio de programa");
while(1){
leer_datos();
+
mover_steper_nema(sentido_motor, N_pasos);
}
}
@@ -69,6 +70,7 @@
void leer_datos(){
+
while(command.getc()!= INITCMD);
sentido_motor=command.getc();
N_pasos=command.getc();
@@ -78,25 +80,25 @@
void mover_steper_nema(uint8_t sentido, uint8_t num_pasos){
+ int i = 0;
- uint32_t dpulse=0;
-
/* complementar el código necesario */
-
- if (sentido == 1) {
+ if (sentido == 1) { // configuracion despues de la lectura del comando
steppeer_dir = 0;
+
} else if (sentido == 0) {
steppeer_dir = 1;
+
}
+ wait_us(1);
/*esperar 650 nsegundo*/
-
/* complementar el código necesario */
+ for (i=1 ; i<=num_pasos; i++){
+ printf ("%x",i );
stepper_step=1;
wait_us(VELOCITY);
stepper_step=0;
wait_us(VELOCITY);
+ }}
-}
-
-