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 MODSERIAL- mbed-dsp mbed
Diff: Project_main.cpp
- Revision:
- 27:54167d54b0c5
- Parent:
- 26:9b43d9cb1fb2
- Child:
- 28:f4b09acf78c9
--- a/Project_main.cpp Fri Oct 03 12:40:15 2014 +0000
+++ b/Project_main.cpp Fri Oct 03 13:05:50 2014 +0000
@@ -1,15 +1,20 @@
#include "mbed.h"
#include "MODSERIAL.h"
#include "HIDScope.h"
-#define TIMEB4NEXTCHOICE 2
-#define TIMEBETWEENBLINK 20
+#define TIMEB4NEXTCHOICE 1
+#define TIMEBETWEENBLINK 10
//Define objects
-AnalogIn emg0(PTB1); //Analog input
-PwmOut emgfloat(PTD4);//Float voor EMG-waarde
-PwmOut red(LED_RED); //PWM output
+AnalogIn emg0(PTB1); //Analog input biceps
+AnalogIn emg1(PTB2); //Analog input triceps NO IDEA WELKE PTB
+
+PwmOut emg_bifloat(PTD4); //Float voor EMG-waarde biceps
+PwmOut emg_trifloat(PTA4); //Float voor EMG-waarde triceps
+
+PwmOut red(LED_RED); //PWM output
PwmOut green(LED_GREEN);
PwmOut blue(LED_BLUE);
+
int direction = 0;
int force = 0;
@@ -33,19 +38,26 @@
void looper()
{
/*variable to store value in*/
- uint16_t emg_value;
+ uint16_t emg_bivalue;
/*put raw emg value both in emgfloat and in emg_value*/
- emgfloat.write(emg0.read()); // read float value (0..1 = 0..3.3V)
- emg_value = emg0.read_u16(); // read direct ADC result (0..4096 = 0..3.3V)
+ emg_bifloat.write(emg0.read()); // read float value (0..1 = 0..3.3V) biceps
+ emg_bivalue = emg0.read_u16(); // read direct ADC result (0..4096 = 0..3.3V) biceps
+
+ uint16_t emg_trivalue;
+ /*put raw emg value both in emgfloat and in emg_value*/
+ emg_trifloat.write(emg1.read()); // read float value (0..1 = 0..3.3V) biceps
+ emg_trivalue = emg1.read_u16(); // read direct ADC result (0..4096 = 0..3.3V) biceps
+
/*send value to PC. Line below is used to prevent buffer overrun */
if(pc.rxBufferGetSize(0)-pc.rxBufferGetCount() > 30)
- //pc.printf("%u\n",emg_value);
- scope.set(0,emg_value);
- scope.set(1,emgfloat.read());
+ //pc.printf("%u\n",emg_value);
+
+ scope.set(0,emg_bivalue);
+ scope.set(1,emg_bifloat.read());
+ scope.set(2,emg_trivalue);
+ scope.set(3,emg_trifloat.read());
scope.send();
- /**When not using the LED, the above could also have been done this way:
- * pc.printf("%u\n", emg0.read_u16());
- */
+
}
@@ -53,7 +65,8 @@
int main()
{
pc.baud(115200); //baudrate instellen
- emgfloat.period_ms(2); //sets period for the PWM to the emgfloat PTD4
+ emg_bifloat.period_ms(2); //sets period for the PWM to the emgfloat PTD4
+ emg_trifloat.period_ms(2);
log_timer.attach(looper, 0.001); // The looper() function will be called every 0.001 seconds (with the ticker object)
goto directionchoice; // goes to first while(1) for the deciding the direction