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 QEI HIDScope biquadFilter MODSERIAL FastPWM
Diff: main.cpp
- Revision:
- 20:4424d447f3cd
- Parent:
- 19:a37cae6964ca
- Child:
- 21:bea7c8a08e1d
diff -r a37cae6964ca -r 4424d447f3cd main.cpp
--- a/main.cpp Thu Oct 17 11:01:37 2019 +0000
+++ b/main.cpp Fri Oct 18 08:14:36 2019 +0000
@@ -2,7 +2,6 @@
To-do:
Add reference generator
fully implement schmitt trigger
- EMG normalizing
Homing
Turning the magnet on/off
Inverse kinematics
@@ -21,12 +20,13 @@
#define PI 3.14159265
Serial pc(USBTX, USBRX); //connect to pc
-HIDScope scope(3); //HIDScope instance
+HIDScope scope(1); //HIDScope instance
DigitalOut motor1_direction(D4); //rotation motor 1 on shield (always D6)
FastPWM motor1_pwm(D5); //pwm 1 on shield (always D7)
DigitalOut motor2_direction(D7); //rotation motor 2 on shield (always D4)
FastPWM motor2_pwm(D6); //pwm 2 on shield (always D5)
Ticker loop_ticker; //used in main()
+Ticker scope_ticker;
AnalogIn Pot1(A1); //pot 1 on biorobotics shield
AnalogIn Pot2(A0); //pot 2 on biorobotics shield
InterruptIn but1(D10); //debounced button on biorobotics shield
@@ -70,8 +70,8 @@
float dt = 0.001;
float theta;
float L;
-int enc1_zero = 0; //the zero position of the encoders, to be determined from the
-int enc2_zero = 0; //encoder calibration
+int enc1_zero = 0;//the zero position of the encoders, to be determined from the
+int enc2_zero = 0;//encoder calibration
int EMG1_filtered;
int EMG2_filtered;
int enc1_value;
@@ -292,6 +292,8 @@
motor2_direction = actuator.dir2;
motor1_pwm.write(actuator.duty_cycle1);
motor2_pwm.write(actuator.duty_cycle2);
+
+ scope.set(0, EMG1_filtered);
}
void state_machine()
@@ -385,6 +387,7 @@
but1.fall(&but1_interrupt);
but2.fall(&but2_interrupt);
+ scope_ticker.attach(&scope, &HIDScope::send, 0.02);
loop_ticker.attach(&main_loop, dt); //main loop at 1kHz
pc.printf("Main_loop is running\n\r");
while (true) {