Difference between revisions of "Team Avengers"

From Hackteria Wiki
Jump to: navigation, search
(Code)
(Code)
Line 57: Line 57:
 
<code>
 
<code>
 
/*
 
/*
  * ----------------------------------------------------------------------------------------------------
+
* ----------------------------------------------------------------------------------------------------
  * Backyard Brains 2015
+
* Backyard Brains 2015
  * Muscle SpikerShield Arduino UNO Code for Human-Human-Interface
+
* Muscle SpikerShield Arduino UNO Code for Human-Human-Interface
  *
+
*
  * Code monitors amplitude of EMG envelope, displays EMG strength on LED bar and controls  
+
* Code monitors amplitude of EMG envelope, displays EMG strength on LED bar and controls  
  * relay that turns on/off a TENS (Transcutaneous Electrical Nerve Stimulation) device.
+
* relay that turns on/off a TENS (Transcutaneous Electrical Nerve Stimulation) device.
  *  
+
*  
  * V1.0
+
* V1.0
  * Written by Marcio Amorim
+
* Written by Marcio Amorim
  * Updated by Stanislav Mircic
+
* Updated by Stanislav Mircic
  *
+
*
  * Tested with Muscle SpikerShield V2.31
+
* Tested with Muscle SpikerShield V2.31
  * ----------------------------------------------------------------------------------------------------
+
* ----------------------------------------------------------------------------------------------------
  */   
+
*/   
 
    
 
    
  #define RELAY_PIN 3                        //pin for relay that controls TENS device
+
#define RELAY_PIN 3                        //pin for relay that controls TENS device
  #define SENSITIVITY_BUTTON_PIN 7            //pin for button that selects sesitivity
+
#define SENSITIVITY_BUTTON_PIN 7            //pin for button that selects sesitivity
  #define NUM_LED 6                          //number of LEDs in LED bar
+
#define NUM_LED 6                          //number of LEDs in LED bar
  #define RELAY_THRESHOLD 4                  //defines sensitivity of relay
+
#define RELAY_THRESHOLD 4                  //defines sensitivity of relay
  
  byte ledPins[] = {8, 9, 10, 11, 12, 13};    //pins for LEDs in LED bar
+
byte ledPins[] = {8, 9, 10, 11, 12, 13};    //pins for LEDs in LED bar
 +
 +
//EMG saturation values (when EMG reaches this value the TENS relay will be activated)
 +
int sensitivities[] = {200, 350, 520, 680, 840, 1000};
 +
int lastSensitivitiesIndex = 2;            //set initial sensitivity index
 
    
 
    
  //EMG saturation values (when EMG reaches this value the TENS relay will be activated)
+
int emgSaturationValue = 0;                //selected sensitivity/EMG saturation value
  int sensitivities[] = {200, 350, 520, 680, 840, 1000};
+
int analogReadings;                        //measured value for EMG
  int lastSensitivitiesIndex = 2;            //set initial sensitivity index
+
byte ledbarHeight = 0;                      //temporary variable for led bar height
 
 
  int emgSaturationValue = 0;                //selected sensitivity/EMG saturation value
 
  int analogReadings;                        //measured value for EMG
 
  byte ledbarHeight = 0;                      //temporary variable for led bar height
 
  
  
  //-----------------------------------------------------------------------------------
+
//-----------------------------------------------------------------------------------
  //  Setup inputs and outputs
+
//  Setup inputs and outputs
  // ----------------------------------------------------------------------------------
+
// ----------------------------------------------------------------------------------
  void setup(){
+
void setup(){
  
    //init button pin to input                                 
+
  //init button pin to input                                 
    pinMode(SENSITIVITY_BUTTON_PIN, INPUT);  
+
  pinMode(SENSITIVITY_BUTTON_PIN, INPUT);  
    //init relay pin to output     
+
  //init relay pin to output     
    pinMode(RELAY_PIN, OUTPUT);  
+
  pinMode(RELAY_PIN, OUTPUT);  
    digitalWrite(RELAY_PIN, LOW);
+
  digitalWrite(RELAY_PIN, LOW);
    //initialize all LED pins to output
+
  //initialize all LED pins to output
    for(int i = 0; i < NUM_LED; i++){  
+
  for(int i = 0; i < NUM_LED; i++){  
      pinMode(ledPins[i], OUTPUT);
+
    pinMode(ledPins[i], OUTPUT);
    }
 
   
 
    //get current sensitivity
 
    emgSaturationValue = sensitivities[lastSensitivitiesIndex];
 
 
   }
 
   }
 +
 
 +
  //get current sensitivity
 +
  emgSaturationValue = sensitivities[lastSensitivitiesIndex];
 +
}
  
 
+
//-----------------------------------------------------------------------------------
 
