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.
Dependencies: mbed M3_CAN_mbed
Diff: main.cpp
- Revision:
- 0:4134d186d76d
- Child:
- 1:fca866f76ca0
diff -r 000000000000 -r 4134d186d76d main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Thu Dec 13 13:38:35 2018 +0000
@@ -0,0 +1,72 @@
+#include "mbed.h"
+#include "Usart.h"
+
+//PwmOut led(LED1);
+
+Serial Nin(PC_10,PC_11);
+Serial pc(SERIAL_TX, SERIAL_RX);
+
+/*
+AnalogIn f0(PA_0);
+AnalogIn f1(PA_1);
+AnalogIn f2(PA_4);
+AnalogIn f3(PB_0);
+AnalogIn f4(PC_1);
+*/
+
+///M3_USART m3(PA_9,PA_10,115200);
+//Serial pc(USBTX,USBRX);
+//DigitalOut myled(LED1);
+///DigitalIn myb(USER_BUTTON);
+
+int main()
+{
+ //float k=0.5;
+ //int32_t a=0;
+ //uint8_t error;
+ //Nex.baud(9600);
+ //Nex.format(8,Serial::None,2);
+ float force[5];
+ char tmp[5];
+ //led.period_ms(10);
+
+ //m3.write(RG_SOFT_SRV,RG_DEFAULT, 0);
+ //wait(1);
+/// m3.write(RG_SOFT_SRV,RG_DEFAULT, 1);
+/// m3.write(RG_PGAIN,RG_POSITION,2500);
+/// m3.write(RG_IGAIN,RG_POSITION,0);
+/// m3.write(RG_DGAIN,RG_POSITION,1000);
+
+
+ while(1){
+ for(int j = 0; j <= 4; j++){
+ for(int i = 0;i <= 4; i++){
+ tmp[i] = Nin.getc();
+ }
+ force[j] = atof(tmp);
+ }
+
+ //duty_m = f0;
+ //pc.printf("Duty_m:%.3f\r\n",duty_m);
+ //pc.printf("Duty:%.3f\r\n",duty);
+ //led.write(duty);
+
+ pc.printf("%.3f, %.3f, %.3f, %.3f, %.3f\r\n"
+ ,force[0],force[1],force[2],force[3],force[4]);
+
+ //diff = duty_m-duty;
+
+/* a+=(int32_t)(30000*diff);
+
+
+ if(a>300000)a=300000;
+ else if(a<0)a=0;
+
+ m3.write(RG_REFERENCE,RG_POSITION,a*(-1));
+ pc.printf("Stroke:%ld mm\n\r",a*2/36000);*/
+
+
+ //wait(0.001);
+ }
+}
+