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:
- 30:5e5098b0cca6
- Parent:
- 29:7523e4a8e000
- Child:
- 31:d8eaf0ce8517
diff -r 7523e4a8e000 -r 5e5098b0cca6 Project_main.cpp
--- a/Project_main.cpp Mon Oct 06 12:42:02 2014 +0000
+++ b/Project_main.cpp Mon Oct 06 13:21:55 2014 +0000
@@ -20,6 +20,7 @@
int force = 0;
Ticker log_timer;
+Ticker reset_timer;
MODSERIAL pc(USBTX,USBRX);
HIDScope scope(4);
@@ -35,9 +36,9 @@
uint16_t emg_trivalue;
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 */ //VRAAG: praktisch nut hiervan? behalve dat het een heleboel spul uitprint
- if(pc.rxBufferGetSize(0)-pc.rxBufferGetCount() > 30) {
- //pc.printf("%u\n",emg_value);
+ /*send value to PC. Line below is used to prevent buffer overrun */
+ if(pc.rxBufferGetSize(0)-pc.rxBufferGetCount() > 30) { //VRAAG: praktisch nut hiervan? print emg value wanneer buffercount groter dan 30 is
+ //pc.printf("%u\n",emg_bivalue);
}
scope.set(0,emg_bivalue);
scope.set(1,emg_bifloat.read());
@@ -46,12 +47,21 @@
scope.send();
}
+void resetlooper(){
+ if(emg_trifloat.read()>0.8 && direction != 0) { //dit is alleen mogelijk wanneer directionchoice is gemaakt
+ direction = 0;
+ force = 0; // WEGHALEN, wanneer in uiteindelijke script na force keuzen niet meer gereset kan worden (voor nu wel handig)
+ goto directionchoice;
+ }
+}
+
int main()
{
pc.baud(115200); //baudrate instellen
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)
+ reset_timer.attach(resetlooper, 0.1); //
goto directionchoice; // goes to first while(1) for the deciding the direction