+
//  Main loop
  //-----------------------------------------------------------------------------------
+
//
  //  Main loop
+
//  - Checks state of sesitivity button
  //
+
//  - Measure EMG
  //  - Checks state of sesitivity button
+
//  - Shows EMG strength on LED bar
  //  - Measure EMG
+
//  - Turns ON or OFF the relay for TENS device
  //  - Shows EMG strength on LED bar
+
// ----------------------------------------------------------------------------------
  //  - Turns ON or OFF the relay for TENS device
+
void loop()
  // ----------------------------------------------------------------------------------
+
{
  void loop()
 
  {
 
 
    
 
    
        //-----------------------  Switch sensitivity ------------------------------------
+
      //-----------------------  Switch sensitivity ------------------------------------
 
      
 
      
        //check if button is pressed (HIGH)
+
      //check if button is pressed (HIGH)
        if (digitalRead(SENSITIVITY_BUTTON_PIN))
+
      if (digitalRead(SENSITIVITY_BUTTON_PIN))
        {  
+
      {  
            //turn off all the LEDs in LED bar
+
          //turn off all the LEDs in LED bar
            for(int j = 0; j < NUM_LED; j++)
+
          for(int j = 0; j < NUM_LED; j++)
            {   
+
          {   
              digitalWrite(ledPins[j], LOW);
+
            digitalWrite(ledPins[j], LOW);
            }
+
          }
 
            
 
            
            //increment sensitivity index
+
          //increment sensitivity index
            lastSensitivitiesIndex++;
+
          lastSensitivitiesIndex++;
            if(lastSensitivitiesIndex==NUM_LED)
+
          if(lastSensitivitiesIndex==NUM_LED)
            {
+
          {
              lastSensitivitiesIndex = 0;
+
            lastSensitivitiesIndex = 0;
            }
+
          }
 
            
 
            
            //get current sensitivity value
+
          //get current sensitivity value
            emgSaturationValue = sensitivities[lastSensitivitiesIndex];  
+
          emgSaturationValue = sensitivities[lastSensitivitiesIndex];  
 
              
 
              
            //light up LED at lastSensitivitiesIndex position for visual feedback
+
          //light up LED at lastSensitivitiesIndex position for visual feedback
            digitalWrite(ledPins[lastSensitivitiesIndex], HIGH);
+
          digitalWrite(ledPins[lastSensitivitiesIndex], HIGH);
 
            
 
            
            //wait user to release button
+
          //wait user to release button
            while (digitalRead(SENSITIVITY_BUTTON_PIN))  
+
          while (digitalRead(SENSITIVITY_BUTTON_PIN))  
            {   
+
          {   
              delay(10);
+
            delay(10);
            }       
+
          }       
            //whait a bit more so that LED light feedback is always visible
+
          //whait a bit more so that LED light feedback is always visible
            delay(100);         
+
          delay(100);         
        }
+
      }
 
          
 
          
  
        //-----------------------------  Measure EMG -----------------------------------------------
+
      //-----------------------------  Measure EMG -----------------------------------------------
 
      
 
      
        analogReadings = analogRead(A0);//read EMG value from analog input A0
+
      analogReadings = analogRead(A0);//read EMG value from analog input A0
 
          
 
          
 
          
 
          
        //---------------------- Show EMG strength on LED ------------------------------------------
+
      //---------------------- Show EMG strength on LED ------------------------------------------
 
          
 
          
        //turn OFF all LEDs on LED bar
+
      //turn OFF all LEDs on LED bar
        for(int j = 0; j < NUM_LED; j++)
+
      for(int j = 0; j < NUM_LED; j++)
        {   
+
      {   
          digitalWrite(ledPins[j], LOW);
+
        digitalWrite(ledPins[j], LOW);
        }
+
      }
 
          
 
          
        //calculate what LEDs should be turned ON on the LED bar
+
      //calculate what LEDs should be turned ON on the LED bar
        analogReadings= constrain(analogReadings, 30, emgSaturationValue);
+
      analogReadings= constrain(analogReadings, 30, emgSaturationValue);
        ledbarHeight = map(analogReadings, 30, emgSaturationValue, 0, NUM_LED);
+
      ledbarHeight = map(analogReadings, 30, emgSaturationValue, 0, NUM_LED);
 
          
 
          
        //turn ON LEDs on the LED bar
+
      //turn ON LEDs on the LED bar
        for(int k = 0; k < ledbarHeight; k++)
+
      for(int k = 0; k < ledbarHeight; k++)
        {
+
      {
          digitalWrite(ledPins[k], HIGH);
+
        digitalWrite(ledPins[k], HIGH);
        }
+
      }
 
          
 
          
 
          
 
          
        //----------------------- Turn ON/OFF relay for TENS ---------------------------------------
+
      //----------------------- Turn ON/OFF relay for TENS ---------------------------------------
 
          
 
          
        //Turn ON relay if EMG is greater than threshold value
+
      //Turn ON relay if EMG is greater than threshold value
        //(threshold is expressed in LED bar height units)
+
      //(threshold is expressed in LED bar height units)
        if(ledbarHeight>RELAY_THRESHOLD)
+
      if(ledbarHeight>RELAY_THRESHOLD)
        {
+
      {
          digitalWrite(RELAY_PIN, HIGH);
+
        digitalWrite(RELAY_PIN, HIGH);
          delay(50);
+
        delay(50);
        }
+
      }
        else
+
      else
        {
+
      {
          digitalWrite(RELAY_PIN, LOW);
+
        digitalWrite(RELAY_PIN, LOW);
        }
+
      }
 
}
 
}
 
