EmbDev.net

Forum: µC & Digital Electronics Strain gauge based on Arduino


von Cliff W. (cliff)


Attached files:

Rate this post
useful
not useful
The strain assessment instrument is used to assess the degree of 
corresponding muscle strain by obtaining the muscle surface action 
potential through silver oxide electrodes or other human surface 
electrodes, together with the patient's conscious control of muscle 
movements. The highest level of muscle strain is 7 and the lowest level 
is 1. Level 1 is a mild condition, followed by levels 2, 3, 4, and 5, 
and levels 6 and 7 are severe conditions. This project uses the serial 
touch screen animation to display the evaluation process, and the end of 
the evaluation will give the level of the proposed treatment plan 
display. The accessories are as follows.

1, STONE 5.6" serial touch screen and adapter board V1.2.
2, electrodes, electrode wires.
3, Arduino EMG feedback module.

The result demonstration is shown in the attached image.

von Cliff W. (cliff)


Rate this post
useful
not useful
1
//EMG assess is testing for people. 
2
// by Frank 20210326.
3
//
4
#include <Servo.h>  
5
int pos = 0;    // variable to store the servo position 
6
int inDelay = 0;
7
String inString = "";    // String buffer
8
// Pin 13 has an LED connected on most Arduino boards.
9
// give it a name:
10
int led = 13;       // in pcba
11
int led2 = 12;       // yellow
12
int led3 = 11;       // red
13
int ipage = 1;         //  Pointer buffer 1-7
14
int ipage0;            //  Pointer buffer 1-7
15
int ipage2;            //  Pointer buffer 1-7
16
int biaozhi = 0;  // 1 = begin, 0 = stop. 
17
int threeok;      // 3 = trun to reslut page  and biaozhi zero,
18
int dataMuscle = 0;   // The muscle data of testing.
19
void setup() 
20
{ 
21
   pinMode(led, OUTPUT);        // initialize the digital pin as an output.  
22
  pinMode(led2, OUTPUT);        // initialize the digital pin as an output.  
23
  pinMode(led3, OUTPUT);        // initialize the digital pin as an output.
24
  Serial.begin(9600);  // Open the serial communication function and wait for the serial port to open
25
  while (!Serial) {
26
    ; // wait for serial port to connect. Needed for Leonardo only
27
  }  
28
}   
29
void loop() 
30
{ 
31
  int inChar;
32
  if(inDelay == 0){  
33
       inDelay = 1;                //RTC is only once! 
34
      //-------------------------RTC--------------------------
35
        Serial.write(0xA5);       //"A5" is 165
36
        Serial.write(0x5A);       //"5A" is 90
37
        Serial.write(0x0A);
38
        Serial.write(0x80);
39
        Serial.write(0x1F);
40
        Serial.write(0x5A); 
41
        Serial.write(0x21);    
42
        Serial.write(0x03);      
43
        Serial.write(0x26);            // 3 month 26 day
44
        Serial.write(0x05);            // friday
45
        Serial.write(0x11);
46
        Serial.write(0x08);   
47
        Serial.write(0x57);           // 11:08:57
48
      //---------------------------------------------------  
49
  }
50
  // Read the information sent by the serial port:
51
  if (Serial.available() > 0)   {    inChar = Serial.read();  }
52
  /* begin key is biaozhi = 1 ! */
53
  if ((inChar == 0x61)&&(biaozhi == 0)) {        // 0x0061 is the begin key !
54
     biaozhi = 1;
55
     threeok = 0;
56
     dataMuscle = random(1,7);            //shui ji shu (1-7)   ,it is the result num!
57
     ipage2 = 0;
58
     ipage3 = 0;
59
  }
60
  /*-------------------------------------EMG assess begin------------------------------*/
61
  if(biaozhi == 1)     // begin EMG assess testing!
62
  {
63
     digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level) 
64
    //------------------------------------------1------------------------------------------   
65
     if (ipage < 7)            // only begin look each page!
66
     {
67
         for(ipage0 = ipage; ipage0 < 7; ipage0 += 1)      // Num 1+
68
        {
69
              // variable Icon + 1
70
            Serial.write(0xA5);       //"A5" is 165
71
            Serial.write(0x5A);       //"5A" is 90
72
            Serial.write(0x05);
73
            Serial.write(0x82);
74
            Serial.write(0x03);
75
            Serial.write(0x00);
76
            Serial.write(0x00);
77
            Serial.write(ipage0);    // 0-7 page all can look!      
78
            delay(600);              // waits 0.6s            
79
            if((ipage0 == (dataMuscle + 1))&&(ipage2 == 0)){
80
              ipage2 = 1;
81
              ipage0 -= 2;
82
            }
83
        }
84
        ipage = 7;
85
        ipage2 = 0;         
86
        digitalWrite(led3, HIGH);   // turn the LED on (HIGH is the voltage level)   
87
        for(ipage0 = ipage; ipage0 > 0; ipage0 -= 1)  // Num 1-
88
        {
89
          Serial.write(0xA5);       //"A5" is 165
90
          Serial.write(0x5A);       //"5A" is 90
91
          Serial.write(0x05);
92
          Serial.write(0x82);
93
          Serial.write(0x03);
94
          Serial.write(0x00);
95
          Serial.write(0x00);
96
          Serial.write(ipage0);    // 01-7 page all can look!          
97
          delay(900);              // waits 0.9s          
98
          if((ipage0 == (dataMuscle - 1))&&(ipage2 == 0)){
99
              ipage2 = 1;
100
              ipage0 += 2;
101
          }
102
        }
103
        ipage = 1;
104
        ipage2 = 0;
105
   }
106
    threeok = 1;       
107
    //----------------------------------------2------------------------------------------
108
       digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
109
     digitalWrite(led2, HIGH);    // turn the LED off by making the voltage LOW
110
     digitalWrite(led3, LOW);    // turn the LED off by making the voltage LOW
111
       if (ipage < 7)            // only begin look each page!
112
   {
113
     for(ipage0 = ipage; ipage0 < 7; ipage0 += 1)      // Num 1+
114
      {
115
              // variable Icon + 1
116
        Serial.write(0xA5);       //"A5" is 165
117
        Serial.write(0x5A);       //"5A" is 90
118
        Serial.write(0x05);
119
        Serial.write(0x82);
120
        Serial.write(0x03);
121
        Serial.write(0x00);
122
        Serial.write(0x00);
123
        Serial.write(ipage0);    // 1-7 page all can look!        
124
        delay(500);              // waits 0.6s
125
        if((ipage0 == (dataMuscle + 1))&&(ipage2 == 0)){
126
           ipage2 = 1;
127
           ipage0 -= 2;
128
         }       
129
      }
130
      ipage = 7;
131
      ipage2 = 0;        
132
      digitalWrite(led3, HIGH);   // turn the LED on (HIGH is the voltage level)   
133
      for(ipage0 = ipage; ipage0 > 0; ipage0 -= 1)  // Num 1-
134
      {
135
        Serial.write(0xA5);       //"A5" is 165
136
        Serial.write(0x5A);       //"5A" is 90
137
        Serial.write(0x05);
138
        Serial.write(0x82);
139
        Serial.write(0x03);
140
        Serial.write(0x00);
141
        Serial.write(0x00);
142
        Serial.write(ipage0);    // 0-7 page all can look!        
143
        delay(800);              // waits 0.9s
144
        if((ipage0 == (dataMuscle - 1))&&(ipage2 == 0)){
145
            ipage2 = 1;
146
            ipage0 += 2;
147
        }
148
      }
149
      ipage = 1;
150
      ipage2 = 0;
151
   }
152
    threeok = 2;      
153
    //------------------------------------------3------------------------------------------
154
        digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
155
     digitalWrite(led2, LOW);    // turn the LED off by making the voltage LOW
156
     digitalWrite(led3, HIGH);    // turn the LED off by making the voltage LOW
157
   if (ipage < 7)            // only begin look each page!
158
   {
159
     for(ipage0 = ipage; ipage0 < 7; ipage0 += 1)      // Num 1+
160
      {
161
              // variable Icon + 1
162
        Serial.write(0xA5);       //"A5" is 165
163
        Serial.write(0x5A);       //"5A" is 90
164
        Serial.write(0x05);
165
        Serial.write(0x82);
166
        Serial.write(0x03);
167
        Serial.write(0x00);
168
        Serial.write(0x00);
169
        Serial.write(ipage0);    // 0-7 page all can look!
170
        delay(300);              // waits 0.6s
171
        if((ipage0 == (dataMuscle + 1))&&(ipage2 == 0)){
172
            ipage2 = 1;
173
            ipage0 -= 2;
174
        }   
175
      }
176
      ipage = 7;
177
      ipage2 = 0;   
178
      digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)   
179
      for(ipage0 = ipage; ipage0 > 0; ipage0 -= 1)  // Num 1-
180
      {
181
        Serial.write(0xA5);       //"A5" is 165
182
        Serial.write(0x5A);       //"5A" is 90
183
        Serial.write(0x05);
184
        Serial.write(0x82);
185
        Serial.write(0x03);
186
        Serial.write(0x00);
187
        Serial.write(0x00);
188
        Serial.write(ipage0);    // 0-7 page all can look!        
189
        delay(600);              // waits 0.9s
190
        if((ipage0 == (dataMuscle - 1))&&(ipage2 == 0)){
191
            ipage2 = 1;
192
            ipage0 += 2;
193
        }
194
      }
195
      ipage = 1;
196
      ipage2 = 0;
197
   }
198
   threeok = 3;      
199
  }// end if(biaozhi == 1)  
200
  /*-------------------------------------EMG assess  END -----------------------------*/
201
202
  if(threeok == 3)      // 3 = trun to reslut page  and biaozhi zero,
203
  {
204
    biaozhi = 0;
205
    threeok = 0;
206
    //trun reslut page.
207
        Serial.write(0xA5);       //"A5" is 165
208
        Serial.write(0x5A);       //"5A" is 90
209
        Serial.write(0x04);
210
        Serial.write(0x80);
211
        Serial.write(0x03);
212
        Serial.write(0x00);
213
        Serial.write(dataMuscle);     
214
     digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
215
     digitalWrite(led2, HIGH);    // turn the LED off by making the voltage LOW
216
     digitalWrite(led3, LOW);    // turn the LED off by making the voltage LOW
217
  }//end if(threeok == 3)  
218
}

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.