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: HIDScope Servo mbed QEI biquadFilter
Diff: main.cpp
- Revision:
- 0:cb8857cf3ea4
- Child:
- 1:1a8211e1f3f3
- Child:
- 2:4b9c67f44848
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Oct 19 12:32:35 2018 +0000 @@ -0,0 +1,83 @@ +#include "mbed.h" +#include "HIDScope" // For displaying data +#include "FastPWM" // For setting PWM for motor +#include "MODSERIAL" // For getting information from keyboard +#include "QEI" // For encoder of motors + +// In- en outputs // +//------------------------------------------------------------- + +// EMG related +AnalogIn emg1(A0); // EMG signal 1 +AnalogIn emg2(A1); // EMG signal 2 +/* if needed +AnalogIn emg3(A0); // EMG signal 3 +AnalogIn emg4(A1); // EMG signal 4 +*/ + +// Motor related +DigitalOut dirpin_1(D4); // direction of motor 1 +PwmOut pwmpin_1(D5); // PWM pin of motor 1 +DigitalOut dirpin_2(D6); // direction of motor 2 +PwmOut pwmpin_2(D7); // PWM pin of motor 2 + +// Extra stuff +// Like LED lights, buttons etc + +// Other stuff +// ------------------------------------------------------------ +// Define stuff like tickers etc + +Ticker NAME; // Name a ticker, use each ticker only for 1 function! +HIDScope scope(2); // Number of channels in HIDScope +QEI Encoder(D13,D12,NC,64,QEI::X4_ENCODING); // Define the type of encoding: X4 encoding(default is X2) +MODSERIAL pc(USBTX,USBRX); + +// Variables +// ------------------------------------------------------------ +// Define here all variables needed throughout the whole code + +// Functions +// ------------------------------------------------------------ + +// Motor calibration +// To calibrate the motor angle to some mechanical boundaries + +// EMG calibration +// To calibrate the EMG signal to some boundary values + +// Send EMG to HIDScope +void sample() // attach this to a ticker! +{ + scope.set(0, emg1.read()); // send EMG 1 to channel 1 (=0) + scope.set(1, emg2.read()); // sent EMG 2 to channel 2 (=1) + /* If needed + scope.set(2, emg3.read()); // send EMG 3 to channel 3 (=2) + scope.set(3, emg4.read()); // sent EMG 4 to channel 4 (=3) + */ + // Ensure that enough channels are available (HIDScope scope( 2 )) + scope.send(); // Send all channels to the PC at once +} + +// Start +// To move the robot to the starting position: middle + +// Operating mode +// To control the robot with EMG signals + +// Processing EMG +// To process the raw EMG to a usable value, with filters etc + +// Demo mode +// To control the robot with a written code and write 'HELLO' + +// Emergency mode +// To shut down the robot after an error etc + +// Main function +// ------------------------------------------------------------ +int main() +{ + pc.baud(115200); // For TeraTerm, the baudrate, set also in TeraTerm itself! + pc.printf("Start code\r\n"); // To check if the program starts +} \ No newline at end of file