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.
Diff: global.cpp
- Revision:
- 0:ae5d19a716e1
diff -r 000000000000 -r ae5d19a716e1 global.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/global.cpp Wed Mar 05 05:17:45 2014 +0000
@@ -0,0 +1,114 @@
+/* global.cpp */
+
+#include "global.h"
+
+/**
+ * Classes
+ */
+PwmOut mortar_A(p21); //aori
+PwmOut mortar_U(p22); //UFO up down
+PwmOut mortar_M(p23); //merry-go-round
+PwmOut mortar_S(p24); //yosou
+
+DigitalOut UFO(p6); //UFO ON:close, OFF:open
+DigitalOut RISE1(p5); //rise
+DigitalOut RISE2(p7);
+DigitalOut RISE3(p8);
+
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+DigitalOut led3(LED3);
+DigitalOut led4(LED4);
+
+DigitalIn MS_A(p20); //microswitch
+DigitalIn MS_U(p19);
+DigitalIn MS_M(p18);
+DigitalIn MS_S(p17);
+
+QEI hight(p29, p30, NC, 100);
+
+Serial pc(USBTX, USBRX); //serialport
+
+/**
+ * Parameters
+ */
+double duty_A=0.13, dutyr_A=0.42, dutyu_U=0.30, dutyd_U=0.65, duty_M=0.30, dutyr_M=0.70, duty_S=0.40, dutyr_S=0.60;
+double speed[4] = {STOP, STOP, STOP, STOP};
+double wait_A=0.45, wait_U=0.2, wait_M=0.2, wait_S=0.15;
+
+bool STOP_STATUS=true; //false:stop
+
+/**
+ * Functions
+ */
+void led_all(int s){
+ if ( s==ON ){
+ led1=led2=led3=led4=ON;
+ }
+ else if ( s==OFF ) {
+ led1=led2=led3=led4=OFF;
+ }
+}
+
+void setspeed( double t_speed, int x ) {
+ double step, waittime;
+ if(speed[x]<t_speed) {
+ while (speed[x]<t_speed) {
+ if(t_speed-speed[x]>0.05) step = 0.05;
+ else step = 0.01;
+ speed[x]+=step;
+ switch(x) {
+ case _A_:
+ waittime = wait_A;
+ mortar_A = speed[x];
+ break;
+ case _U_:
+ waittime = wait_U;
+ mortar_U = speed[x];
+ break;
+ case _M_:
+ waittime = wait_M;
+ mortar_M = speed[x];
+ break;
+ case _S_:
+ waittime = wait_S;
+ mortar_S = speed[x];
+ break;
+ }
+ wait(waittime);
+ }
+ }
+ else {
+ while(speed[x]>t_speed) {
+ if(speed[x]-t_speed>0.05) step = 0.05;
+ else step = 0.01;
+ speed[x]-=step;
+ switch(x) {
+ case _A_:
+ waittime = wait_A;
+ mortar_A = speed[x];
+ break;
+ case _U_:
+ waittime = wait_U;
+ mortar_U = speed[x];
+ break;
+ case _M_:
+ waittime = wait_M;
+ mortar_M = speed[x];
+ break;
+ case _S_:
+ waittime = wait_S;
+ mortar_S = speed[x];
+ break;
+ }
+ wait(waittime);
+ }
+ }
+}
+
+void ALLSTOP() {
+ setspeed(STOP, _A_);
+ setspeed(STOP, _U_);
+ setspeed(STOP, _M_);
+ setspeed(STOP, _S_);
+}