</code>
 
</code>
  
 
==== Resultat ====
 
==== Resultat ====

Revision as of 16:17, 7 February 2022


Einleitung

Herzlich willkommen auf der offiziellen Seite vom Team "Avengers". Auf dieser Seite werden die Ergebnisse der Blockwoche "Medtech DIY 2022" vorgestellt. Die Daten unserer Projekte werden hier zur Verfügung gestellt, wenn man diese nachbauen möchte.

Team

  • Sabrina
  • Sarah
  • Noel
  • Pascal

Reflektion Readings

Articles

SATW Publication 2015

In Bezug auf die SATW-Publikation eröffnen "Do-it-yourself"-Strategien ein Wissensgebiet, das traditionell von Experten besetzt war. Garagenlaboratorien mit Waagen, Mischern, Kühlschränken und Brutschränken sind im Kommen. DIY-Biologen bauen aus Einzelteilen Labormaterialien wie Spektrometer. Im Internet findet jeder eine Anleitung, wie man aus einer Webcam für ein paar Euro ein Mikroskop bauen kann. Billige, hochmoderne Geräte, die für den Massenmarkt produziert werden, können für neue Funktionen mit Laborfähigkeiten modifiziert werden. Die Strategie des "Hacking" ist ein wesentlicher Bestandteil dieses Prozesses.

MCD #68

Videos

Greg Gage Ted

In diesem Video demonstriert Greg Gage seine Technologie zur Messung und Weiterleitung von Elektrischen Signalen in Motorischen Endplatten von menschlichen Muskeln. Dabei werden mit Elektroden an Versuchsperson Nummer 1 die Muskelsignale gemessen, und über einen Verstärker an Versuchsperson 2 weitergeleitet. Dabei werden bei Versuchsperson 2 die Muskeln stimuliert, welche von Versuchsperson 1 aktiviert wurden. Dadurch entstehen bei Versuchsperson 2 die gleichen Bewegungen wie bei Versuchsperson 1, einfach ohne dass diese dies kontrollieren kann.

Open Source Lego

Arduino

Hacks

Hack 0: Muscle Shield

Als Erster Hack wird in diesem Modul ein Kit zur Erkennung von Muskelströmungen zusammengebaut.

Teile

Parts Muscle Shield.jpeg

Instruktionen

Die Anleitung zum Zusammenbau dieses Kits sind vom Kit-Hersteller auf dessen Seite zur Verfügung gestellt. Die korrekte Version ist untenstehend verlinkt. Das Kit selbst ist auch verlinkt.

Kit

Muscle Shield Instruction v2.11

Prozess

Soldering.jpeg

Top down view.jpeg

Code

Dieser Code wird für das Kit verwendet. Er wird ebenfalls vom Hersteller zur Verfügung gestellt.

