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 2:72952132894a, committed 2021-02-20
- Comitter:
- elab
- Date:
- Sat Feb 20 09:04:41 2021 +0000
- Parent:
- 1:77096ac47e7a
- Commit message:
- Version 1 of the smart marbles factory
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/012921.txt Sat Feb 20 09:04:41 2021 +0000
@@ -0,0 +1,185 @@
+#include "mbed.h"
+#include "stdio.h"
+
+//DigitalOut led(LED1);
+
+Serial pc(USBTX, USBRX);
+DigitalIn my_button(USER_BUTTON); // Use the user button to switch from dc motor to servo motor and vice versa
+DigitalIn end_stop(D5); // relais fin de course
+//
+//PwmOut l1_dc_motor_en(D3);
+PwmOut l1_dc_motor_cw(D10);
+PwmOut l1_dc_motor_ccw(D11);
+//PwmOut l1_servo_en(D5);
+//DigitalOut l1_servo_cw(D7);
+//DigitalOut l1_servo_ccw(D8);
+DigitalOut l1_servo_cw(A0);
+DigitalOut l1_servo_ccw(A1);
+
+PwmOut l2_dc_motor_en(D6);
+DigitalOut l2_dc_motor_cw(D12);
+DigitalOut l2_dc_motor_ccw(D13);
+//PwmOut l2_servo_en(D9);
+DigitalOut l2_servo_cw(D14);
+DigitalOut l2_servo_ccw(D15);
+
+void run_l1_dc_motor_cw(void){
+ l1_dc_motor_cw.period_ms(20);
+ l1_dc_motor_cw.pulsewidth_us(10000);
+}
+void run_l1_dc_motor_ccw(void){
+ l1_dc_motor_ccw.period_ms(20); // shoul be 20 ms (490 Hz) and 10 ms for the servo (980 Hz)
+ l1_dc_motor_ccw.pulsewidth_us(20000);
+}
+void run_l2_dc_motor_cw(void){
+ l2_dc_motor_en.period_ms(20); // shoul be 20 ms (490 Hz) and 10 ms for the servo (980 Hz)
+ l2_dc_motor_en.pulsewidth_us(50000);
+ l2_dc_motor_cw=0;
+ l2_dc_motor_ccw=1;
+}
+void run_l2_dc_motor_ccw(void){
+ l2_dc_motor_en.period_ms(20); // shoul be 20 ms (490 Hz) and 10 ms for the servo (980 Hz)
+ l2_dc_motor_en.pulsewidth_us(50000);
+ l2_dc_motor_cw=1;
+ l2_dc_motor_ccw=0;
+}
+
+
+void stop_dc_motor(void){
+ l1_dc_motor_cw.pulsewidth_us(0);
+ l1_dc_motor_ccw.pulsewidth_us(0);
+ l2_dc_motor_cw=0;
+ l2_dc_motor_ccw=0;
+
+}
+
+void run_l1_servo_cw(void){
+ l1_servo_cw=1;
+ l1_servo_ccw=0;
+}
+void run_l1_servo_ccw(void){
+ l1_servo_cw=0;
+ l1_servo_ccw=1;
+}
+
+void run_l2_servo_cw(void){
+ l2_servo_cw=1;
+ l2_servo_ccw=0;
+}
+void run_l2_servo_ccw(void){
+ l2_servo_cw=0;
+ l2_servo_ccw=1;
+}
+
+
+void stop_servo(void){
+ l1_servo_cw=0;
+ l1_servo_ccw=0;
+ l2_servo_cw=0;
+ l2_servo_ccw=0;
+}
+
+
+void test_limite(void){
+ end_stop.mode(PullDown);
+ while(1){
+ printf("lim=%d\n", end_stop.read());
+
+ if(end_stop.read()==1){
+ stop_dc_motor();
+// led=0;
+ printf("stop_dc_motor\n");
+ }
+ else{
+ run_l1_dc_motor_ccw();
+ printf("motor runs\n");
+// led=1;
+ }
+ }
+
+}
+
+int main()
+{
+ printf("Hello World !\n");
+ unsigned char cmd=0;
+ while (true) {
+ scanf("%c", &cmd);
+ if(cmd == '1')
+ {
+ cmd = 0;
+ stop_dc_motor();
+ printf("stop_dc_motor\r\n");
+ }
+ if(cmd == '2')
+ {
+ cmd = 0;
+ run_l1_dc_motor_cw();
+ printf("run_l1_dc_motor_cw\r\n");
+ }
+ if(cmd == '3')
+ {
+ cmd = 0;
+ run_l1_dc_motor_ccw();
+ printf("run_l1_dc_motor_ccw\r\n");
+ }
+ if(cmd == '4')
+ {
+ cmd = 0;
+ run_l1_servo_cw();
+ wait(1);
+ stop_servo();
+ printf("run_l1_servo_cw\r\n");
+ }
+ if(cmd == '5')
+ {
+ cmd = 0;
+ run_l1_servo_ccw();
+ wait(1);
+ stop_servo();
+ printf("run_l1_servo_ccw\r\n");
+ }
+ if(cmd == '6')
+ {
+ cmd = 0;
+ run_l2_dc_motor_cw();
+ printf("run_l2_dc_motor_cw\r\n");
+ }
+ if(cmd == '7')
+ {
+ cmd = 0;
+ run_l2_dc_motor_ccw();
+ printf("run_l2_dc_motor_ccw\r\n");
+ }
+ if(cmd == '8')
+ {
+ cmd = 0;
+ run_l2_servo_cw();
+ wait(1);
+ stop_servo();
+
+// l2_servo_cw=0;
+// l2_servo_ccw=0;
+ printf("run_l2_servo_cw\r\n");
+ }
+
+ if(cmd == '9')
+ {
+ cmd = 0;
+ run_l2_servo_ccw();
+ wait(1);
+ stop_servo();
+// l2_servo_cw=0;
+// l2_servo_ccw=0;
+
+ printf("run_l2_servo_ccw\r\n");
+ }
+
+
+ if(cmd == 'h')
+ {
+ cmd=0;
+ printf("1=stop_dc_motor; 2=run_l1_dc_motor_cw; 3=run_l1_dc_motor_ccw; 4=run_l1_servo_cw; 5=run_l1_servo_ccw, 6=run_l1_dc_motor_cw; 7=run_l1_dc_motor_ccw\n");
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/auto_working_code.txt Sat Feb 20 09:04:41 2021 +0000
@@ -0,0 +1,134 @@
+#include "mbed.h"
+#include "stdio.h"
+
+//DigitalOut led(LED1);
+
+Serial pc(USBTX, USBRX);
+DigitalIn my_button(USER_BUTTON); // Use the user button to switch from dc motor to servo motor and vice versa
+DigitalIn end_stop(A5); // relais fin de course
+
+PwmOut l1_dc_motor_cw(D2);
+PwmOut l1_dc_motor_ccw(D3);
+DigitalOut l1_servo_cw(D4);
+DigitalOut l1_servo_ccw(D5);
+PwmOut l2_dc_motor_cw(D6);
+PwmOut l2_dc_motor_ccw(D7);
+DigitalOut l2_servo_cw(D8);
+DigitalOut l2_servo_ccw(D9);
+PwmOut l3_dc_motor_cw(D10);
+PwmOut l3_dc_motor_ccw(D11);
+DigitalOut l3_servo_cw(D12);
+DigitalOut l3_servo_ccw(D13);
+
+void run_l1_dc_motor_cw(void){
+ l1_dc_motor_cw.period_ms(20);
+ l1_dc_motor_cw.pulsewidth_us(4000);
+}
+void run_l1_dc_motor_ccw(void){
+ l1_dc_motor_ccw.period_ms(20); // shoul be 20 ms (490 Hz) and 10 ms for the servo (980 Hz)
+ l1_dc_motor_ccw.pulsewidth_us(5000);
+}
+void run_l2_dc_motor_cw(void){
+ l2_dc_motor_cw.period_ms(20);
+ l2_dc_motor_cw.pulsewidth_us(20000);
+}
+void run_l2_dc_motor_ccw(void){
+ l2_dc_motor_ccw.period_ms(20); // shoul be 20 ms (490 Hz) and 10 ms for the servo (980 Hz)
+ l2_dc_motor_ccw.pulsewidth_us(20000);
+}
+void run_l3_dc_motor_cw(void){
+// l3_dc_motor_cw.period_ms(20);
+// l3_dc_motor_cw.pulsewidth_us(10000);
+}
+void run_l3_dc_motor_ccw(void){
+ l3_dc_motor_ccw.period_ms(20); // shoul be 20 ms (490 Hz) and 10 ms for the servo (980 Hz)
+ l3_dc_motor_ccw.pulsewidth_us(10000);
+}
+void stop_dc_motor(void){
+ l1_dc_motor_cw.pulsewidth_us(0);
+ l1_dc_motor_ccw.pulsewidth_us(0);
+ l2_dc_motor_cw.pulsewidth_us(0);
+ l2_dc_motor_ccw.pulsewidth_us(0);
+ l3_dc_motor_cw.pulsewidth_us(0);
+ l3_dc_motor_ccw.pulsewidth_us(0);
+}
+void run_l1_servo_cw(void){
+ l1_servo_cw=1;
+ l1_servo_ccw=0;
+}
+void run_l1_servo_ccw(void){
+ l1_servo_cw=0;
+ l1_servo_ccw=1;
+}
+void run_l2_servo_cw(void){
+// l2_servo_cw=1;
+// l2_servo_ccw=0;
+}
+void run_l2_servo_ccw(void){
+ l2_servo_cw=0;
+ l2_servo_ccw=1;
+}
+void run_l3_servo_cw(void){
+ l3_servo_cw=1;
+ l3_servo_ccw=0;
+}
+void run_l3_servo_ccw(void){
+ l3_servo_cw=0;
+ l3_servo_ccw=1;
+}
+void stop_servo(void){
+ l1_servo_cw=0;
+ l1_servo_ccw=0;
+ l2_servo_cw=0;
+ l2_servo_ccw=0;
+ l3_servo_cw=0;
+ l3_servo_ccw=0;
+}
+void test_limite(void){
+ end_stop.mode(PullDown);
+ while(1){
+ printf("lim=%d\n", end_stop.read());
+
+ if(end_stop.read()==1){
+ stop_dc_motor();
+// led=0;
+ printf("stop_dc_motor\n");
+ }
+ else{
+ run_l2_dc_motor_ccw();
+ printf("motor runs\n");
+// led=1;
+ }
+ }
+
+}
+int main()
+{
+ printf("Hello World !\n");
+ run_l1_dc_motor_cw();
+ wait_ms(2500);
+ stop_dc_motor();
+ run_l1_servo_cw();
+ wait_ms(2000);
+ stop_servo();
+ run_l2_dc_motor_ccw();
+ wait_ms(1500);
+ stop_dc_motor();
+ run_l2_servo_ccw();
+ wait_ms(1000);
+ stop_servo();
+ run_l2_dc_motor_cw();
+ wait_ms(1500);
+ stop_dc_motor();
+ run_l1_dc_motor_cw();
+ wait_ms(2500);
+ stop_dc_motor();
+ run_l1_servo_ccw();
+ wait_ms(2000);
+ stop_servo();
+ run_l3_dc_motor_ccw();
+ wait_ms(3000);
+ stop_dc_motor();
+
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/backup.txt Sat Feb 20 09:04:41 2021 +0000
@@ -0,0 +1,162 @@
+#include "mbed.h"
+#include "stdio.h"
+
+//DigitalOut led(LED1);
+
+Serial pc(USBTX, USBRX);
+DigitalIn my_button(USER_BUTTON); // Use the user button to switch from dc motor to servo motor and vice versa
+DigitalIn end_stop(D12); // relais fin de course
+
+PwmOut l1_dc_motor_en(D0);
+DigitalOut l1_dc_motor_cw(D1);
+DigitalOut l1_dc_motor_ccw(D2);
+
+PwmOut l1_servo_en(D5);
+DigitalOut l1_servo_cw(D3);
+DigitalOut l1_servo_ccw(D4);
+
+//
+//PwmOut l2_dc_motor_en(D6);
+//DigitalOut l2_dc_motor_cw(D7);
+//DigitalOut l2_dc_motor_ccw(D8);
+//
+//PwmOut l2_servo_en(D11);
+//DigitalOut l2_servo_cw(D9);
+//DigitalOut l2_servo_ccw(D10);
+
+
+void run_l1_dc_motor_cw(void){
+ l1_dc_motor_en.period_ms(20); // shoul be 20 ms (490 Hz) and 10 ms for the servo (980 Hz)
+ l1_dc_motor_en.pulsewidth_us(3000);
+ l1_dc_motor_cw=0;
+ l1_dc_motor_ccw=1;
+}
+void run_l1_dc_motor_ccw(void){
+ l1_dc_motor_en.period_ms(20); // shoul be 20 ms (490 Hz) and 10 ms for the servo (980 Hz)
+ l1_dc_motor_en.pulsewidth_us(3000);
+ l1_dc_motor_cw=1;
+ l1_dc_motor_ccw=0;
+}
+//void run_l2_dc_motor_cw(void){
+// l2_dc_motor_en.period_ms(20); // shoul be 20 ms (490 Hz) and 10 ms for the servo (980 Hz)
+// l2_dc_motor_en.pulsewidth_us(3000);
+// l2_dc_motor_cw=0;
+// l2_dc_motor_ccw=1;
+//}
+//void run_l2_dc_motor_ccw(void){
+// l2_dc_motor_en.period_ms(20); // shoul be 20 ms (490 Hz) and 10 ms for the servo (980 Hz)
+// l2_dc_motor_en.pulsewidth_us(3000);
+// l2_dc_motor_cw=1;
+// l2_dc_motor_ccw=0;
+//}
+
+
+void stop_dc_motor(void){
+ l1_dc_motor_cw=0;
+ l1_dc_motor_ccw=0;
+// l2_dc_motor_cw=0;
+// l2_dc_motor_ccw=0;
+
+}
+
+void run_l1_servo_cw(void){
+ l1_servo_cw=1;
+ l1_servo_ccw=0;
+ l1_servo_en.period_us(870);
+ l1_servo_en.pulsewidth_ms(870);
+}
+void run_l1_servo_ccw(void){
+ l1_servo_cw=0;
+ l1_servo_ccw=1;
+ l1_servo_en.period_us(870);
+ l1_servo_en.pulsewidth_ms(870);
+}
+void stop_servo(void){
+ l1_servo_cw=0;
+ l1_servo_ccw=0;
+}
+
+
+void test_limite(void){
+ end_stop.mode(PullDown);
+ while(1){
+ printf("lim=%d\n", end_stop.read());
+
+ if(end_stop.read()==1){
+ stop_dc_motor();
+// led=0;
+ printf("stop_dc_motor\n");
+ }
+ else{
+ run_l1_dc_motor_ccw();
+ printf("motor runs\n");
+// led=1;
+ }
+ }
+
+}
+
+
+int main()
+{
+ unsigned char cmd=0;
+
+ while (true) {
+ scanf("%c", &cmd);
+ if(cmd == '1')
+ {
+ cmd = 0;
+ stop_dc_motor();
+ printf("stop_dc_motor\r\n");
+ }
+ if(cmd == '2')
+ {
+ cmd = 0;
+ run_l1_dc_motor_cw();
+ printf("run_l1_dc_motor_cw\r\n");
+ }
+ if(cmd == '3')
+ {
+ cmd = 0;
+ run_l1_dc_motor_ccw();
+ printf("run_l1_dc_motor_ccw\r\n");
+ }
+ if(cmd == '4')
+ {
+ cmd = 0;
+ run_l1_servo_cw();
+ wait(1);
+ stop_servo();
+ printf("run_l1_servo_cw\r\n");
+ }
+ if(cmd == '5')
+ {
+ cmd = 0;
+ run_l1_servo_ccw();
+ wait(1);
+ stop_servo();
+ printf("run_l1_servo_ccw\r\n");
+ }
+ if(cmd == '6')
+ {
+// cmd = 0;
+// run_l2_dc_motor_cw();
+// printf("run_l2_dc_motor_cw\r\n");
+ }
+ if(cmd == '7')
+ {
+// cmd = 0;
+// run_l2_dc_motor_ccw();
+// printf("run_l2_dc_motor_ccw\r\n");
+ }
+
+
+
+ if(cmd == 'h')
+ {
+ cmd=0;
+ printf("1=stop_dc_motor; 2=run_l1_dc_motor_cw; 3=run_l1_dc_motor_ccw; 4=run_l1_servo_cw; 5=run_l1_servo_ccw, 6=run_l1_dc_motor_cw; 7=run_l1_dc_motor_ccw\n");
+ }
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/backup0.txt Sat Feb 20 09:04:41 2021 +0000
@@ -0,0 +1,187 @@
+#include "mbed.h"
+#include "stdio.h"
+
+//DigitalOut led(LED1);
+
+Serial pc(USBTX, USBRX);
+DigitalIn my_button(USER_BUTTON); // Use the user button to switch from dc motor to servo motor and vice versa
+DigitalIn end_stop(D11); // relais fin de course
+//
+PwmOut l1_dc_motor_en(D3);
+DigitalOut l1_dc_motor_cw(D2);
+DigitalOut l1_dc_motor_ccw(D4);
+//PwmOut l1_servo_en(D5);
+DigitalOut l1_servo_cw(D7);
+DigitalOut l1_servo_ccw(D8);
+
+PwmOut l2_dc_motor_en(D6);
+DigitalOut l2_dc_motor_cw(D12);
+DigitalOut l2_dc_motor_ccw(D13);
+//PwmOut l2_servo_en(D9);
+DigitalOut l2_servo_cw(D14);
+DigitalOut l2_servo_ccw(D15);
+
+void run_l1_dc_motor_cw(void){
+ l1_dc_motor_en.period_ms(20); // shoul be 20 ms (490 Hz) and 10 ms for the servo (980 Hz)
+ l1_dc_motor_en.pulsewidth_us(3000);
+ l1_dc_motor_cw=0;
+ l1_dc_motor_ccw=1;
+}
+void run_l1_dc_motor_ccw(void){
+ l1_dc_motor_en.period_ms(20); // shoul be 20 ms (490 Hz) and 10 ms for the servo (980 Hz)
+ l1_dc_motor_en.pulsewidth_us(3000);
+ l1_dc_motor_cw=1;
+ l1_dc_motor_ccw=0;
+}
+void run_l2_dc_motor_cw(void){
+ l2_dc_motor_en.period_ms(20); // shoul be 20 ms (490 Hz) and 10 ms for the servo (980 Hz)
+ l2_dc_motor_en.pulsewidth_us(50000);
+ l2_dc_motor_cw=0;
+ l2_dc_motor_ccw=1;
+}
+void run_l2_dc_motor_ccw(void){
+ l2_dc_motor_en.period_ms(20); // shoul be 20 ms (490 Hz) and 10 ms for the servo (980 Hz)
+ l2_dc_motor_en.pulsewidth_us(50000);
+ l2_dc_motor_cw=1;
+ l2_dc_motor_ccw=0;
+}
+
+
+void stop_dc_motor(void){
+ l1_dc_motor_cw=0;
+ l1_dc_motor_ccw=0;
+ l2_dc_motor_cw=0;
+ l2_dc_motor_ccw=0;
+
+}
+
+void run_l1_servo_cw(void){
+ l1_servo_cw=1;
+ l1_servo_ccw=0;
+}
+void run_l1_servo_ccw(void){
+ l1_servo_cw=0;
+ l1_servo_ccw=1;
+}
+
+void run_l2_servo_cw(void){
+ l2_servo_cw=1;
+ l2_servo_ccw=0;
+}
+void run_l2_servo_ccw(void){
+ l2_servo_cw=0;
+ l2_servo_ccw=1;
+}
+
+
+void stop_servo(void){
+ l1_servo_cw=0;
+ l1_servo_ccw=0;
+ l2_servo_cw=0;
+ l2_servo_ccw=0;
+}
+
+
+void test_limite(void){
+ end_stop.mode(PullDown);
+ while(1){
+ printf("lim=%d\n", end_stop.read());
+
+ if(end_stop.read()==1){
+ stop_dc_motor();
+// led=0;
+ printf("stop_dc_motor\n");
+ }
+ else{
+ run_l1_dc_motor_ccw();
+ printf("motor runs\n");
+// led=1;
+ }
+ }
+
+}
+
+int main()
+{
+ printf("Hello World !\n");
+ unsigned char cmd=0;
+ while (true) {
+ scanf("%c", &cmd);
+ if(cmd == '1')
+ {
+ cmd = 0;
+ stop_dc_motor();
+ printf("stop_dc_motor\r\n");
+ }
+ if(cmd == '2')
+ {
+ cmd = 0;
+ run_l1_dc_motor_cw();
+ printf("run_l1_dc_motor_cw\r\n");
+ }
+ if(cmd == '3')
+ {
+ cmd = 0;
+ run_l1_dc_motor_ccw();
+ printf("run_l1_dc_motor_ccw\r\n");
+ }
+ if(cmd == '4')
+ {
+ cmd = 0;
+ run_l1_servo_cw();
+ wait(1);
+ stop_servo();
+ printf("run_l1_servo_cw\r\n");
+ }
+ if(cmd == '5')
+ {
+ cmd = 0;
+ run_l1_servo_ccw();
+ wait(1);
+ stop_servo();
+ printf("run_l1_servo_ccw\r\n");
+ }
+ if(cmd == '6')
+ {
+ cmd = 0;
+ run_l2_dc_motor_cw();
+ printf("run_l2_dc_motor_cw\r\n");
+ }
+ if(cmd == '7')
+ {
+ cmd = 0;
+ run_l2_dc_motor_ccw();
+ printf("run_l2_dc_motor_ccw\r\n");
+ }
+ if(cmd == '8')
+ {
+ cmd = 0;
+ run_l2_servo_cw();
+ wait(1);
+ stop_servo();
+
+// l2_servo_cw=0;
+// l2_servo_ccw=0;
+ printf("run_l2_servo_cw\r\n");
+ }
+
+ if(cmd == '9')
+ {
+ cmd = 0;
+ run_l2_servo_ccw();
+ wait(1);
+ stop_servo();
+// l2_servo_cw=0;
+// l2_servo_ccw=0;
+
+ printf("run_l2_servo_ccw\r\n");
+ }
+
+
+ if(cmd == 'h')
+ {
+ cmd=0;
+ printf("1=stop_dc_motor; 2=run_l1_dc_motor_cw; 3=run_l1_dc_motor_ccw; 4=run_l1_servo_cw; 5=run_l1_servo_ccw, 6=run_l1_dc_motor_cw; 7=run_l1_dc_motor_ccw\n");
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/control_working_code.txt Sat Feb 20 09:04:41 2021 +0000
@@ -0,0 +1,220 @@
+#include "mbed.h"
+#include "stdio.h"
+
+//DigitalOut led(LED1);
+
+Serial pc(USBTX, USBRX);
+DigitalIn my_button(USER_BUTTON); // Use the user button to switch from dc motor to servo motor and vice versa
+DigitalIn end_stop(A5); // relais fin de course
+
+PwmOut l1_dc_motor_cw(D2);
+PwmOut l1_dc_motor_ccw(D3);
+DigitalOut l1_servo_cw(D4);
+DigitalOut l1_servo_ccw(D5);
+PwmOut l2_dc_motor_cw(D6);
+PwmOut l2_dc_motor_ccw(D7);
+DigitalOut l2_servo_cw(D8);
+DigitalOut l2_servo_ccw(D9);
+PwmOut l3_dc_motor_cw(D10);
+PwmOut l3_dc_motor_ccw(D11);
+DigitalOut l3_servo_cw(D12);
+DigitalOut l3_servo_ccw(D13);
+
+void run_l1_dc_motor_cw(void){
+ l1_dc_motor_cw.period_ms(20);
+ l1_dc_motor_cw.pulsewidth_us(4000);
+}
+void run_l1_dc_motor_ccw(void){
+ l1_dc_motor_ccw.period_ms(20); // shoul be 20 ms (490 Hz) and 10 ms for the servo (980 Hz)
+ l1_dc_motor_ccw.pulsewidth_us(5000);
+}
+void run_l2_dc_motor_cw(void){
+ l2_dc_motor_cw.period_ms(20);
+ l2_dc_motor_cw.pulsewidth_us(20000);
+}
+void run_l2_dc_motor_ccw(void){
+ l2_dc_motor_ccw.period_ms(20); // shoul be 20 ms (490 Hz) and 10 ms for the servo (980 Hz)
+ l2_dc_motor_ccw.pulsewidth_us(20000);
+}
+void run_l3_dc_motor_cw(void){
+// l3_dc_motor_cw.period_ms(20);
+// l3_dc_motor_cw.pulsewidth_us(10000);
+}
+void run_l3_dc_motor_ccw(void){
+ l3_dc_motor_ccw.period_ms(20); // shoul be 20 ms (490 Hz) and 10 ms for the servo (980 Hz)
+ l3_dc_motor_ccw.pulsewidth_us(10000);
+}
+void stop_dc_motor(void){
+ l1_dc_motor_cw.pulsewidth_us(0);
+ l1_dc_motor_ccw.pulsewidth_us(0);
+ l2_dc_motor_cw.pulsewidth_us(0);
+ l2_dc_motor_ccw.pulsewidth_us(0);
+ l3_dc_motor_cw.pulsewidth_us(0);
+ l3_dc_motor_ccw.pulsewidth_us(0);
+}
+void run_l1_servo_cw(void){
+ l1_servo_cw=1;
+ l1_servo_ccw=0;
+}
+void run_l1_servo_ccw(void){
+ l1_servo_cw=0;
+ l1_servo_ccw=1;
+}
+void run_l2_servo_cw(void){
+// l2_servo_cw=1;
+// l2_servo_ccw=0;
+}
+void run_l2_servo_ccw(void){
+ l2_servo_cw=0;
+ l2_servo_ccw=1;
+}
+void run_l3_servo_cw(void){
+ l3_servo_cw=1;
+ l3_servo_ccw=0;
+}
+void run_l3_servo_ccw(void){
+ l3_servo_cw=0;
+ l3_servo_ccw=1;
+}
+void stop_servo(void){
+ l1_servo_cw=0;
+ l1_servo_ccw=0;
+ l2_servo_cw=0;
+ l2_servo_ccw=0;
+ l3_servo_cw=0;
+ l3_servo_ccw=0;
+}
+void test_limite(void){
+ end_stop.mode(PullDown);
+ while(1){
+ printf("lim=%d\n", end_stop.read());
+
+ if(end_stop.read()==1){
+ stop_dc_motor();
+// led=0;
+ printf("stop_dc_motor\n");
+ }
+ else{
+ run_l2_dc_motor_ccw();
+ printf("motor runs\n");
+// led=1;
+ }
+ }
+
+}
+int main()
+{
+ printf("Hello World !\n");
+ unsigned char cmd=0;
+ while (true) {
+ scanf("%c", &cmd);
+ if(cmd == '1')
+ {
+ cmd = 0;
+ stop_dc_motor();
+ printf("stop_dc_motor\r\n");
+ }
+ if(cmd == '2')
+ {
+ cmd = 0;
+ run_l1_dc_motor_cw();
+ printf("run_l1_dc_motor_cw\r\n");
+ }
+ if(cmd == '3')
+ {
+ cmd = 0;
+ run_l1_dc_motor_ccw();
+ printf("run_l1_dc_motor_ccw\r\n");
+ }
+ if(cmd == '4')
+ {
+ cmd = 0;
+ run_l1_servo_cw();
+ wait(1);
+ stop_servo();
+ printf("run_l1_servo_cw\r\n");
+ }
+ if(cmd == '5')
+ {
+ cmd = 0;
+ run_l1_servo_ccw();
+ wait(1);
+ stop_servo();
+ printf("run_l1_servo_ccw\r\n");
+ }
+ if(cmd == '6')
+ {
+ cmd = 0;
+ run_l2_dc_motor_cw();
+ printf("run_l2_dc_motor_cw\r\n");
+ }
+ if(cmd == '7')
+ {
+ cmd = 0;
+ run_l2_dc_motor_ccw();
+ printf("run_l2_dc_motor_ccw\r\n");
+ }
+ if(cmd == '8')
+ {
+ cmd = 0;
+ run_l2_servo_cw();
+ wait(1);
+ stop_servo();
+ printf("run_l2_servo_cw\r\n");
+ }
+ if(cmd == '9')
+ {
+ cmd = 0;
+ run_l2_servo_ccw();
+ wait(1);
+ stop_servo();
+ printf("run_l2_servo_ccw\r\n");
+ }
+
+
+
+ if(cmd == 'a')
+ {
+ cmd = 0;
+ run_l3_dc_motor_cw();
+ printf("run_l3_dc_motor_cw\r\n");
+ }
+ if(cmd == 'b')
+ {
+ cmd = 0;
+ run_l3_dc_motor_ccw();
+ printf("run_l3_dc_motor_ccw\r\n");
+ }
+ if(cmd == 'c')
+ {
+ cmd = 0;
+ run_l3_servo_cw();
+ wait(1);
+ stop_servo();
+ printf("run_l3_servo_cw\r\n");
+ }
+ if(cmd == 'd')
+ {
+ cmd = 0;
+ run_l3_servo_ccw();
+ wait(1);
+ stop_servo();
+ printf("run_l3_servo_ccw\r\n");
+ }
+ if(cmd == 't')
+ {
+ cmd = 0;
+ test_limite();
+ printf("test_limite()\r\n");
+ }
+
+ if(cmd == 'h')
+ {
+ cmd=0;
+ printf("1=stop_dc_motor\n");
+ printf("2=run_l1_dc_motor_cw; 3=run_l1_dc_motor_ccw; 4=run_l1_servo_cw; 5=run_l1_servo_ccw\n");
+ printf("6=run_l2_dc_motor_cw; 7=run_l2_dc_motor_ccw; 8=run_l2_servo_cw; 9=run_l2_servo_ccw\n");
+ printf("a=run_l3_dc_motor_cw; b=run_l3_dc_motor_ccw; c=run_l3_servo_cw; d=run_l3_servo_ccw.\n");
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/final_v1_code.txt Sat Feb 20 09:04:41 2021 +0000
@@ -0,0 +1,276 @@
+#include "mbed.h"
+#include "stdio.h"
+
+//DigitalOut led(LED1);
+
+Serial pc(USBTX, USBRX);
+DigitalIn my_button(USER_BUTTON); // Use the user button to switch from control mode and auto mode
+DigitalIn end_stop(A5); // relais fin de course
+
+PwmOut l1_dc_motor_cw(D2);
+PwmOut l1_dc_motor_ccw(D3);
+DigitalOut l1_servo_cw(D4);
+DigitalOut l1_servo_ccw(D5);
+PwmOut l2_dc_motor_cw(D6);
+PwmOut l2_dc_motor_ccw(D7);
+DigitalOut l2_servo_cw(D8);
+DigitalOut l2_servo_ccw(D9);
+PwmOut l3_dc_motor_cw(D10);
+PwmOut l3_dc_motor_ccw(D11);
+DigitalOut l3_servo_cw(D12);
+DigitalOut l3_servo_ccw(D13);
+int l1_dc_speed=2500;
+
+void run_l1_dc_motor_cw(void){
+ l1_dc_motor_cw.period_ms(20);
+ l1_dc_motor_cw.pulsewidth_us(l1_dc_speed);//1800
+}
+void run_l1_dc_motor_ccw(void){
+ l1_dc_motor_ccw.period_ms(20); // shoul be 20 ms (490 Hz) and 10 ms for the servo (980 Hz)
+ l1_dc_motor_ccw.pulsewidth_us(l1_dc_speed);
+}
+void run_l2_dc_motor_cw(void){
+ l2_dc_motor_cw.period_ms(20);
+ l2_dc_motor_cw.pulsewidth_us(5000);
+}
+void run_l2_dc_motor_ccw(void){
+ l2_dc_motor_ccw.period_ms(20); // shoul be 20 ms (490 Hz) and 10 ms for the servo (980 Hz)
+ l2_dc_motor_ccw.pulsewidth_us(5000);
+}
+void run_l3_dc_motor_cw(void){
+// l3_dc_motor_cw.period_ms(20);
+// l3_dc_motor_cw.pulsewidth_us(10000);
+}
+void run_l3_dc_motor_ccw(void){
+ l3_dc_motor_ccw.period_ms(20); // shoul be 20 ms (490 Hz) and 10 ms for the servo (980 Hz)
+ l3_dc_motor_ccw.pulsewidth_us(5000);
+}
+void stop_dc_motor(void){
+ l1_dc_motor_cw.pulsewidth_us(0);
+ l1_dc_motor_ccw.pulsewidth_us(0);
+ l2_dc_motor_cw.pulsewidth_us(0);
+ l2_dc_motor_ccw.pulsewidth_us(0);
+ l3_dc_motor_cw.pulsewidth_us(0);
+ l3_dc_motor_ccw.pulsewidth_us(0);
+}
+void run_l1_servo_cw(void){
+ l1_servo_cw=1;
+ l1_servo_ccw=0;
+}
+void run_l1_servo_ccw(void){
+ l1_servo_cw=0;
+ l1_servo_ccw=1;
+}
+void run_l2_servo_cw(void){
+// l2_servo_cw=1;
+// l2_servo_ccw=0;
+}
+void run_l2_servo_ccw(void){
+ l2_servo_cw=0;
+ l2_servo_ccw=1;
+}
+void run_l3_servo_cw(void){
+ l3_servo_cw=1;
+ l3_servo_ccw=0;
+}
+void run_l3_servo_ccw(void){
+ l3_servo_cw=0;
+ l3_servo_ccw=1;
+}
+void stop_servo(void){
+ l1_servo_cw=0;
+ l1_servo_ccw=0;
+ l2_servo_cw=0;
+ l2_servo_ccw=0;
+ l3_servo_cw=0;
+ l3_servo_ccw=0;
+}
+void test_limite(void){
+ end_stop.mode(PullDown);
+ while(1){
+ printf("lim=%d\n", end_stop.read());
+
+ if(end_stop.read()==1){
+ stop_dc_motor();
+// led=0;
+ printf("stop_dc_motor\n");
+ }
+ else{
+ run_l2_dc_motor_ccw();
+ printf("motor runs\n");
+// led=1;
+ }
+ }
+
+}
+void auto_run(void){
+ int l1_wait = 1300;
+ int l2_wait = 1250;
+ int l3_wait = 2500;
+
+ printf("Hello World !\n");
+ run_l1_dc_motor_cw();
+ wait_ms(l1_wait);
+ stop_dc_motor();
+ run_l1_dc_motor_ccw();
+ wait_ms(l1_wait);
+ stop_dc_motor();
+ wait_ms(1000);
+ run_l1_servo_cw();
+ wait_ms(1000);
+ stop_servo();
+ run_l2_dc_motor_ccw();
+ wait_ms(l2_wait);
+ stop_dc_motor();
+ wait_ms(1000);
+ run_l2_servo_ccw();
+ wait_ms(1000);
+ stop_servo();
+ run_l2_dc_motor_cw();
+ wait_ms(l2_wait);
+ stop_dc_motor();
+ run_l1_dc_motor_cw();
+ wait_ms(l1_wait);
+ stop_dc_motor();
+ run_l1_dc_motor_ccw();
+ wait_ms(l1_wait);
+ stop_dc_motor();
+ wait_ms(1000);
+ run_l1_servo_ccw();
+ wait_ms(1000);
+ stop_servo();
+ run_l3_dc_motor_ccw();
+ wait_ms(l3_wait);
+ stop_dc_motor();
+}
+
+void control_mode(void){
+ unsigned char cmd=0;
+ while(1){
+ scanf("%c", &cmd);
+ if(cmd == '1')
+ {
+ cmd = 0;
+ stop_dc_motor();
+ printf("stop_dc_motor\r\n");
+ }
+ if(cmd == '2')
+ {
+ cmd = 0;
+ run_l1_dc_motor_cw();
+ printf("run_l1_dc_motor_cw\r\n");
+ }
+ if(cmd == '3')
+ {
+ cmd = 0;
+ run_l1_dc_motor_ccw();
+ printf("run_l1_dc_motor_ccw\r\n");
+ }
+ if(cmd == '4')
+ {
+ cmd = 0;
+ run_l1_servo_cw();
+ wait(1);
+ stop_servo();
+ printf("run_l1_servo_cw\r\n");
+ }
+ if(cmd == '5')
+ {
+ cmd = 0;
+ run_l1_servo_ccw();
+ wait(1);
+ stop_servo();
+ printf("run_l1_servo_ccw\r\n");
+ }
+ if(cmd == '6')
+ {
+ cmd = 0;
+ run_l2_dc_motor_cw();
+ printf("run_l2_dc_motor_cw\r\n");
+ }
+ if(cmd == '7')
+ {
+ cmd = 0;
+ run_l2_dc_motor_ccw();
+ printf("run_l2_dc_motor_ccw\r\n");
+ }
+ if(cmd == '8')
+ {
+ cmd = 0;
+ run_l2_servo_cw();
+ wait(1);
+ stop_servo();
+ printf("run_l2_servo_cw\r\n");
+ }
+ if(cmd == '9')
+ {
+ cmd = 0;
+ run_l2_servo_ccw();
+ wait(1);
+ stop_servo();
+ printf("run_l2_servo_ccw\r\n");
+ }
+
+ if(cmd == 'a')
+ {
+ cmd = 0;
+ run_l3_dc_motor_cw();
+ printf("run_l3_dc_motor_cw\r\n");
+ }
+ if(cmd == 'b')
+ {
+ cmd = 0;
+ run_l3_dc_motor_ccw();
+ printf("run_l3_dc_motor_ccw\r\n");
+ }
+ if(cmd == 'c')
+ {
+ cmd = 0;
+ run_l3_servo_cw();
+ wait(1);
+ stop_servo();
+ printf("run_l3_servo_cw\r\n");
+ }
+ if(cmd == 'd')
+ {
+ cmd = 0;
+ run_l3_servo_ccw();
+ wait(1);
+ stop_servo();
+ printf("run_l3_servo_ccw\r\n");
+ }
+ if(cmd == 't')
+ {
+ cmd = 0;
+ test_limite();
+ printf("test_limite()\r\n");
+ }
+
+ if(cmd == 'e')
+ {
+ cmd = 0;
+ printf("exit\r\n");
+ break;
+ }
+
+ if(cmd == 'h')
+ {
+ cmd=0;
+ printf("1=stop_dc_motor\n");
+ printf("2=run_l1_dc_motor_cw; 3=run_l1_dc_motor_ccw; 4=run_l1_servo_cw; 5=run_l1_servo_ccw\n");
+ printf("6=run_l2_dc_motor_cw; 7=run_l2_dc_motor_ccw; 8=run_l2_servo_cw; 9=run_l2_servo_ccw\n");
+ printf("a=run_l3_dc_motor_cw; b=run_l3_dc_motor_ccw; c=run_l3_servo_cw; d=run_l3_servo_ccw.\n");
+ }
+
+ }
+
+}
+
+int main(){
+ while(1){
+ for (int i=0; i<3; i++) {
+ auto_run();
+ }
+ control_mode();
+ }
+}
--- a/main.cpp Thu Jan 28 15:51:12 2021 +0000
+++ b/main.cpp Sat Feb 20 09:04:41 2021 +0000
@@ -1,83 +1,90 @@
#include "mbed.h"
#include "stdio.h"
-DigitalOut gpo(D10);
-DigitalOut led(LED1);
+//DigitalOut led(LED1);
Serial pc(USBTX, USBRX);
-DigitalIn my_button(USER_BUTTON); // Use the user button to switch from dc motor to servo motor and vice versa
-DigitalIn end_stop(D2); // relais fin de course
-
-PwmOut l1_dc_motor_en(D0);
-DigitalOut l1_dc_motor_cw(D1);
-DigitalOut l1_dc_motor_ccw(D2);
+DigitalIn my_button(USER_BUTTON); // Use the user button to switch from control mode and auto mode
+DigitalIn end_stop(A5); // relais fin de course
-PwmOut l1_servo_en(D5);
-DigitalOut l1_servo_cw(D3);
-DigitalOut l1_servo_ccw(D4);
-
-
-PwmOut l2_dc_motor_en(D6);
-DigitalOut l2_dc_motor_cw(D7);
-DigitalOut l2_dc_motor_ccw(D8);
-
-PwmOut l2_servo_en(D11);
-DigitalOut l2_servo_cw(D9);
-DigitalOut l2_servo_ccw(D10);
-
+PwmOut l1_dc_motor_cw(D2);
+PwmOut l1_dc_motor_ccw(D3);
+DigitalOut l1_servo_cw(D4);
+DigitalOut l1_servo_ccw(D5);
+PwmOut l2_dc_motor_cw(D6);
+PwmOut l2_dc_motor_ccw(D7);
+DigitalOut l2_servo_cw(D8);
+DigitalOut l2_servo_ccw(D9);
+PwmOut l3_dc_motor_cw(D10);
+PwmOut l3_dc_motor_ccw(D11);
+DigitalOut l3_servo_cw(D12);
+DigitalOut l3_servo_ccw(D13);
+int l1_dc_speed=2500;
void run_l1_dc_motor_cw(void){
- l1_dc_motor_en.period_ms(20); // shoul be 20 ms (490 Hz) and 10 ms for the servo (980 Hz)
- l1_dc_motor_en.pulsewidth_us(3000);
- l1_dc_motor_cw=0;
- l1_dc_motor_ccw=1;
+ l1_dc_motor_cw.period_ms(20);
+ l1_dc_motor_cw.pulsewidth_us(l1_dc_speed);//1800
}
void run_l1_dc_motor_ccw(void){
- l1_dc_motor_en.period_ms(20); // shoul be 20 ms (490 Hz) and 10 ms for the servo (980 Hz)
- l1_dc_motor_en.pulsewidth_us(3000);
- l1_dc_motor_cw=1;
- l1_dc_motor_ccw=0;
+ l1_dc_motor_ccw.period_ms(20); // shoul be 20 ms (490 Hz) and 10 ms for the servo (980 Hz)
+ l1_dc_motor_ccw.pulsewidth_us(l1_dc_speed);
}
void run_l2_dc_motor_cw(void){
- l2_dc_motor_en.period_ms(20); // shoul be 20 ms (490 Hz) and 10 ms for the servo (980 Hz)
- l2_dc_motor_en.pulsewidth_us(3000);
- l2_dc_motor_cw=0;
- l2_dc_motor_ccw=1;
+ l2_dc_motor_cw.period_ms(20);
+ l2_dc_motor_cw.pulsewidth_us(5000);
}
void run_l2_dc_motor_ccw(void){
- l2_dc_motor_en.period_ms(20); // shoul be 20 ms (490 Hz) and 10 ms for the servo (980 Hz)
- l2_dc_motor_en.pulsewidth_us(3000);
- l2_dc_motor_cw=1;
- l2_dc_motor_ccw=0;
+ l2_dc_motor_ccw.period_ms(20); // shoul be 20 ms (490 Hz) and 10 ms for the servo (980 Hz)
+ l2_dc_motor_ccw.pulsewidth_us(5000);
}
-
-
+void run_l3_dc_motor_cw(void){
+// l3_dc_motor_cw.period_ms(20);
+// l3_dc_motor_cw.pulsewidth_us(10000);
+}
+void run_l3_dc_motor_ccw(void){
+ l3_dc_motor_ccw.period_ms(20); // shoul be 20 ms (490 Hz) and 10 ms for the servo (980 Hz)
+ l3_dc_motor_ccw.pulsewidth_us(5000);
+}
void stop_dc_motor(void){
- l1_dc_motor_cw=0;
- l1_dc_motor_ccw=0;
- l2_dc_motor_cw=0;
- l2_dc_motor_ccw=0;
-
+ l1_dc_motor_cw.pulsewidth_us(0);
+ l1_dc_motor_ccw.pulsewidth_us(0);
+ l2_dc_motor_cw.pulsewidth_us(0);
+ l2_dc_motor_ccw.pulsewidth_us(0);
+ l3_dc_motor_cw.pulsewidth_us(0);
+ l3_dc_motor_ccw.pulsewidth_us(0);
}
-
void run_l1_servo_cw(void){
l1_servo_cw=1;
l1_servo_ccw=0;
- l1_servo_en.period_us(870);
- l1_servo_en.pulsewidth_ms(870);
}
void run_l1_servo_ccw(void){
l1_servo_cw=0;
l1_servo_ccw=1;
- l1_servo_en.period_us(870);
- l1_servo_en.pulsewidth_ms(870);
+}
+void run_l2_servo_cw(void){
+// l2_servo_cw=1;
+// l2_servo_ccw=0;
+}
+void run_l2_servo_ccw(void){
+ l2_servo_cw=0;
+ l2_servo_ccw=1;
+}
+void run_l3_servo_cw(void){
+ l3_servo_cw=1;
+ l3_servo_ccw=0;
+}
+void run_l3_servo_ccw(void){
+ l3_servo_cw=0;
+ l3_servo_ccw=1;
}
void stop_servo(void){
l1_servo_cw=0;
l1_servo_ccw=0;
+ l2_servo_cw=0;
+ l2_servo_ccw=0;
+ l3_servo_cw=0;
+ l3_servo_ccw=0;
}
-
-
void test_limite(void){
end_stop.mode(PullDown);
while(1){
@@ -85,24 +92,61 @@
if(end_stop.read()==1){
stop_dc_motor();
- led=0;
+// led=0;
printf("stop_dc_motor\n");
}
else{
- run_l1_dc_motor_ccw();
+ run_l2_dc_motor_ccw();
printf("motor runs\n");
- led=1;
+// led=1;
}
}
}
-
+void auto_run(void){
+ int l1_wait = 1300;
+ int l2_wait = 1250;
+ int l3_wait = 2500;
-int main()
-{
+ printf("Hello World !\n");
+ run_l1_dc_motor_cw();
+ wait_ms(l1_wait);
+ stop_dc_motor();
+ run_l1_dc_motor_ccw();
+ wait_ms(l1_wait);
+ stop_dc_motor();
+ wait_ms(1000);
+ run_l1_servo_cw();
+ wait_ms(1000);
+ stop_servo();
+ run_l2_dc_motor_ccw();
+ wait_ms(l2_wait);
+ stop_dc_motor();
+ wait_ms(1000);
+ run_l2_servo_ccw();
+ wait_ms(1000);
+ stop_servo();
+ run_l2_dc_motor_cw();
+ wait_ms(l2_wait);
+ stop_dc_motor();
+ run_l1_dc_motor_cw();
+ wait_ms(l1_wait);
+ stop_dc_motor();
+ run_l1_dc_motor_ccw();
+ wait_ms(l1_wait);
+ stop_dc_motor();
+ wait_ms(1000);
+ run_l1_servo_ccw();
+ wait_ms(1000);
+ stop_servo();
+ run_l3_dc_motor_ccw();
+ wait_ms(l3_wait);
+ stop_dc_motor();
+}
+
+void control_mode(void){
unsigned char cmd=0;
-
- while (true) {
+ while(1){
scanf("%c", &cmd);
if(cmd == '1')
{
@@ -150,14 +194,83 @@
run_l2_dc_motor_ccw();
printf("run_l2_dc_motor_ccw\r\n");
}
+ if(cmd == '8')
+ {
+ cmd = 0;
+ run_l2_servo_cw();
+ wait(1);
+ stop_servo();
+ printf("run_l2_servo_cw\r\n");
+ }
+ if(cmd == '9')
+ {
+ cmd = 0;
+ run_l2_servo_ccw();
+ wait(1);
+ stop_servo();
+ printf("run_l2_servo_ccw\r\n");
+ }
+
+ if(cmd == 'a')
+ {
+ cmd = 0;
+ run_l3_dc_motor_cw();
+ printf("run_l3_dc_motor_cw\r\n");
+ }
+ if(cmd == 'b')
+ {
+ cmd = 0;
+ run_l3_dc_motor_ccw();
+ printf("run_l3_dc_motor_ccw\r\n");
+ }
+ if(cmd == 'c')
+ {
+ cmd = 0;
+ run_l3_servo_cw();
+ wait(1);
+ stop_servo();
+ printf("run_l3_servo_cw\r\n");
+ }
+ if(cmd == 'd')
+ {
+ cmd = 0;
+ run_l3_servo_ccw();
+ wait(1);
+ stop_servo();
+ printf("run_l3_servo_ccw\r\n");
+ }
+ if(cmd == 't')
+ {
+ cmd = 0;
+ test_limite();
+ printf("test_limite()\r\n");
+ }
-
+ if(cmd == 'e')
+ {
+ cmd = 0;
+ printf("exit\r\n");
+ break;
+ }
if(cmd == 'h')
{
cmd=0;
- printf("1=stop_dc_motor; 2=run_l1_dc_motor_cw; 3=run_l1_dc_motor_ccw; 4=run_l1_servo_cw; 5=run_l1_servo_ccw, 6=run_l1_dc_motor_cw; 7=run_l1_dc_motor_ccw\n");
+ printf("1=stop_dc_motor\n");
+ printf("2=run_l1_dc_motor_cw; 3=run_l1_dc_motor_ccw; 4=run_l1_servo_cw; 5=run_l1_servo_ccw\n");
+ printf("6=run_l2_dc_motor_cw; 7=run_l2_dc_motor_ccw; 8=run_l2_servo_cw; 9=run_l2_servo_ccw\n");
+ printf("a=run_l3_dc_motor_cw; b=run_l3_dc_motor_ccw; c=run_l3_servo_cw; d=run_l3_servo_ccw.\n");
}
+
+ }
+
+}
+
+int main(){
+ while(1){
+ for (int i=0; i<3; i++) {
+ auto_run();
+ }
+ control_mode();
}
-
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main_V0.txt Sat Feb 20 09:04:41 2021 +0000
@@ -0,0 +1,266 @@
+#include "mbed.h"
+#include "stdio.h"
+
+//DigitalOut led(LED1);
+
+Serial pc(USBTX, USBRX);
+DigitalIn my_button(USER_BUTTON); // Use the user button to switch from dc motor to servo motor and vice versa
+DigitalIn end_stop(A5); // relais fin de course
+
+PwmOut l1_dc_motor_cw(D2);
+PwmOut l1_dc_motor_ccw(D3);
+DigitalOut l1_servo_cw(D4);
+DigitalOut l1_servo_ccw(D5);
+PwmOut l2_dc_motor_cw(D6);
+PwmOut l2_dc_motor_ccw(D7);
+DigitalOut l2_servo_cw(D8);
+DigitalOut l2_servo_ccw(D9);
+PwmOut l3_dc_motor_cw(D10);
+PwmOut l3_dc_motor_ccw(D11);
+DigitalOut l3_servo_cw(D12);
+DigitalOut l3_servo_ccw(D13);
+int l1_dc_speed=2500;
+
+void run_l1_dc_motor_cw(void){
+ l1_dc_motor_cw.period_ms(20);
+ l1_dc_motor_cw.pulsewidth_us(l1_dc_speed);//1800
+}
+void run_l1_dc_motor_ccw(void){
+ l1_dc_motor_ccw.period_ms(20); // shoul be 20 ms (490 Hz) and 10 ms for the servo (980 Hz)
+ l1_dc_motor_ccw.pulsewidth_us(l1_dc_speed);
+}
+void run_l2_dc_motor_cw(void){
+ l2_dc_motor_cw.period_ms(20);
+ l2_dc_motor_cw.pulsewidth_us(5000);
+}
+void run_l2_dc_motor_ccw(void){
+ l2_dc_motor_ccw.period_ms(20); // shoul be 20 ms (490 Hz) and 10 ms for the servo (980 Hz)
+ l2_dc_motor_ccw.pulsewidth_us(5000);
+}
+void run_l3_dc_motor_cw(void){
+// l3_dc_motor_cw.period_ms(20);
+// l3_dc_motor_cw.pulsewidth_us(10000);
+}
+void run_l3_dc_motor_ccw(void){
+ l3_dc_motor_ccw.period_ms(20); // shoul be 20 ms (490 Hz) and 10 ms for the servo (980 Hz)
+ l3_dc_motor_ccw.pulsewidth_us(5000);
+}
+void stop_dc_motor(void){
+ l1_dc_motor_cw.pulsewidth_us(0);
+ l1_dc_motor_ccw.pulsewidth_us(0);
+ l2_dc_motor_cw.pulsewidth_us(0);
+ l2_dc_motor_ccw.pulsewidth_us(0);
+ l3_dc_motor_cw.pulsewidth_us(0);
+ l3_dc_motor_ccw.pulsewidth_us(0);
+}
+void run_l1_servo_cw(void){
+ l1_servo_cw=1;
+ l1_servo_ccw=0;
+}
+void run_l1_servo_ccw(void){
+ l1_servo_cw=0;
+ l1_servo_ccw=1;
+}
+void run_l2_servo_cw(void){
+// l2_servo_cw=1;
+// l2_servo_ccw=0;
+}
+void run_l2_servo_ccw(void){
+ l2_servo_cw=0;
+ l2_servo_ccw=1;
+}
+void run_l3_servo_cw(void){
+ l3_servo_cw=1;
+ l3_servo_ccw=0;
+}
+void run_l3_servo_ccw(void){
+ l3_servo_cw=0;
+ l3_servo_ccw=1;
+}
+void stop_servo(void){
+ l1_servo_cw=0;
+ l1_servo_ccw=0;
+ l2_servo_cw=0;
+ l2_servo_ccw=0;
+ l3_servo_cw=0;
+ l3_servo_ccw=0;
+}
+void test_limite(void){
+ end_stop.mode(PullDown);
+ while(1){
+ printf("lim=%d\n", end_stop.read());
+
+ if(end_stop.read()==1){
+ stop_dc_motor();
+// led=0;
+ printf("stop_dc_motor\n");
+ }
+ else{
+ run_l2_dc_motor_ccw();
+ printf("motor runs\n");
+// led=1;
+ }
+ }
+
+}
+void auto_run(void){
+ int l1_wait = 1300;
+ int l2_wait = 1250;
+ int l3_wait = 2500;
+
+ printf("Hello World !\n");
+ run_l1_dc_motor_cw();
+ wait_ms(l1_wait);
+ stop_dc_motor();
+ run_l1_dc_motor_ccw();
+ wait_ms(l1_wait);
+ stop_dc_motor();
+ wait_ms(1000);
+ run_l1_servo_cw();
+ wait_ms(1000);
+ stop_servo();
+ run_l2_dc_motor_ccw();
+ wait_ms(l2_wait);
+ stop_dc_motor();
+ wait_ms(1000);
+ run_l2_servo_ccw();
+ wait_ms(1000);
+ stop_servo();
+ run_l2_dc_motor_cw();
+ wait_ms(l2_wait);
+ stop_dc_motor();
+ run_l1_dc_motor_cw();
+ wait_ms(l1_wait);
+ stop_dc_motor();
+ run_l1_dc_motor_ccw();
+ wait_ms(l1_wait);
+ stop_dc_motor();
+ wait_ms(1000);
+ run_l1_servo_ccw();
+ wait_ms(1000);
+ stop_servo();
+ run_l3_dc_motor_ccw();
+ wait_ms(l3_wait);
+ stop_dc_motor();
+}
+void control(){
+ unsigned char cmd=0;
+ while (true) {
+ scanf("%c", &cmd);
+ if(cmd == '1')
+ {
+ cmd = 0;
+ stop_dc_motor();
+ printf("stop_dc_motor\r\n");
+ }
+ if(cmd == '2')
+ {
+ cmd = 0;
+ run_l1_dc_motor_cw();
+ printf("run_l1_dc_motor_cw\r\n");
+ }
+ if(cmd == '3')
+ {
+ cmd = 0;
+ run_l1_dc_motor_ccw();
+ printf("run_l1_dc_motor_ccw\r\n");
+ }
+ if(cmd == '4')
+ {
+ cmd = 0;
+ run_l1_servo_cw();
+ wait(1);
+ stop_servo();
+ printf("run_l1_servo_cw\r\n");
+ }
+ if(cmd == '5')
+ {
+ cmd = 0;
+ run_l1_servo_ccw();
+ wait(1);
+ stop_servo();
+ printf("run_l1_servo_ccw\r\n");
+ }
+ if(cmd == '6')
+ {
+ cmd = 0;
+ run_l2_dc_motor_cw();
+ printf("run_l2_dc_motor_cw\r\n");
+ }
+ if(cmd == '7')
+ {
+ cmd = 0;
+ run_l2_dc_motor_ccw();
+ printf("run_l2_dc_motor_ccw\r\n");
+ }
+ if(cmd == '8')
+ {
+ cmd = 0;
+ run_l2_servo_cw();
+ wait(1);
+ stop_servo();
+ printf("run_l2_servo_cw\r\n");
+ }
+ if(cmd == '9')
+ {
+ cmd = 0;
+ run_l2_servo_ccw();
+ wait(1);
+ stop_servo();
+ printf("run_l2_servo_ccw\r\n");
+ }
+
+
+
+ if(cmd == 'a')
+ {
+ cmd = 0;
+ run_l3_dc_motor_cw();
+ printf("run_l3_dc_motor_cw\r\n");
+ }
+ if(cmd == 'b')
+ {
+ cmd = 0;
+ run_l3_dc_motor_ccw();
+ printf("run_l3_dc_motor_ccw\r\n");
+ }
+ if(cmd == 'c')
+ {
+ cmd = 0;
+ run_l3_servo_cw();
+ wait(1);
+ stop_servo();
+ printf("run_l3_servo_cw\r\n");
+ }
+ if(cmd == 'd')
+ {
+ cmd = 0;
+ run_l3_servo_ccw();
+ wait(1);
+ stop_servo();
+ printf("run_l3_servo_ccw\r\n");
+ }
+ if(cmd == 't')
+ {
+ cmd = 0;
+ test_limite();
+ printf("test_limite()\r\n");
+ }
+
+ if(cmd == 'h')
+ {
+ cmd=0;
+ printf("1=stop_dc_motor\n");
+ printf("2=run_l1_dc_motor_cw; 3=run_l1_dc_motor_ccw; 4=run_l1_servo_cw; 5=run_l1_servo_ccw\n");
+ printf("6=run_l2_dc_motor_cw; 7=run_l2_dc_motor_ccw; 8=run_l2_servo_cw; 9=run_l2_servo_ccw\n");
+ printf("a=run_l3_dc_motor_cw; b=run_l3_dc_motor_ccw; c=run_l3_servo_cw; d=run_l3_servo_ccw.\n");
+ }
+ }
+}
+int main()
+{
+ printf("Hello World !\n");
+ for (int i=0; i<3; i++) {
+ auto_run();
+ }
+}
--- a/main_old.txt Thu Jan 28 15:51:12 2021 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-#include "mbed.h"
-
-
-PwmOut DCMotor(D6);
-PwmOut ServoClockWise(D5);
-PwmOut ServoCounterCW(D3);
-
-DigitalOut DCMotor_IN1(D7);
-DigitalOut DCMotor_IN2(D8);
-DigitalOut ServoEnable(D4);
-
-
-
-int main()
-{
- DCMotor.period_ms(20); // shoul be 20 ms (490 Hz) and 10 ms for the servo (980 Hz)
- ServoClockWise.period_ms(10);
- ServoCounterCW.period_ms(10);
- ServoEnable=1;
-
- DCMotor_IN1=0;
- DCMotor_IN2=1;
- DCMotor.pulsewidth_us(1500);
-// wait(5);
-// DCMotor.pulsewidth_ms(0);
-
-
-
- while(0){
-
- DCMotor_IN1=0;
- DCMotor_IN2=1;
- DCMotor.pulsewidth_ms(2);
- ServoClockWise.pulsewidth_us(0);
- ServoCounterCW.pulsewidth_us(100);
- wait_ms(1000);
- ServoCounterCW.pulsewidth_us(19000);
- wait_ms(1000);
-
- DCMotor_IN1=1;
- DCMotor_IN2=0;
- DCMotor.pulsewidth_ms(10);
- ServoCounterCW.pulsewidth_us(0);
- ServoClockWise.pulsewidth_us(100);
- wait_ms(1000);
- ServoClockWise.pulsewidth_us(19000);
- wait_ms(1000);
-
- }
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test.txt Sat Feb 20 09:04:41 2021 +0000
@@ -0,0 +1,183 @@
+#include "mbed.h"
+#include "stdio.h"
+
+//DigitalOut led(LED1);
+
+Serial pc(USBTX, USBRX);
+DigitalIn my_button(USER_BUTTON); // Use the user button to switch from dc motor to servo motor and vice versa
+DigitalIn end_stop(D5); // relais fin de course
+//
+//PwmOut l1_dc_motor_en(D3);
+PwmOut l1_dc_motor_cw(D10);
+PwmOut l1_dc_motor_ccw(D11);
+//PwmOut l1_servo_en(D5);
+DigitalOut l1_servo_cw(D7);
+DigitalOut l1_servo_ccw(D8);
+
+PwmOut l2_dc_motor_en(D6);
+DigitalOut l2_dc_motor_cw(D12);
+DigitalOut l2_dc_motor_ccw(D13);
+//PwmOut l2_servo_en(D9);
+DigitalOut l2_servo_cw(D14);
+DigitalOut l2_servo_ccw(D15);
+
+void run_l1_dc_motor_cw(void){
+ l1_dc_motor_cw.period_ms(20);
+ l1_dc_motor_cw.pulsewidth_us(10000);
+}
+void run_l1_dc_motor_ccw(void){
+ l1_dc_motor_ccw.period_ms(20); // shoul be 20 ms (490 Hz) and 10 ms for the servo (980 Hz)
+ l1_dc_motor_ccw.pulsewidth_us(20000);
+}
+void run_l2_dc_motor_cw(void){
+ l2_dc_motor_en.period_ms(20); // shoul be 20 ms (490 Hz) and 10 ms for the servo (980 Hz)
+ l2_dc_motor_en.pulsewidth_us(50000);
+ l2_dc_motor_cw=0;
+ l2_dc_motor_ccw=1;
+}
+void run_l2_dc_motor_ccw(void){
+ l2_dc_motor_en.period_ms(20); // shoul be 20 ms (490 Hz) and 10 ms for the servo (980 Hz)
+ l2_dc_motor_en.pulsewidth_us(50000);
+ l2_dc_motor_cw=1;
+ l2_dc_motor_ccw=0;
+}
+
+
+void stop_dc_motor(void){
+ l1_dc_motor_cw.pulsewidth_us(0);
+ l1_dc_motor_ccw.pulsewidth_us(0);
+ l2_dc_motor_cw=0;
+ l2_dc_motor_ccw=0;
+
+}
+
+void run_l1_servo_cw(void){
+ l1_servo_cw=1;
+ l1_servo_ccw=0;
+}
+void run_l1_servo_ccw(void){
+ l1_servo_cw=0;
+ l1_servo_ccw=1;
+}
+
+void run_l2_servo_cw(void){
+ l2_servo_cw=1;
+ l2_servo_ccw=0;
+}
+void run_l2_servo_ccw(void){
+ l2_servo_cw=0;
+ l2_servo_ccw=1;
+}
+
+
+void stop_servo(void){
+ l1_servo_cw=0;
+ l1_servo_ccw=0;
+ l2_servo_cw=0;
+ l2_servo_ccw=0;
+}
+
+
+void test_limite(void){
+ end_stop.mode(PullDown);
+ while(1){
+ printf("lim=%d\n", end_stop.read());
+
+ if(end_stop.read()==1){
+ stop_dc_motor();
+// led=0;
+ printf("stop_dc_motor\n");
+ }
+ else{
+ run_l1_dc_motor_ccw();
+ printf("motor runs\n");
+// led=1;
+ }
+ }
+
+}
+
+int main()
+{
+ printf("Hello World !\n");
+ unsigned char cmd=0;
+ while (true) {
+ scanf("%c", &cmd);
+ if(cmd == '1')
+ {
+ cmd = 0;
+ stop_dc_motor();
+ printf("stop_dc_motor\r\n");
+ }
+ if(cmd == '2')
+ {
+ cmd = 0;
+ run_l1_dc_motor_cw();
+ printf("run_l1_dc_motor_cw\r\n");
+ }
+ if(cmd == '3')
+ {
+ cmd = 0;
+ run_l1_dc_motor_ccw();
+ printf("run_l1_dc_motor_ccw\r\n");
+ }
+ if(cmd == '4')
+ {
+ cmd = 0;
+ run_l1_servo_cw();
+ wait(1);
+ stop_servo();
+ printf("run_l1_servo_cw\r\n");
+ }
+ if(cmd == '5')
+ {
+ cmd = 0;
+ run_l1_servo_ccw();
+ wait(1);
+ stop_servo();
+ printf("run_l1_servo_ccw\r\n");
+ }
+ if(cmd == '6')
+ {
+ cmd = 0;
+ run_l2_dc_motor_cw();
+ printf("run_l2_dc_motor_cw\r\n");
+ }
+ if(cmd == '7')
+ {
+ cmd = 0;
+ run_l2_dc_motor_ccw();
+ printf("run_l2_dc_motor_ccw\r\n");
+ }
+ if(cmd == '8')
+ {
+ cmd = 0;
+ run_l2_servo_cw();
+ wait(1);
+ stop_servo();
+
+// l2_servo_cw=0;
+// l2_servo_ccw=0;
+ printf("run_l2_servo_cw\r\n");
+ }
+
+ if(cmd == '9')
+ {
+ cmd = 0;
+ run_l2_servo_ccw();
+ wait(1);
+ stop_servo();
+// l2_servo_cw=0;
+// l2_servo_ccw=0;
+
+ printf("run_l2_servo_ccw\r\n");
+ }
+
+
+ if(cmd == 'h')
+ {
+ cmd=0;
+ printf("1=stop_dc_motor; 2=run_l1_dc_motor_cw; 3=run_l1_dc_motor_ccw; 4=run_l1_servo_cw; 5=run_l1_servo_ccw, 6=run_l1_dc_motor_cw; 7=run_l1_dc_motor_ccw\n");
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tmp.txt Sat Feb 20 09:04:41 2021 +0000
@@ -0,0 +1,220 @@
+#include "mbed.h"
+#include "stdio.h"
+
+//DigitalOut led(LED1);
+
+Serial pc(USBTX, USBRX);
+DigitalIn my_button(USER_BUTTON); // Use the user button to switch from dc motor to servo motor and vice versa
+DigitalIn end_stop(A5); // relais fin de course
+
+PwmOut l1_dc_motor_cw(D2);
+PwmOut l1_dc_motor_ccw(D3);
+DigitalOut l1_servo_cw(D4);
+DigitalOut l1_servo_ccw(D5);
+PwmOut l2_dc_motor_cw(D6);
+PwmOut l2_dc_motor_ccw(D7);
+DigitalOut l2_servo_cw(D8);
+DigitalOut l2_servo_ccw(D9);
+PwmOut l3_dc_motor_cw(D10);
+PwmOut l3_dc_motor_ccw(D11);
+DigitalOut l3_servo_cw(D12);
+DigitalOut l3_servo_ccw(D13);
+
+void run_l1_dc_motor_cw(void){
+ l1_dc_motor_cw.period_ms(20);
+ l1_dc_motor_cw.pulsewidth_us(2500);
+}
+void run_l1_dc_motor_ccw(void){
+ l1_dc_motor_ccw.period_ms(20); // shoul be 20 ms (490 Hz) and 10 ms for the servo (980 Hz)
+ l1_dc_motor_ccw.pulsewidth_us(2500);
+}
+void run_l2_dc_motor_cw(void){
+ l2_dc_motor_cw.period_ms(20);
+ l2_dc_motor_cw.pulsewidth_us(5000);
+}
+void run_l2_dc_motor_ccw(void){
+ l2_dc_motor_ccw.period_ms(20); // shoul be 20 ms (490 Hz) and 10 ms for the servo (980 Hz)
+ l2_dc_motor_ccw.pulsewidth_us(5000);
+}
+void run_l3_dc_motor_cw(void){
+// l3_dc_motor_cw.period_ms(20);
+// l3_dc_motor_cw.pulsewidth_us(10000);
+}
+void run_l3_dc_motor_ccw(void){
+ l3_dc_motor_ccw.period_ms(20); // shoul be 20 ms (490 Hz) and 10 ms for the servo (980 Hz)
+ l3_dc_motor_ccw.pulsewidth_us(5000);
+}
+void stop_dc_motor(void){
+ l1_dc_motor_cw.pulsewidth_us(0);
+ l1_dc_motor_ccw.pulsewidth_us(0);
+ l2_dc_motor_cw.pulsewidth_us(0);
+ l2_dc_motor_ccw.pulsewidth_us(0);
+ l3_dc_motor_cw.pulsewidth_us(0);
+ l3_dc_motor_ccw.pulsewidth_us(0);
+}
+void run_l1_servo_cw(void){
+ l1_servo_cw=1;
+ l1_servo_ccw=0;
+}
+void run_l1_servo_ccw(void){
+ l1_servo_cw=0;
+ l1_servo_ccw=1;
+}
+void run_l2_servo_cw(void){
+// l2_servo_cw=1;
+// l2_servo_ccw=0;
+}
+void run_l2_servo_ccw(void){
+ l2_servo_cw=0;
+ l2_servo_ccw=1;
+}
+void run_l3_servo_cw(void){
+ l3_servo_cw=1;
+ l3_servo_ccw=0;
+}
+void run_l3_servo_ccw(void){
+ l3_servo_cw=0;
+ l3_servo_ccw=1;
+}
+void stop_servo(void){
+ l1_servo_cw=0;
+ l1_servo_ccw=0;
+ l2_servo_cw=0;
+ l2_servo_ccw=0;
+ l3_servo_cw=0;
+ l3_servo_ccw=0;
+}
+void test_limite(void){
+ end_stop.mode(PullDown);
+ while(1){
+ printf("lim=%d\n", end_stop.read());
+
+ if(end_stop.read()==1){
+ stop_dc_motor();
+// led=0;
+ printf("stop_dc_motor\n");
+ }
+ else{
+ run_l2_dc_motor_ccw();
+ printf("motor runs\n");
+// led=1;
+ }
+ }
+
+}
+int main()
+{
+ printf("Hello World !\n");
+ unsigned char cmd=0;
+ while (true) {
+ scanf("%c", &cmd);
+ if(cmd == '1')
+ {
+ cmd = 0;
+ stop_dc_motor();
+ printf("stop_dc_motor\r\n");
+ }
+ if(cmd == '2')
+ {
+ cmd = 0;
+ run_l1_dc_motor_cw();
+ printf("run_l1_dc_motor_cw\r\n");
+ }
+ if(cmd == '3')
+ {
+ cmd = 0;
+ run_l1_dc_motor_ccw();
+ printf("run_l1_dc_motor_ccw\r\n");
+ }
+ if(cmd == '4')
+ {
+ cmd = 0;
+ run_l1_servo_cw();
+ wait(1);
+ stop_servo();
+ printf("run_l1_servo_cw\r\n");
+ }
+ if(cmd == '5')
+ {
+ cmd = 0;
+ run_l1_servo_ccw();
+ wait(1);
+ stop_servo();
+ printf("run_l1_servo_ccw\r\n");
+ }
+ if(cmd == '6')
+ {
+ cmd = 0;
+ run_l2_dc_motor_cw();
+ printf("run_l2_dc_motor_cw\r\n");
+ }
+ if(cmd == '7')
+ {
+ cmd = 0;
+ run_l2_dc_motor_ccw();
+ printf("run_l2_dc_motor_ccw\r\n");
+ }
+ if(cmd == '8')
+ {
+ cmd = 0;
+ run_l2_servo_cw();
+ wait(1);
+ stop_servo();
+ printf("run_l2_servo_cw\r\n");
+ }
+ if(cmd == '9')
+ {
+ cmd = 0;
+ run_l2_servo_ccw();
+ wait(1);
+ stop_servo();
+ printf("run_l2_servo_ccw\r\n");
+ }
+
+
+
+ if(cmd == 'a')
+ {
+ cmd = 0;
+ run_l3_dc_motor_cw();
+ printf("run_l3_dc_motor_cw\r\n");
+ }
+ if(cmd == 'b')
+ {
+ cmd = 0;
+ run_l3_dc_motor_ccw();
+ printf("run_l3_dc_motor_ccw\r\n");
+ }
+ if(cmd == 'c')
+ {
+ cmd = 0;
+ run_l3_servo_cw();
+ wait(1);
+ stop_servo();
+ printf("run_l3_servo_cw\r\n");
+ }
+ if(cmd == 'd')
+ {
+ cmd = 0;
+ run_l3_servo_ccw();
+ wait(1);
+ stop_servo();
+ printf("run_l3_servo_ccw\r\n");
+ }
+ if(cmd == 't')
+ {
+ cmd = 0;
+ test_limite();
+ printf("test_limite()\r\n");
+ }
+
+ if(cmd == 'h')
+ {
+ cmd=0;
+ printf("1=stop_dc_motor\n");
+ printf("2=run_l1_dc_motor_cw; 3=run_l1_dc_motor_ccw; 4=run_l1_servo_cw; 5=run_l1_servo_ccw\n");
+ printf("6=run_l2_dc_motor_cw; 7=run_l2_dc_motor_ccw; 8=run_l2_servo_cw; 9=run_l2_servo_ccw\n");
+ printf("a=run_l3_dc_motor_cw; b=run_l3_dc_motor_ccw; c=run_l3_servo_cw; d=run_l3_servo_ccw.\n");
+ }
+ }
+}