/*

  • ----------------------------------------------------------------------------------------------------
  • Backyard Brains 2015
  • Muscle SpikerShield Arduino UNO Code for Human-Human-Interface
  • Code monitors amplitude of EMG envelope, displays EMG strength on LED bar and controls
  • relay that turns on/off a TENS (Transcutaneous Electrical Nerve Stimulation) device.
  • V1.0
  • Written by Marcio Amorim
  • Updated by Stanislav Mircic
  • Tested with Muscle SpikerShield V2.31
  • ----------------------------------------------------------------------------------------------------
  • /
  1. define RELAY_PIN 3 //pin for relay that controls TENS device
  2. define SENSITIVITY_BUTTON_PIN 7 //pin for button that selects sesitivity
  3. define NUM_LED 6 //number of LEDs in LED bar
  4. define RELAY_THRESHOLD 4 //defines sensitivity of relay

byte ledPins[] = {8, 9, 10, 11, 12, 13}; //pins for LEDs in LED bar

//EMG saturation values (when EMG reaches this value the TENS relay will be activated) int sensitivities[] = {200, 350, 520, 680, 840, 1000}; int lastSensitivitiesIndex = 2; //set initial sensitivity index

int emgSaturationValue = 0; //selected sensitivity/EMG saturation value int analogReadings; //measured value for EMG byte ledbarHeight = 0; //temporary variable for led bar height


//----------------------------------------------------------------------------------- // Setup inputs and outputs // ---------------------------------------------------------------------------------- void setup(){

 //init button pin to input                                
 pinMode(SENSITIVITY_BUTTON_PIN, INPUT); 
 //init relay pin to output    
 pinMode(RELAY_PIN, OUTPUT); 
 digitalWrite(RELAY_PIN, LOW);
 //initialize all LED pins to output
 for(int i = 0; i < NUM_LED; i++){ 
   pinMode(ledPins[i], OUTPUT);
 }
 
 //get current sensitivity
 emgSaturationValue = sensitivities[lastSensitivitiesIndex];

}

//----------------------------------------------------------------------------------- // Main loop // // - Checks state of sesitivity button // - Measure EMG // - Shows EMG strength on LED bar // - Turns ON or OFF the relay for TENS device // ---------------------------------------------------------------------------------- void loop() {

     //-----------------------  Switch sensitivity ------------------------------------
   
     //check if button is pressed (HIGH)
     if (digitalRead(SENSITIVITY_BUTTON_PIN))
     { 
         //turn off all the LEDs in LED bar
         for(int j = 0; j < NUM_LED; j++)
         {  
           digitalWrite(ledPins[j], LOW);
         }
         
         //increment sensitivity index
         lastSensitivitiesIndex++;
         if(lastSensitivitiesIndex==NUM_LED)
         {
           lastSensitivitiesIndex = 0;
         }
         
         //get current sensitivity value
         emgSaturationValue = sensitivities[lastSensitivitiesIndex]; 
           
         //light up LED at lastSensitivitiesIndex position for visual feedback
         digitalWrite(ledPins[lastSensitivitiesIndex], HIGH);
          
         //wait user to release button
         while (digitalRead(SENSITIVITY_BUTTON_PIN)) 
         {  
           delay(10);
         }       
         //whait a bit more so that LED light feedback is always visible
         delay(100);        
     }
       
     //-----------------------------  Measure EMG -----------------------------------------------
   
     analogReadings = analogRead(A0);//read EMG value from analog input A0
       
       
     //---------------------- Show EMG strength on LED ------------------------------------------
       
     //turn OFF all LEDs on LED bar
     for(int j = 0; j < NUM_LED; j++)
     {  
       digitalWrite(ledPins[j], LOW);
     }
        
     //calculate what LEDs should be turned ON on the LED bar
     analogReadings= constrain(analogReadings, 30, emgSaturationValue);
     ledbarHeight = map(analogReadings, 30, emgSaturationValue, 0, NUM_LED);
       
     //turn ON LEDs on the LED bar
     for(int k = 0; k < ledbarHeight; k++)
     {
       digitalWrite(ledPins[k], HIGH);
     }
       
       
     //----------------------- Turn ON/OFF relay for TENS ---------------------------------------
       
     //Turn ON relay if EMG is greater than threshold value
     //(threshold is expressed in LED bar height units)
     if(ledbarHeight>RELAY_THRESHOLD)
     {
       digitalWrite(RELAY_PIN, HIGH);
       delay(50);
     }
     else
     {
       digitalWrite(RELAY_PIN, LOW);
     }

}

Resultat