Components and supplies
1
Nextion NX8048T070 - Generic 7.0" HMI TFT LCD Touch Display
1
Analog joystick (Generic)
1
NEMA 17 Stepper Motor
Tools and machines
1
Soldering iron (generic)
Apps and platforms
1
Arduino IDE
Project description
Code
MATT.ino
arduino
1r// ***In the name of allah***// 2//this program is written by Mahdi Hajy Alimohamadi for MATT machin. its inclouded all function for load cell, thermal printer, joystic , TFT LCD// 3//date of last freamware 02/2017 4#include "Adafruit_Thermal.h" 5Adafruit_Thermal printer(&Serial2); 6#include <SPFD5408_Adafruit_GFX.h> // Core graphics library 7#include <SPFD5408_Adafruit_TFTLCD.h> // Hardware-specific library 8#include <SPFD5408_TouchScreen.h> 9#include <SD.h> 10#include <SPI.h> 11#include "HX711.h" 12#define calibration_factor -7050.0 13#define SD_CS 10 14#define LCD_CS A3 // Chip Select goes to Analog 3 15#define LCD_CD A2 // Command/Data goes to Analog 2 16#define LCD_WR A1 // LCD Write goes to Analog 1 17#define LCD_RD A0 // LCD Read goes to Analog 0 18#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin 19 // Assign human-readable names to some common 16-bit color values: 20#define BLACK 0x0000 21#define BLUE 0x001F 22#define RED 0xF800 23#define GREEN 0x07E0 24#define CYAN 0x07FF 25#define MAGENTA 0xF81F 26#define YELLOW 0xFFE0 27#define WHITE 0xFFFF 28 #define DOUT 22 29#define CLK 23 30HX711 scale(DOUT, CLK); 31Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET); 32int down= 39; 33int up = 38; 34int senup = 51; 35int senmid = 52; 36int sendown = 53; 37int joystic = A15; 38int bott = 26; 39 float kilo = 0; 40 float avr =0; 41 float maxi=0; 42 float sum=0; 43 int counter=0; 44const int f1 = 50; 45const int f2 = 49; 46const int f3 = 48; 47const int f4 = 47; 48const int f5 = 46; 49const int f6 = 45; 50const int startkey = 44; 51const int stopkey = 43; 52const int printkey = 42; 53const int stor = 41; 54const int resetkey = 40; 55 56void setup(void) 57{ 58 59 60 61 Serial2.begin(9600); 62//scale.set_scale(calibration_factor); //This value is obtained by using the SparkFun_HX711_Calibration sketch 63 scale.tare(); 64 // SDFP540 (0x9341) 65 66 tft.begin(0x9341); 67 68 pinMode (bott, INPUT_PULLUP); 69 pinMode(down, OUTPUT); 70 pinMode(up, OUTPUT); 71 pinMode(senup, INPUT); 72 pinMode(senmid, INPUT); 73 pinMode(sendown, INPUT); 74 pinMode(f1, INPUT_PULLUP); 75 pinMode(f2, INPUT_PULLUP); 76 pinMode(f3, INPUT_PULLUP); 77 pinMode(f4, INPUT_PULLUP); 78 pinMode(f5, INPUT_PULLUP); 79 pinMode(f6, INPUT_PULLUP); 80 pinMode(startkey, INPUT_PULLUP); 81 pinMode(stopkey, INPUT_PULLUP); 82 pinMode(printkey, INPUT_PULLUP); 83 pinMode(resetkey, INPUT_PULLUP); 84 pinMode(stor, INPUT_PULLUP); 85int value = 0; 86 87 /* printer.feed(1); 88 printer.justify('L'); 89 printer.println("Test Type: MANUAL"); 90 printer.feed(1); 91 printer.boldOn(); 92 printer.println("Ahesive Test : Roller Plate"); 93 printer.boldOff(); 94 printer.feed(2); 95 printer.setSize('S'); 96 printer.print("Average Force: "); 97 printer.print(avr); 98 printer.println(" N"); 99 printer.feed(1); 100 printer.print("Maximum Force: "); 101 printer.print(maxi); 102 printer.println(" N"); 103printer.feed(1); 104 printer.print("Number of samples:"); 105 printer.println(counter); 106 printer.feed(1); 107 printer.println("Speed ratio: "); 108 printer.println(counter); 109 110 printer.feed(2); 111 printer.justify('C'); 112 printer.setSize('M'); 113 printer.println("WWW.DNP-CO.IR"); 114 printer.feed(1); 115 printer.println("Tel: 09125221037"); 116 printer.feed(2); 117 printer.setSize('S'); 118 printer.justify('C'); 119 printer.println("...End of report..."); 120 printer.feed(3); 121 printer.wake(); 122 printer.setDefault(); 123 */ 124 125} 126//////////////////////////////////////////////////////////////////////////////1inch square 127void mili (void){ 128tft.fillScreen(BLACK); 129tft.setTextColor(YELLOW); tft.setTextSize(3); 130 tft.setCursor(20, 50); 131 tft.println(" 1 Inch Square Test."); 132tft.setTextColor(MAGENTA); 133tft.setTextSize(3); 134 tft.setCursor(10, 100); 135 tft.println("Please wait... "); 136 tft.setTextColor(WHITE); tft.setTextSize(2); 137 tft.setCursor(10, 200); 138 tft.println("The head is going to be set in the proper position"); 139 140 for(int i=25000; i>1; i--){ 141 digitalWrite(up, HIGH); 142 digitalWrite(down, HIGH); 143 delayMicroseconds(200); 144 digitalWrite(down, LOW); 145 delayMicroseconds(200); 146 } 147tft.fillScreen(BLACK); 148tft.setTextColor(YELLOW); tft.setTextSize(3); 149 tft.setCursor(20, 50); 150 tft.println("1 Inch Square Test."); 151tft.setTextColor(MAGENTA); 152tft.setTextSize(3); 153 tft.setCursor(10, 100); 154 tft.println("Please use a loop of adhesive tape with length of 25 cm and attach to the moving clamp."); 155 tft.setTextColor(WHITE); tft.setTextSize(2); 156 tft.setCursor(10, 220); 157 tft.println("Press START to start."); 158 tft.setCursor(10, 250); 159 tft.println("Press STOP to cancel."); 160while (true){ 161if (digitalRead (startkey) == LOW){ 162 tft.fillScreen(BLACK); 163tft.setTextColor(YELLOW); tft.setTextSize(3); 164 tft.setCursor(20, 50); 165 tft.println("Test is in progress..."); 166tft.setTextColor(MAGENTA); 167tft.setTextSize(3); 168 tft.setCursor(10, 100); 169 tft.println("Please wait to finish the test."); 170 tft.setTextColor(WHITE); tft.setTextSize(2); 171 tft.setCursor(10, 200); 172 for(int i=2000; i>1; i--){ 173 digitalWrite(up, HIGH); 174 digitalWrite(down, HIGH); 175 delay(1); 176 digitalWrite(down, LOW); 177 delay(1); 178 } 179 delay(500); 180 scale.tare(); 181 182 for(int j=30; j>1; j--){ 183 kilo = scale.get_units(); 184 kilo=kilo/10000; 185 kilo=kilo*1.15; 186counter ++; 187if (kilo > 70) alarm(); 188sum = sum+kilo; 189avr = sum/counter; 190if (kilo>maxi) maxi=kilo; 191 for(int i=100; i>1; i--){ 192 193 digitalWrite(down, HIGH); 194 digitalWrite(up, HIGH); 195 delay(1); 196 digitalWrite(up, LOW); 197 delay(1); 198 } 199 200} 201tft.setRotation(3); 202tft.fillScreen(BLACK); 203tft.setTextColor(YELLOW); tft.setTextSize(3); 204tft.setCursor(5, 50); 205tft.println("Test Is Finished."); 206//tft.setCursor(30, 104); 207//tft.setTextColor(WHITE); tft.setTextSize(2); 208//tft.println("Avarege Force:"); 209//tft.setTextColor(YELLOW); tft.setTextSize(3); 210//tft.setCursor(300,100); 211//tft.println(avr); 212//tft.setCursor(390, 100); 213//tft.println("N"); 214tft.setCursor(30, 134); 215tft.setTextColor(WHITE); tft.setTextSize(2); 216tft.println("Maximum Force:"); 217tft.setCursor(300, 130); 218tft.setTextColor(YELLOW); tft.setTextSize(3); 219tft.println(maxi); 220tft.setTextColor(WHITE); tft.setTextSize(2); 221tft.setCursor(390, 130); 222tft.println(" Newton"); 223tft.setCursor(30, 164); 224tft.setTextColor(WHITE); tft.setTextSize(2); 225tft.println("Number of samples:"); 226tft.setCursor(300, 160); 227tft.setTextColor(YELLOW); tft.setTextSize(3); 228tft.println(counter); 229tft.setCursor(30, 194); 230tft.setTextColor(WHITE); tft.setTextSize(2); 231tft.println("Speed rate:"); 232tft.setCursor(300, 190); 233tft.setTextColor(YELLOW); tft.setTextSize(3); 234tft.println("5 mm/s"); 235tft.setTextColor(CYAN); tft.setTextSize(2); 236tft.setCursor(5, 260); 237tft.println("To print results press PRINT."); 238tft.setTextColor(MAGENTA); tft.setTextSize(2); 239tft.setCursor(5, 290); 240tft.println("To restart press STOP."); 241 while (1){ 242if (digitalRead (stopkey) == LOW){ 243 loop(); 244} 245if (digitalRead (printkey) == LOW){ 246 tft.reset(); 247 248 printer.begin(); 249 printer.inverseOn(); 250 printer.justify('C'); 251 printer.setSize('L'); 252 printer.println("...MATT..."); 253 printer.inverseOff(); 254 printer.setSize('S'); 255 printer.println("Medical Adhesive Tape Test"); 256 printer.feed(1); 257 printer.justify('L'); 258 printer.println("Test Type: AUTOMATIC"); 259 printer.feed(1); 260 printer.boldOn(); 261 printer.println("Adhesive Test: 1Inch Square Test"); 262 printer.boldOff(); 263 printer.feed(2); 264 printer.setSize('S'); 265 // printer.print("Average Force: "); 266 //printer.print(avr); 267 //printer.println(" N"); 268 printer.feed(1); 269 printer.print("Maximum Force: "); 270 printer.print(maxi); 271 printer.println(" Newton"); 272printer.feed(1); 273 printer.print("Number of samples: "); 274 printer.println(counter); 275 printer.feed(1); 276 printer.print("Speed ratio: "); 277 printer.println("5 mm/s"); 278 279 printer.feed(2); 280 printer.justify('C'); 281 printer.setSize('M'); 282 printer.println("WWW.DNP-CO.IR"); 283 printer.feed(1); 284 printer.println("Tel: 09125221037"); 285 printer.feed(2); 286 printer.setSize('S'); 287 printer.justify('C'); 288 printer.println("...End of report..."); 289 printer.feed(3); 290 printer.wake(); 291 printer.setDefault(); 292 tft.begin(0x9341); 293 tft.setRotation(3); 294 loop(); 295} 296} 297 298} 299} 300} 301////////////////////////////////////////////////////////////////////////TERMINATION 302 void terminate (void) { 303 tft.fillScreen(BLACK); 304tft.setTextColor(YELLOW); tft.setTextSize(3); 305 tft.setCursor(5, 50); 306 tft.println("Test Is Terminated By User"); 307 tft.setTextColor(WHITE); tft.setTextSize(2); 308 tft.setCursor(5, 150); 309 tft.println("To print final result prees PRINT."); 310 tft.setCursor(5, 180); 311 tft.println("To store final result press STORE."); 312 tft.setTextColor(MAGENTA); tft.setTextSize(2); 313 tft.setCursor(5, 240); 314 tft.println("To restart press STOP."); 315while (1){ 316 if (digitalRead (stopkey) == LOW){ 317 loop(); 318 } 319 delay(1); 320} 321 322} 323 324/////////////////////////////////////////////////////////////////////////////////////////////-180degree 325void degree (void){ 326tft.fillScreen(BLACK); 327tft.setTextColor(YELLOW); tft.setTextSize(3); 328 tft.setCursor(20, 50); 329 tft.println(" 180 Degree Test."); 330tft.setTextColor(MAGENTA); 331tft.setTextSize(3); 332 tft.setCursor(10, 100); 333 tft.println("Please wait... "); 334 tft.setTextColor(WHITE); tft.setTextSize(2); 335 tft.setCursor(10, 200); 336 tft.println("The head is going to be set in the proper position"); 337 338 for(int i=25000; i>1; i--){ 339 digitalWrite(up, HIGH); 340 digitalWrite(down, HIGH); 341 delayMicroseconds(200); 342 digitalWrite(down, LOW); 343 delayMicroseconds(200); 344 } 345tft.fillScreen(BLACK); 346tft.setTextColor(YELLOW); tft.setTextSize(3); 347 tft.setCursor(20, 50); 348 tft.println("180 Degree Test."); 349tft.setTextColor(MAGENTA); 350tft.setTextSize(3); 351 tft.setCursor(10, 100); 352 tft.println("Please use appropret clamp and attache one side the specimen to the moving clamp and attache other side to plate."); 353 tft.setTextColor(WHITE); tft.setTextSize(2); 354 tft.setCursor(10, 260); 355 tft.println("Press START to start."); 356 tft.setCursor(10, 290); 357 tft.println("Press STOP to cancel."); 358while (true){ 359if (digitalRead (startkey) == LOW){ 360 tft.fillScreen(BLACK); 361tft.setTextColor(YELLOW); tft.setTextSize(3); 362 tft.setCursor(20, 50); 363 tft.println("Test is in progress..."); 364tft.setTextColor(MAGENTA); 365tft.setTextSize(3); 366 tft.setCursor(10, 100); 367 tft.println("please wait to finish te test."); 368 tft.setTextColor(WHITE); tft.setTextSize(2); 369 tft.setCursor(10, 200); 370 371 scale.tare(); 372 373 for(int j=110; j>1; j--){ 374 kilo = scale.get_units(); 375 kilo=kilo/10000; 376 kilo=kilo*1.15; 377counter ++; 378if (kilo > 70) alarm(); 379sum = sum+kilo; 380avr = sum/counter; 381if (kilo>maxi) maxi=kilo; 382 for(int i=100; i>1; i--){ 383 384 digitalWrite(down, HIGH); 385 digitalWrite(up, HIGH); 386 delay(1); 387 digitalWrite(up, LOW); 388 delay(1); 389 } 390 391} 392 393tft.setRotation(3); 394tft.fillScreen(BLACK); 395tft.setTextColor(YELLOW); tft.setTextSize(3); 396tft.setCursor(5, 50); 397tft.println("Test Is Finshed."); 398tft.setCursor(30, 104); 399tft.setTextColor(WHITE); tft.setTextSize(2); 400tft.println("Avarege Force:"); 401tft.setTextColor(YELLOW); tft.setTextSize(3); 402tft.setCursor(300,100); 403tft.println(avr); 404tft.setTextColor(WHITE); tft.setTextSize(2); 405tft.setCursor(390, 100); 406tft.println(" Newton"); 407tft.setCursor(30, 134); 408tft.setTextColor(WHITE); tft.setTextSize(2); 409tft.println("Maximum Force:"); 410tft.setCursor(300, 130); 411tft.setTextColor(YELLOW); tft.setTextSize(3); 412tft.println(maxi); 413tft.setTextColor(WHITE); tft.setTextSize(2); 414tft.setCursor(390, 130); 415tft.println(" Newton"); 416tft.setCursor(30, 164); 417tft.setTextColor(WHITE); tft.setTextSize(2); 418tft.println("Number of samples:"); 419tft.setCursor(300, 160); 420tft.setTextColor(YELLOW); tft.setTextSize(3); 421tft.println(counter); 422tft.setCursor(30, 194); 423tft.setTextColor(WHITE); tft.setTextSize(2); 424tft.println("Speed rate:"); 425tft.setCursor(300, 190); 426tft.setTextColor(YELLOW); tft.setTextSize(3); 427tft.println("5 mm/s"); 428tft.setTextColor(CYAN); tft.setTextSize(2); 429tft.setCursor(5, 260); 430tft.println("To print results press PRINT."); 431tft.setTextColor(MAGENTA); tft.setTextSize(2); 432tft.setCursor(5, 290); 433tft.println("To restart press STOP."); 434 while (1){ 435if (digitalRead (stopkey) == LOW){ 436 loop(); 437} 438if (digitalRead (printkey) == LOW){ 439 tft.reset(); 440 441 printer.begin(); 442 printer.inverseOn(); 443 printer.justify('C'); 444 printer.setSize('L'); 445 printer.println("...MATT..."); 446 printer.inverseOff(); 447 printer.setSize('S'); 448 printer.println("Medical Adhesive Tape Test"); 449 printer.feed(1); 450 printer.justify('L'); 451 printer.println("Test Type: AUTOMATIC"); 452 printer.feed(1); 453 printer.boldOn(); 454 printer.println("Adhesive Test: 180 degree"); 455 printer.boldOff(); 456 printer.feed(2); 457 printer.setSize('S'); 458 printer.print("Average Force: "); 459 printer.print(avr); 460 printer.println(" Newton"); 461 printer.feed(1); 462 printer.print("Maximum Force: "); 463 printer.print(maxi); 464 printer.println(" Newton"); 465printer.feed(1); 466 printer.print("Number of samples: "); 467 printer.println(counter); 468 printer.feed(1); 469 printer.print("Speed ratio: "); 470 printer.println("5 mm/s"); 471 472 printer.feed(2); 473 printer.justify('C'); 474 printer.setSize('M'); 475 printer.println("WWW.DNP-CO.IR"); 476 printer.feed(1); 477 printer.println("Tel: 09125221037"); 478 printer.feed(2); 479 printer.setSize('S'); 480 printer.justify('C'); 481 printer.println("...End of report..."); 482 printer.feed(3); 483 printer.wake(); 484 printer.setDefault(); 485 tft.begin(0x9341); 486 tft.setRotation(3); 487 loop(); 488} 489} 490 491 492} 493}} 494 495/////////////////////////////////////////////////////////alarm 496void alarm (void){ 497 tft.fillScreen(BLACK); 498tft.setTextColor(YELLOW); tft.setTextSize(3); 499 tft.setCursor(5, 50); 500 tft.println("ALARM!"); 501 tft.setTextColor(WHITE); tft.setTextSize(2); 502 tft.setCursor(5, 150); 503 tft.println("The force is raeched limit (>40 N)"); 504 tft.setCursor(5, 180); 505 tft.println("Please remove tape ad restart test."); 506 tft.setTextColor(MAGENTA); tft.setTextSize(2); 507 tft.setCursor(5, 240); 508 tft.println("To restart press STOP."); 509 while(true){ 510 if (digitalRead (stopkey) == LOW){ 511terminate(); 512 513}}} 514 ////////////////////////////////////////////////////////////////////////////////////////////////////////MAIN LOOP 515void loop(void) 516{ 517 518 519//////////////////////////////////////////////////////////////////////////////////////////////////////////Initialaizing 520 521kilo=0; 522maxi=0; 523sum=0; 524avr=0; 525counter=0; 526 527 /////////logo 528 tft.setRotation(3); 529 tft.fillScreen(WHITE); 530 tft.fillScreen(MAGENTA); 531 tft.fillScreen(WHITE); 532 tft.setTextColor(BLUE); 533 tft.setTextSize(7); 534 tft.setCursor(100, 50); 535 tft.println("M A T T"); 536 tft.setTextColor(CYAN); tft.setTextSize(3); 537 tft.setCursor(5, 150); 538 tft.println("Medical Adhesive Tape Test"); 539 tft.setTextColor(BLACK); tft.setTextSize(2); 540 tft.setCursor(20, 230); 541 tft.println("Designed and Developed by DNP co."); 542 tft.setCursor(20, 260); 543 tft.println("www.DNP-CO.ir"); 544 tft.setCursor(20, 290); 545 tft.println("Tel: +98-912 522 1037"); 546 delay(5000); 547/////////////////////// 548 549 tft.fillScreen(BLACK); 550 tft.setTextColor(WHITE); tft.setTextSize(1); 551 tft.setCursor(10, 10); 552 tft.println("Version. 2.6 Sep 2017"); 553 tft.setTextColor(WHITE); tft.setTextSize(3); 554 tft.setCursor(100, 50); 555 tft.println("Initializing..."); 556 tft.setTextColor(YELLOW); tft.setTextSize(2); 557 tft.setCursor(30, 100); 558 tft.println("Self Test:"); 559 tft.setCursor(30, 120); 560 tft.println("Limit Sensors, Motor, ROM, Loadcell "); 561 562 tft.setTextColor(WHITE); tft.setTextSize(2); 563 tft.setCursor(150, 150); 564 tft.println("Please wait..."); 565 566 tft.setTextColor(WHITE); tft.setTextSize(2); 567 tft.setCursor(10, 290); 568 tft.println("www.DNP-CO.ir 09125221037"); 569 570for (int n=3; n>0; n--){ 571 572 tft.setTextColor(YELLOW); tft.setTextSize(2); 573 tft.setCursor(210, 220); 574 tft.println(n); 575// tft.setCursor(210, 240); 576 // tft.println(kilo); 577 delay(1000); 578 tft.setTextColor(BLACK); tft.setTextSize(2); 579 tft.setCursor(210, 220); 580 tft.println(n); 581 // tft.setCursor(210, 240); 582 // tft.println(kilo); 583} 584//////////////////////////////////////////////////////////////////////////////////////////////////////////////////Auto Position 585tft.fillScreen(BLACK); 586 tft.setTextColor(YELLOW); tft.setTextSize(3); 587 tft.setCursor(50, 50); 588 tft.println("Auto Set Postition..."); 589 tft.setTextColor(WHITE); tft.setTextSize(2); 590 tft.setCursor(5, 100); 591 tft.println("Please wait while the haed is going to be set in the zero position."); 592 593 tft.setTextColor(WHITE); tft.setTextSize(2); 594 tft.setCursor(10, 270); 595 tft.println("www.DNP-CO.ir 09125221037"); 596 while (true) 597 { 598 599 600 digitalWrite(down, HIGH); 601 digitalWrite(up, HIGH); 602 delayMicroseconds(200); 603 digitalWrite(up, LOW); 604 delayMicroseconds(200); 605 if (digitalRead(senup)== HIGH){ 606 delay(10); 607 if(digitalRead(senup)==HIGH){ 608 break; 609 } 610 } 611 } 612 613 for (int m=200; m>0; m--){ 614 digitalWrite(up, HIGH); 615 digitalWrite(down, HIGH); 616delayMicroseconds(200); 617digitalWrite(down, LOW); 618delayMicroseconds(200); 619 620 } 621///////////////////////////////////////////////////////////////////////////////////////////////////////////////////Manual / Auto selection 622 tft.fillScreen(BLACK); 623 tft.setTextColor(YELLOW); tft.setTextSize(3); 624 tft.setCursor(20, 50); 625 tft.println("Please select Test Mode: "); 626 tft.setTextColor(WHITE); tft.setTextSize(3); 627 tft.setCursor(5, 130); 628 tft.println("For Manual press 1."); 629 tft.setCursor(5, 180); 630 tft.println("For Auto press 2"); 631 while (1){ 632 if (digitalRead(f1) == LOW){ 633manualmode(); 634 } 635if (digitalRead(f2) == LOW){ 636 tft.fillScreen(BLACK); 637tft.setTextColor(YELLOW); tft.setTextSize(3); 638 tft.setCursor(20, 50); 639 tft.println("Please select the type of test"); 640tft.setTextColor(WHITE); tft.setTextSize(2); 641 642 tft.setCursor(10, 200); 643 tft.println("For Tension Test press F1."); 644 tft.setCursor(10, 230); 645 tft.println("For Adhesive Test press F2."); 646 while (1){ 647 if (digitalRead(f1) == LOW){ 648tension(); 649 } 650 if (digitalRead(f2) == LOW){ 651 652 tft.fillScreen(BLACK); 653tft.setTextColor(YELLOW); tft.setTextSize(3); 654 tft.setCursor(20, 50); 655 tft.println("Adhesie test selection:"); 656tft.setTextColor(WHITE); tft.setTextSize(2); 657 tft.setCursor(10, 150); 658 tft.println("Roller Plate = F1"); 659 tft.setCursor(10, 180); 660 tft.println("1 Inch Square= F2."); 661tft.setCursor(10, 210); 662 tft.println("180 degree test = F3."); 663 tft.setTextColor(MAGENTA); 664 tft.setCursor(10, 270); 665 tft.println("To cancel press STOP."); 666 667while (true){ 668 if (digitalRead(f1) == LOW){ 669 rollerplate(); 670 671 } 672 if (digitalRead(f2) == LOW){ 673 674mili(); 675 } 676 if (digitalRead(f3) == LOW){ 677degree(); 678} 679 if (digitalRead(stopkey) == LOW){ 680terminate(); 681} 682} 683} 684} 685} 686} 687tft.fillScreen(BLACK); 688} 689///////////////////////////////////////////////////////////////////////////////////////////////////////////////////TENSION 690 void tension (void){ 691 tft.fillScreen(BLACK); 692tft.setTextColor(YELLOW); tft.setTextSize(3); 693 tft.setCursor(20, 50); 694 tft.println("Tension test."); 695tft.setTextColor(MAGENTA); 696tft.setTextSize(3); 697 tft.setCursor(10, 100); 698 tft.println("Please wait... "); 699 tft.setTextColor(WHITE); tft.setTextSize(2); 700 tft.setCursor(10, 200); 701 tft.println("The head is going to be set in the proper position."); 702 703 while (digitalRead(sendown) == LOW) 704 { 705 706 digitalWrite(up, HIGH); 707 digitalWrite(down, HIGH); 708delayMicroseconds(200); 709digitalWrite(down, LOW); 710delayMicroseconds(200); 711} 712 for (int m=1000; m>0; m--){ 713 digitalWrite(down, HIGH); 714 digitalWrite(up, HIGH); 715delayMicroseconds(200); 716digitalWrite(up, LOW); 717delayMicroseconds(200); 718 719 } 720 tft.fillScreen(BLACK); 721tft.setTextColor(YELLOW); tft.setTextSize(3); 722 tft.setCursor(20, 50); 723 tft.println("Tension test."); 724tft.setTextColor(MAGENTA); 725tft.setTextSize(3); 726 tft.setCursor(10, 100); 727 tft.println("Please attache appropriateclamp according to the width of tape."); 728 tft.setTextColor(WHITE); tft.setTextSize(2); 729 tft.setCursor(10, 200); 730 tft.println("Press START to start."); 731 tft.setCursor(10, 230); 732 tft.println("Press STOP to cancel."); 733 734while (true){ 735 if (digitalRead (startkey) == LOW){ 736 break;} 737 if (digitalRead (stopkey) == LOW){ 738 739terminate();} 740 741} 742 tft.fillScreen(BLACK); 743tft.setTextColor(YELLOW); tft.setTextSize(3); 744 tft.setCursor(20, 50); 745 tft.println("Test is in progress..."); 746tft.setTextColor(MAGENTA); 747tft.setTextSize(3); 748 tft.setCursor(10, 100); 749 tft.println("please wait to finish the test."); 750 tft.setTextColor(WHITE); tft.setTextSize(2); 751 tft.setCursor(10, 200); 752 753 tft.println("Press STOP to cancel."); 754 scale.tare(); 755 for (int i=0; i<1000 ; i++){ 756 if (digitalRead(senmid)== HIGH)break; 757 digitalWrite(down, HIGH); 758 digitalWrite(up, HIGH); 759 delay(1); 760 digitalWrite(up, LOW); 761 delay(1); 762 } 763 while (digitalRead(senmid) == LOW) 764 { 765 766 kilo = scale.get_units(); 767 kilo=kilo/10000; 768 kilo=kilo*1.15; 769counter ++; 770if (kilo > 70) alarm(); 771sum = sum+kilo; 772avr = sum/counter; 773if (kilo>maxi) maxi=kilo; 774 775if (digitalRead (stopkey) == LOW){ 776//....................................................................................................................................................................................... 777terminate();} 778for (int i=0; i<500 ; i++){ 779 if (digitalRead(senmid)== HIGH)break; 780 digitalWrite(down, HIGH); 781 digitalWrite(up, HIGH); 782 delay(1); 783 digitalWrite(up, LOW); 784 delay(1); 785 } 786 if(kilo < avr)break; 787 } 788////////////////////////result show 789tft.setRotation(3); 790tft.fillScreen(BLACK); 791tft.setTextColor(YELLOW); tft.setTextSize(3); 792tft.setCursor(5, 50); 793tft.println("Test Is Finshed."); 794//tft.setCursor(30, 104); 795//tft.setTextColor(WHITE); tft.setTextSize(2); 796//tft.println("Avarege Force:"); 797//tft.setTextColor(YELLOW); tft.setTextSize(2); 798//tft.setCursor(300,100); 799//tft.println(avr); 800//tft.setCursor(390, 100); 801//tft.println("Newton"); 802tft.setCursor(30, 134); 803tft.setTextColor(WHITE); tft.setTextSize(2); 804tft.println("Maximum Force:"); 805tft.setCursor(300, 130); 806tft.setTextColor(YELLOW); tft.setTextSize(3); 807tft.println(maxi); 808tft.setTextColor(YELLOW); tft.setTextSize(2); 809tft.setCursor(390, 130); 810tft.println(" Newton"); 811tft.setCursor(30, 164); 812tft.setTextColor(WHITE); tft.setTextSize(2); 813tft.println("Number of samples:"); 814tft.setCursor(300, 160); 815tft.setTextColor(YELLOW); tft.setTextSize(3); 816tft.println(counter); 817tft.setCursor(30, 194); 818tft.setTextColor(WHITE); tft.setTextSize(2); 819tft.println("Speed rate:"); 820tft.setCursor(300, 190); 821tft.setTextColor(YELLOW); tft.setTextSize(3); 822tft.println("5 mm/s"); 823tft.setTextColor(CYAN); tft.setTextSize(2); 824tft.setCursor(5, 260); 825tft.println("To print results press PRINT."); 826tft.setTextColor(MAGENTA); tft.setTextSize(2); 827tft.setCursor(5, 290); 828tft.println("To restart press STOP."); 829 while (1){ 830if (digitalRead (stopkey) == LOW){ 831 loop(); 832} 833if (digitalRead (printkey) == LOW){ 834 tft.reset(); 835 836 printer.begin(); 837 printer.inverseOn(); 838 printer.justify('C'); 839 printer.setSize('L'); 840 printer.println("...MATT..."); 841 printer.inverseOff(); 842 printer.setSize('S'); 843 printer.println("Medical Adhesive Tape Test"); 844 printer.feed(1); 845 printer.justify('L'); 846 printer.println("Test Type: AUTOMATIC"); 847 printer.feed(1); 848 printer.boldOn(); 849 printer.println("Tension Test"); 850 printer.boldOff(); 851 printer.feed(3); 852 // printer.setSize('S'); 853 // printer.print("Average Force: "); 854 // printer.print(avr); 855 // printer.println(" N"); 856 printer.feed(1); 857 printer.print("Maximum Force: "); 858 printer.print(maxi); 859 printer.println(" Newton"); 860printer.feed(1); 861 printer.print("Number of samples: "); 862 printer.println(counter); 863 printer.feed(1); 864 printer.print("Speed ratio: "); 865 printer.println("5 mm/s"); 866 867 printer.feed(2); 868 printer.justify('C'); 869 printer.setSize('M'); 870 printer.println("WWW.DNP-CO.IR"); 871 printer.feed(1); 872 printer.println("Tel: 09125221037"); 873 printer.feed(2); 874 printer.setSize('S'); 875 printer.justify('C'); 876 printer.println("...End of report..."); 877 printer.feed(3); 878 printer.wake(); 879 printer.setDefault(); 880 tft.begin(0x9341); 881 tft.setRotation(3); 882 loop(); 883} 884} ///////////////////////////////////// 885 } 886 ////////////////////////////////////////////////////////////////////////////////ROLLER PLATE 887void rollerplate (void){ 888 tft.fillScreen(BLACK); 889tft.setTextColor(YELLOW); tft.setTextSize(3); 890 tft.setCursor(20, 50); 891 tft.println("Roller Plate Test."); 892tft.setTextColor(MAGENTA); 893tft.setTextSize(3); 894 tft.setCursor(10, 100); 895 tft.println("Please wait... "); 896 tft.setTextColor(WHITE); tft.setTextSize(2); 897 tft.setCursor(10, 200); 898 tft.println("The head is going to be set in the proper position"); 899 while (digitalRead(sendown) == LOW) 900 { 901 digitalWrite(up, HIGH); 902 digitalWrite(down, HIGH); 903delayMicroseconds(200); 904digitalWrite(down, LOW); 905delayMicroseconds(200); 906} 907 for (int m=500; m>0; m--){ 908 digitalWrite(down, HIGH); 909 digitalWrite(up, HIGH); 910delayMicroseconds(200); 911digitalWrite(up, LOW); 912delayMicroseconds(200); 913 914 } 915tft.fillScreen(BLACK); 916tft.setTextColor(YELLOW); tft.setTextSize(3); 917 tft.setCursor(20, 50); 918 tft.println("Tension test."); 919tft.setTextColor(MAGENTA); 920tft.setTextSize(3); 921 tft.setCursor(10, 105); 922 tft.println("Please attache Roller Plate. "); 923 tft.setTextColor(WHITE); tft.setTextSize(2); 924 tft.setCursor(10, 200); 925 tft.println("Press START to start."); 926 tft.setCursor(10, 230); 927 tft.println("Press STOP to cancel."); 928while (true){ 929if (digitalRead (startkey) == LOW){ 930break; 931 } 932 if (digitalRead (stopkey) == LOW){ 933terminate(); 934 } 935} 936 tft.fillScreen(BLACK); 937tft.setTextColor(YELLOW); tft.setTextSize(3); 938 tft.setCursor(20, 50); 939 tft.println("Test is in progress..."); 940tft.setTextColor(MAGENTA); 941tft.setTextSize(3); 942 tft.setCursor(10, 100); 943 tft.println("Please wait to finish the test."); 944 tft.setTextColor(WHITE); tft.setTextSize(2); 945 tft.setCursor(10, 200); 946 947 tft.println("Press STOP to cancel."); 948 scale.tare(); 949 950 while (digitalRead(senmid) == LOW) 951 { 952 while (digitalRead(senmid) == LOW) { 953 kilo = scale.get_units(); 954 kilo=kilo/10000; 955 kilo=kilo*1.15; 956counter ++; 957if (kilo > 70) alarm(); 958sum = sum+kilo; 959avr = sum/counter; 960if (kilo>maxi) maxi=kilo; 961for (int i=0; i<100 ; i++){ 962 digitalWrite(down, HIGH); 963 digitalWrite(up, HIGH); 964 delay(1); 965 digitalWrite(up, LOW); 966 delay(1); 967 digitalWrite (stopkey, HIGH); 968 int key =0; 969 key = digitalRead (stopkey); 970 if (key == LOW) { 971 972 terminate(); } 973 }} 974 975 } 976 for (int m=500; m>0; m--){ 977 digitalWrite(up, HIGH); 978 digitalWrite(down, HIGH); 979 delay(1); 980 digitalWrite(down, LOW); 981 delay(1); 982 983 } 984 985 986 tft.setRotation(3); 987tft.fillScreen(BLACK); 988tft.setTextColor(YELLOW); tft.setTextSize(3); 989tft.setCursor(5, 50); 990tft.println("Test Is Finshed."); 991tft.setCursor(30, 104); 992tft.setTextColor(WHITE); tft.setTextSize(2); 993tft.println("Avarege Force:"); 994tft.setTextColor(YELLOW); tft.setTextSize(3); 995tft.setCursor(300,100); 996tft.println(avr); 997tft.setTextColor(WHITE); tft.setTextSize(2); 998tft.setCursor(390, 100); 999tft.println(" Newton"); 1000tft.setCursor(30, 134); 1001tft.setTextColor(WHITE); tft.setTextSize(2); 1002tft.println("Maximum Force:"); 1003tft.setCursor(300, 130); 1004tft.setTextColor(YELLOW); tft.setTextSize(3); 1005tft.println(maxi); 1006tft.setTextColor(WHITE); tft.setTextSize(2); 1007tft.setCursor(390, 130); 1008tft.println(" Newton"); 1009tft.setCursor(30, 164); 1010tft.setTextColor(WHITE); tft.setTextSize(2); 1011tft.println("Number of samples:"); 1012tft.setCursor(300, 160); 1013tft.setTextColor(YELLOW); tft.setTextSize(3); 1014tft.println(counter); 1015tft.setCursor(30, 194); 1016tft.setTextColor(WHITE); tft.setTextSize(2); 1017tft.println("Speed rate:"); 1018tft.setCursor(300, 190); 1019tft.setTextColor(YELLOW); tft.setTextSize(3); 1020tft.println("5 mm/s"); 1021tft.setTextColor(CYAN); tft.setTextSize(2); 1022tft.setCursor(5, 260); 1023tft.println("To print results press PRINT."); 1024tft.setTextColor(MAGENTA); tft.setTextSize(2); 1025tft.setCursor(5, 290); 1026tft.println("To restart press STOP."); 1027 while (1){ 1028if (digitalRead (stopkey) == LOW){ 1029 tft.fillScreen(BLACK); 1030tft.setTextColor(YELLOW); tft.setTextSize(4); 1031tft.setCursor(5, 50); 1032tft.println("WARRNING!!!"); 1033tft.setCursor(30, 104); 1034tft.setTextColor(WHITE); tft.setTextSize(3); 1035tft.println("Remove plate's cable from the head."); 1036tft.setTextColor(MAGENTA); tft.setTextSize(2); 1037tft.setCursor(5, 290); 1038tft.println("To restart press STOP."); 1039while(true){ 1040if (digitalRead (stopkey) == LOW){ 1041 loop();}} 1042} 1043if (digitalRead (printkey) == LOW){ 1044 tft.reset(); 1045 1046 printer.begin(); 1047 printer.inverseOn(); 1048 printer.justify('C'); 1049 printer.setSize('L'); 1050 printer.println("...MATT..."); 1051 printer.inverseOff(); 1052 printer.setSize('S'); 1053 printer.println("Medical Adhesive Tape Test"); 1054 printer.feed(1); 1055 printer.justify('L'); 1056 printer.println("Test Type: AUTOMATIC"); 1057 printer.feed(1); 1058 printer.boldOn(); 1059 printer.println("Adhesive Test: Roller Plate"); 1060 printer.boldOff(); 1061 printer.feed(2); 1062 printer.setSize('S'); 1063 printer.print("Average Force: "); 1064 printer.print(avr); 1065 printer.println(" Newton"); 1066 printer.feed(1); 1067 printer.print("Maximum Force: "); 1068 printer.print(maxi); 1069 printer.println(" Newton"); 1070printer.feed(1); 1071 printer.print("Number of samples: "); 1072 printer.println(counter); 1073 printer.feed(1); 1074 printer.print("Speed ratio: "); 1075 printer.println("5 mm/s"); 1076 1077 printer.feed(2); 1078 printer.justify('C'); 1079 printer.setSize('M'); 1080 printer.println("WWW.DNP-CO.IR"); 1081 printer.feed(1); 1082 printer.println("Tel: 09125221037"); 1083 printer.feed(2); 1084 printer.setSize('S'); 1085 printer.justify('C'); 1086 printer.println("...End of report..."); 1087 printer.feed(3); 1088 printer.wake(); 1089 printer.setDefault(); 1090 tft.begin(0x9341); 1091 tft.setRotation(3); 1092 1093 tft.fillScreen(BLACK); 1094tft.setTextColor(YELLOW); tft.setTextSize(4); 1095tft.setCursor(5, 50); 1096tft.println("WARRNING!!!"); 1097tft.setCursor(30, 104); 1098tft.setTextColor(WHITE); tft.setTextSize(3); 1099tft.println("Remove plate's cable from the head."); 1100 1101tft.setTextColor(MAGENTA); tft.setTextSize(2); 1102tft.setCursor(5, 290); 1103tft.println("To restart press STOP."); 1104while(true){ 1105if (digitalRead (stopkey) == LOW){ 1106 loop();}} 1107} 1108} 1109} 1110 1111/////////////////////////////////////////////////////////////////////////////////////////////////////////////MANUAL MODE 1112 void manualmode (void) 1113 { 1114 1115 tft.fillScreen(BLACK); 1116tft.setTextColor(YELLOW); tft.setTextSize(3); 1117 tft.setCursor(20, 50); 1118 tft.println("Manual Mode is selected"); 1119tft.setTextColor(WHITE); tft.setTextSize(2); 1120 tft.setCursor(10, 150); 1121 tft.println("Press START to continiu."); 1122 tft.setCursor(10, 200); 1123 tft.println("Press STOP to cancel."); 1124 while (1){ 1125 if (digitalRead (startkey) == LOW){ 1126 goto manual; 1127 } 1128 if (digitalRead (stopkey) == LOW){ 1129 terminate(); 1130 } 1131 } 1132 manual: 1133 /////////////////////////////////////////////////////////////////////////////////////////////////////////joystick 1134 kilo=0; 1135 maxi=0; 1136 counter=0; 1137 avr=0; 1138maxi=0; 1139sum=0; 1140int value =0; 1141 tft.fillScreen(BLACK); 1142tft.setTextColor(YELLOW); tft.setTextSize(2); 1143 tft.setCursor(5, 50); 1144 tft.println("Use Joystick to move head up and down."); 1145 tft.setCursor(5, 100); 1146 tft.println(""); 1147 tft.setCursor(5, 150); 1148 tft.println("To finish test press STOP."); 1149 tft.setTextColor(WHITE); tft.setTextSize(4); 1150 1151scale.tare(); 1152while(true) 1153 { 1154 delay(500); 1155 value = analogRead(joystic); 1156 value = value/100; 1157 if (digitalRead (stopkey) == LOW){ 1158 break; 1159 }/*////// 1160 kilo = scale.get_units(); 1161 kilo=kilo/10000; 1162 kilo=kilo*1.15; 1163counter ++; 1164if (kilo > 70) alarm(); 1165sum = sum+kilo; 1166avr = sum/counter; 1167if (kilo>maxi) maxi=kilo; 1168 */////// 1169 1170 while (value>7){ 1171for(int i=200; i>1; i--){ 1172 digitalWrite(down, HIGH); 1173 digitalWrite(up, HIGH); 1174delayMicroseconds(700); 1175digitalWrite(up, LOW); 1176delayMicroseconds(700); 1177} 1178 kilo = scale.get_units(); 1179 kilo=kilo/10000; 1180 kilo=kilo*1.15; 1181counter ++; 1182if (kilo > 70) alarm(); 1183sum = sum+kilo; 1184avr = sum/counter; 1185if (kilo>maxi) maxi=kilo; 1186 value = analogRead(joystic); 1187 value = value/100; 1188 } 1189 1190 while( value<3){ 1191 1192 digitalWrite(up, HIGH); 1193 digitalWrite(down, HIGH); 1194delayMicroseconds(200); 1195digitalWrite(down, LOW); 1196delayMicroseconds(200); 1197value = analogRead(joystic); 1198 value = value/100; 1199 } 1200} 1201tft.setRotation(3); 1202tft.fillScreen(BLACK); 1203tft.setTextColor(YELLOW); tft.setTextSize(3); 1204tft.setCursor(5, 50); 1205tft.println("Test Is Finshed."); 1206tft.setCursor(30, 104); 1207tft.setTextColor(WHITE); tft.setTextSize(2); 1208tft.println("Avarege Force:"); 1209tft.setTextColor(YELLOW); tft.setTextSize(3); 1210tft.setCursor(300,100); 1211tft.println(avr); 1212tft.setTextColor(WHITE); tft.setTextSize(2); 1213tft.setCursor(390, 100); 1214tft.println(" Newton"); 1215tft.setCursor(30, 134); 1216tft.setTextColor(WHITE); tft.setTextSize(2); 1217tft.println("Maximum Force:"); 1218tft.setCursor(300, 130); 1219tft.setTextColor(YELLOW); tft.setTextSize(3); 1220tft.println(maxi); 1221tft.setTextColor(WHITE); tft.setTextSize(2); 1222tft.setCursor(390, 130); 1223tft.println(" Newton"); 1224tft.setCursor(30, 164); 1225tft.setTextColor(WHITE); tft.setTextSize(2); 1226tft.println("Number of samples:"); 1227tft.setCursor(300, 160); 1228tft.setTextColor(YELLOW); tft.setTextSize(3); 1229tft.println(counter); 1230 1231 1232tft.setTextColor(MAGENTA); tft.setTextSize(2); 1233tft.setCursor(5, 260); 1234tft.println("To restart press STOP."); 1235 while (1){ 1236if (digitalRead (stopkey) == LOW){ 1237 goto manual; 1238} 1239if (digitalRead (resetkey) == LOW){ 1240 loop(); 1241} 1242if (digitalRead (printkey) == LOW){ 1243 tft.reset(); 1244 1245 printer.begin(); 1246 printer.inverseOn(); 1247 printer.justify('C'); 1248 printer.setSize('L'); 1249 printer.println("...MATT..."); 1250 printer.inverseOff(); 1251 printer.setSize('S'); 1252 printer.println("Medical Adhesive Tape Test"); 1253 printer.feed(1); 1254 printer.justify('L'); 1255 printer.println("Test Type: MANUAL"); 1256 printer.feed(1); 1257 printer.boldOn(); 1258 printer.println("Tension Test"); 1259 printer.boldOff(); 1260 printer.feed(2); 1261 printer.setSize('S'); 1262 printer.print("Average Force: "); 1263 printer.print(avr); 1264 printer.println(" Newton"); 1265 printer.feed(1); 1266 printer.print("Maximum Force: "); 1267 printer.print(maxi); 1268 printer.println(" Newton"); 1269printer.feed(1); 1270 printer.print("Number of samples: "); 1271 1272 printer.feed(2); 1273 printer.justify('C'); 1274 printer.setSize('M'); 1275 printer.println("WWW.DNP-CO.IR"); 1276 printer.feed(1); 1277 printer.println("Tel: 09125221037"); 1278 printer.feed(2); 1279 printer.setSize('S'); 1280 printer.justify('C'); 1281 printer.println("...End of report..."); 1282 printer.feed(3); 1283 printer.wake(); 1284 printer.setDefault(); 1285 tft.begin(0x9341); 1286 tft.setRotation(3); 1287 goto manual; 1288 1289} 1290} 1291 1292 } 1293 1294 1295 1296
MATT.ino
arduino
1r// ***In the name of allah***// 2//this program is written by Mahdi Hajy Alimohamadi for MATT machin. its inclouded all function for load cell, thermal printer, joystic , TFT LCD// 3//date of last freamware 02/2017 4#include "Adafruit_Thermal.h" 5Adafruit_Thermal printer(&Serial2); 6#include <SPFD5408_Adafruit_GFX.h> // Core graphics library 7#include <SPFD5408_Adafruit_TFTLCD.h> // Hardware-specific library 8#include <SPFD5408_TouchScreen.h> 9#include <SD.h> 10#include <SPI.h> 11#include "HX711.h" 12#define calibration_factor -7050.0 13#define SD_CS 10 14#define LCD_CS A3 // Chip Select goes to Analog 3 15#define LCD_CD A2 // Command/Data goes to Analog 2 16#define LCD_WR A1 // LCD Write goes to Analog 1 17#define LCD_RD A0 // LCD Read goes to Analog 0 18#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin 19 // Assign human-readable names to some common 16-bit color values: 20#define BLACK 0x0000 21#define BLUE 0x001F 22#define RED 0xF800 23#define GREEN 0x07E0 24#define CYAN 0x07FF 25#define MAGENTA 0xF81F 26#define YELLOW 0xFFE0 27#define WHITE 0xFFFF 28 #define DOUT 22 29#define CLK 23 30HX711 scale(DOUT, CLK); 31Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET); 32int down= 39; 33int up = 38; 34int senup = 51; 35int senmid = 52; 36int sendown = 53; 37int joystic = A15; 38int bott = 26; 39 float kilo = 0; 40 float avr =0; 41 float maxi=0; 42 float sum=0; 43 int counter=0; 44const int f1 = 50; 45const int f2 = 49; 46const int f3 = 48; 47const int f4 = 47; 48const int f5 = 46; 49const int f6 = 45; 50const int startkey = 44; 51const int stopkey = 43; 52const int printkey = 42; 53const int stor = 41; 54const int resetkey = 40; 55 56void setup(void) 57{ 58 59 60 61 Serial2.begin(9600); 62//scale.set_scale(calibration_factor); //This value is obtained by using the SparkFun_HX711_Calibration sketch 63 scale.tare(); 64 // SDFP540 (0x9341) 65 66 tft.begin(0x9341); 67 68 pinMode (bott, INPUT_PULLUP); 69 pinMode(down, OUTPUT); 70 pinMode(up, OUTPUT); 71 pinMode(senup, INPUT); 72 pinMode(senmid, INPUT); 73 pinMode(sendown, INPUT); 74 pinMode(f1, INPUT_PULLUP); 75 pinMode(f2, INPUT_PULLUP); 76 pinMode(f3, INPUT_PULLUP); 77 pinMode(f4, INPUT_PULLUP); 78 pinMode(f5, INPUT_PULLUP); 79 pinMode(f6, INPUT_PULLUP); 80 pinMode(startkey, INPUT_PULLUP); 81 pinMode(stopkey, INPUT_PULLUP); 82 pinMode(printkey, INPUT_PULLUP); 83 pinMode(resetkey, INPUT_PULLUP); 84 pinMode(stor, INPUT_PULLUP); 85int value = 0; 86 87 /* printer.feed(1); 88 printer.justify('L'); 89 printer.println("Test Type: MANUAL"); 90 printer.feed(1); 91 printer.boldOn(); 92 printer.println("Ahesive Test : Roller Plate"); 93 printer.boldOff(); 94 printer.feed(2); 95 printer.setSize('S'); 96 printer.print("Average Force: "); 97 printer.print(avr); 98 printer.println(" N"); 99 printer.feed(1); 100 printer.print("Maximum Force: "); 101 printer.print(maxi); 102 printer.println(" N"); 103printer.feed(1); 104 printer.print("Number of samples:"); 105 printer.println(counter); 106 printer.feed(1); 107 printer.println("Speed ratio: "); 108 printer.println(counter); 109 110 printer.feed(2); 111 printer.justify('C'); 112 printer.setSize('M'); 113 printer.println("WWW.DNP-CO.IR"); 114 printer.feed(1); 115 printer.println("Tel: 09125221037"); 116 printer.feed(2); 117 printer.setSize('S'); 118 printer.justify('C'); 119 printer.println("...End of report..."); 120 printer.feed(3); 121 printer.wake(); 122 printer.setDefault(); 123 */ 124 125} 126//////////////////////////////////////////////////////////////////////////////1inch square 127void mili (void){ 128tft.fillScreen(BLACK); 129tft.setTextColor(YELLOW); tft.setTextSize(3); 130 tft.setCursor(20, 50); 131 tft.println(" 1 Inch Square Test."); 132tft.setTextColor(MAGENTA); 133tft.setTextSize(3); 134 tft.setCursor(10, 100); 135 tft.println("Please wait... "); 136 tft.setTextColor(WHITE); tft.setTextSize(2); 137 tft.setCursor(10, 200); 138 tft.println("The head is going to be set in the proper position"); 139 140 for(int i=25000; i>1; i--){ 141 digitalWrite(up, HIGH); 142 digitalWrite(down, HIGH); 143 delayMicroseconds(200); 144 digitalWrite(down, LOW); 145 delayMicroseconds(200); 146 } 147tft.fillScreen(BLACK); 148tft.setTextColor(YELLOW); tft.setTextSize(3); 149 tft.setCursor(20, 50); 150 tft.println("1 Inch Square Test."); 151tft.setTextColor(MAGENTA); 152tft.setTextSize(3); 153 tft.setCursor(10, 100); 154 tft.println("Please use a loop of adhesive tape with length of 25 cm and attach to the moving clamp."); 155 tft.setTextColor(WHITE); tft.setTextSize(2); 156 tft.setCursor(10, 220); 157 tft.println("Press START to start."); 158 tft.setCursor(10, 250); 159 tft.println("Press STOP to cancel."); 160while (true){ 161if (digitalRead (startkey) == LOW){ 162 tft.fillScreen(BLACK); 163tft.setTextColor(YELLOW); tft.setTextSize(3); 164 tft.setCursor(20, 50); 165 tft.println("Test is in progress..."); 166tft.setTextColor(MAGENTA); 167tft.setTextSize(3); 168 tft.setCursor(10, 100); 169 tft.println("Please wait to finish the test."); 170 tft.setTextColor(WHITE); tft.setTextSize(2); 171 tft.setCursor(10, 200); 172 for(int i=2000; i>1; i--){ 173 digitalWrite(up, HIGH); 174 digitalWrite(down, HIGH); 175 delay(1); 176 digitalWrite(down, LOW); 177 delay(1); 178 } 179 delay(500); 180 scale.tare(); 181 182 for(int j=30; j>1; j--){ 183 kilo = scale.get_units(); 184 kilo=kilo/10000; 185 kilo=kilo*1.15; 186counter ++; 187if (kilo > 70) alarm(); 188sum = sum+kilo; 189avr = sum/counter; 190if (kilo>maxi) maxi=kilo; 191 for(int i=100; i>1; i--){ 192 193 digitalWrite(down, HIGH); 194 digitalWrite(up, HIGH); 195 delay(1); 196 digitalWrite(up, LOW); 197 delay(1); 198 } 199 200} 201tft.setRotation(3); 202tft.fillScreen(BLACK); 203tft.setTextColor(YELLOW); tft.setTextSize(3); 204tft.setCursor(5, 50); 205tft.println("Test Is Finished."); 206//tft.setCursor(30, 104); 207//tft.setTextColor(WHITE); tft.setTextSize(2); 208//tft.println("Avarege Force:"); 209//tft.setTextColor(YELLOW); tft.setTextSize(3); 210//tft.setCursor(300,100); 211//tft.println(avr); 212//tft.setCursor(390, 100); 213//tft.println("N"); 214tft.setCursor(30, 134); 215tft.setTextColor(WHITE); tft.setTextSize(2); 216tft.println("Maximum Force:"); 217tft.setCursor(300, 130); 218tft.setTextColor(YELLOW); tft.setTextSize(3); 219tft.println(maxi); 220tft.setTextColor(WHITE); tft.setTextSize(2); 221tft.setCursor(390, 130); 222tft.println(" Newton"); 223tft.setCursor(30, 164); 224tft.setTextColor(WHITE); tft.setTextSize(2); 225tft.println("Number of samples:"); 226tft.setCursor(300, 160); 227tft.setTextColor(YELLOW); tft.setTextSize(3); 228tft.println(counter); 229tft.setCursor(30, 194); 230tft.setTextColor(WHITE); tft.setTextSize(2); 231tft.println("Speed rate:"); 232tft.setCursor(300, 190); 233tft.setTextColor(YELLOW); tft.setTextSize(3); 234tft.println("5 mm/s"); 235tft.setTextColor(CYAN); tft.setTextSize(2); 236tft.setCursor(5, 260); 237tft.println("To print results press PRINT."); 238tft.setTextColor(MAGENTA); tft.setTextSize(2); 239tft.setCursor(5, 290); 240tft.println("To restart press STOP."); 241 while (1){ 242if (digitalRead (stopkey) == LOW){ 243 loop(); 244} 245if (digitalRead (printkey) == LOW){ 246 tft.reset(); 247 248 printer.begin(); 249 printer.inverseOn(); 250 printer.justify('C'); 251 printer.setSize('L'); 252 printer.println("...MATT..."); 253 printer.inverseOff(); 254 printer.setSize('S'); 255 printer.println("Medical Adhesive Tape Test"); 256 printer.feed(1); 257 printer.justify('L'); 258 printer.println("Test Type: AUTOMATIC"); 259 printer.feed(1); 260 printer.boldOn(); 261 printer.println("Adhesive Test: 1Inch Square Test"); 262 printer.boldOff(); 263 printer.feed(2); 264 printer.setSize('S'); 265 // printer.print("Average Force: "); 266 //printer.print(avr); 267 //printer.println(" N"); 268 printer.feed(1); 269 printer.print("Maximum Force: "); 270 printer.print(maxi); 271 printer.println(" Newton"); 272printer.feed(1); 273 printer.print("Number of samples: "); 274 printer.println(counter); 275 printer.feed(1); 276 printer.print("Speed ratio: "); 277 printer.println("5 mm/s"); 278 279 printer.feed(2); 280 printer.justify('C'); 281 printer.setSize('M'); 282 printer.println("WWW.DNP-CO.IR"); 283 printer.feed(1); 284 printer.println("Tel: 09125221037"); 285 printer.feed(2); 286 printer.setSize('S'); 287 printer.justify('C'); 288 printer.println("...End of report..."); 289 printer.feed(3); 290 printer.wake(); 291 printer.setDefault(); 292 tft.begin(0x9341); 293 tft.setRotation(3); 294 loop(); 295} 296} 297 298} 299} 300} 301////////////////////////////////////////////////////////////////////////TERMINATION 302 void terminate (void) { 303 tft.fillScreen(BLACK); 304tft.setTextColor(YELLOW); tft.setTextSize(3); 305 tft.setCursor(5, 50); 306 tft.println("Test Is Terminated By User"); 307 tft.setTextColor(WHITE); tft.setTextSize(2); 308 tft.setCursor(5, 150); 309 tft.println("To print final result prees PRINT."); 310 tft.setCursor(5, 180); 311 tft.println("To store final result press STORE."); 312 tft.setTextColor(MAGENTA); tft.setTextSize(2); 313 tft.setCursor(5, 240); 314 tft.println("To restart press STOP."); 315while (1){ 316 if (digitalRead (stopkey) == LOW){ 317 loop(); 318 } 319 delay(1); 320} 321 322} 323 324/////////////////////////////////////////////////////////////////////////////////////////////-180degree 325void degree (void){ 326tft.fillScreen(BLACK); 327tft.setTextColor(YELLOW); tft.setTextSize(3); 328 tft.setCursor(20, 50); 329 tft.println(" 180 Degree Test."); 330tft.setTextColor(MAGENTA); 331tft.setTextSize(3); 332 tft.setCursor(10, 100); 333 tft.println("Please wait... "); 334 tft.setTextColor(WHITE); tft.setTextSize(2); 335 tft.setCursor(10, 200); 336 tft.println("The head is going to be set in the proper position"); 337 338 for(int i=25000; i>1; i--){ 339 digitalWrite(up, HIGH); 340 digitalWrite(down, HIGH); 341 delayMicroseconds(200); 342 digitalWrite(down, LOW); 343 delayMicroseconds(200); 344 } 345tft.fillScreen(BLACK); 346tft.setTextColor(YELLOW); tft.setTextSize(3); 347 tft.setCursor(20, 50); 348 tft.println("180 Degree Test."); 349tft.setTextColor(MAGENTA); 350tft.setTextSize(3); 351 tft.setCursor(10, 100); 352 tft.println("Please use appropret clamp and attache one side the specimen to the moving clamp and attache other side to plate."); 353 tft.setTextColor(WHITE); tft.setTextSize(2); 354 tft.setCursor(10, 260); 355 tft.println("Press START to start."); 356 tft.setCursor(10, 290); 357 tft.println("Press STOP to cancel."); 358while (true){ 359if (digitalRead (startkey) == LOW){ 360 tft.fillScreen(BLACK); 361tft.setTextColor(YELLOW); tft.setTextSize(3); 362 tft.setCursor(20, 50); 363 tft.println("Test is in progress..."); 364tft.setTextColor(MAGENTA); 365tft.setTextSize(3); 366 tft.setCursor(10, 100); 367 tft.println("please wait to finish te test."); 368 tft.setTextColor(WHITE); tft.setTextSize(2); 369 tft.setCursor(10, 200); 370 371 scale.tare(); 372 373 for(int j=110; j>1; j--){ 374 kilo = scale.get_units(); 375 kilo=kilo/10000; 376 kilo=kilo*1.15; 377counter ++; 378if (kilo > 70) alarm(); 379sum = sum+kilo; 380avr = sum/counter; 381if (kilo>maxi) maxi=kilo; 382 for(int i=100; i>1; i--){ 383 384 digitalWrite(down, HIGH); 385 digitalWrite(up, HIGH); 386 delay(1); 387 digitalWrite(up, LOW); 388 delay(1); 389 } 390 391} 392 393tft.setRotation(3); 394tft.fillScreen(BLACK); 395tft.setTextColor(YELLOW); tft.setTextSize(3); 396tft.setCursor(5, 50); 397tft.println("Test Is Finshed."); 398tft.setCursor(30, 104); 399tft.setTextColor(WHITE); tft.setTextSize(2); 400tft.println("Avarege Force:"); 401tft.setTextColor(YELLOW); tft.setTextSize(3); 402tft.setCursor(300,100); 403tft.println(avr); 404tft.setTextColor(WHITE); tft.setTextSize(2); 405tft.setCursor(390, 100); 406tft.println(" Newton"); 407tft.setCursor(30, 134); 408tft.setTextColor(WHITE); tft.setTextSize(2); 409tft.println("Maximum Force:"); 410tft.setCursor(300, 130); 411tft.setTextColor(YELLOW); tft.setTextSize(3); 412tft.println(maxi); 413tft.setTextColor(WHITE); tft.setTextSize(2); 414tft.setCursor(390, 130); 415tft.println(" Newton"); 416tft.setCursor(30, 164); 417tft.setTextColor(WHITE); tft.setTextSize(2); 418tft.println("Number of samples:"); 419tft.setCursor(300, 160); 420tft.setTextColor(YELLOW); tft.setTextSize(3); 421tft.println(counter); 422tft.setCursor(30, 194); 423tft.setTextColor(WHITE); tft.setTextSize(2); 424tft.println("Speed rate:"); 425tft.setCursor(300, 190); 426tft.setTextColor(YELLOW); tft.setTextSize(3); 427tft.println("5 mm/s"); 428tft.setTextColor(CYAN); tft.setTextSize(2); 429tft.setCursor(5, 260); 430tft.println("To print results press PRINT."); 431tft.setTextColor(MAGENTA); tft.setTextSize(2); 432tft.setCursor(5, 290); 433tft.println("To restart press STOP."); 434 while (1){ 435if (digitalRead (stopkey) == LOW){ 436 loop(); 437} 438if (digitalRead (printkey) == LOW){ 439 tft.reset(); 440 441 printer.begin(); 442 printer.inverseOn(); 443 printer.justify('C'); 444 printer.setSize('L'); 445 printer.println("...MATT..."); 446 printer.inverseOff(); 447 printer.setSize('S'); 448 printer.println("Medical Adhesive Tape Test"); 449 printer.feed(1); 450 printer.justify('L'); 451 printer.println("Test Type: AUTOMATIC"); 452 printer.feed(1); 453 printer.boldOn(); 454 printer.println("Adhesive Test: 180 degree"); 455 printer.boldOff(); 456 printer.feed(2); 457 printer.setSize('S'); 458 printer.print("Average Force: "); 459 printer.print(avr); 460 printer.println(" Newton"); 461 printer.feed(1); 462 printer.print("Maximum Force: "); 463 printer.print(maxi); 464 printer.println(" Newton"); 465printer.feed(1); 466 printer.print("Number of samples: "); 467 printer.println(counter); 468 printer.feed(1); 469 printer.print("Speed ratio: "); 470 printer.println("5 mm/s"); 471 472 printer.feed(2); 473 printer.justify('C'); 474 printer.setSize('M'); 475 printer.println("WWW.DNP-CO.IR"); 476 printer.feed(1); 477 printer.println("Tel: 09125221037"); 478 printer.feed(2); 479 printer.setSize('S'); 480 printer.justify('C'); 481 printer.println("...End of report..."); 482 printer.feed(3); 483 printer.wake(); 484 printer.setDefault(); 485 tft.begin(0x9341); 486 tft.setRotation(3); 487 loop(); 488} 489} 490 491 492} 493}} 494 495/////////////////////////////////////////////////////////alarm 496void alarm (void){ 497 tft.fillScreen(BLACK); 498tft.setTextColor(YELLOW); tft.setTextSize(3); 499 tft.setCursor(5, 50); 500 tft.println("ALARM!"); 501 tft.setTextColor(WHITE); tft.setTextSize(2); 502 tft.setCursor(5, 150); 503 tft.println("The force is raeched limit (>40 N)"); 504 tft.setCursor(5, 180); 505 tft.println("Please remove tape ad restart test."); 506 tft.setTextColor(MAGENTA); tft.setTextSize(2); 507 tft.setCursor(5, 240); 508 tft.println("To restart press STOP."); 509 while(true){ 510 if (digitalRead (stopkey) == LOW){ 511terminate(); 512 513}}} 514 ////////////////////////////////////////////////////////////////////////////////////////////////////////MAIN LOOP 515void loop(void) 516{ 517 518 519//////////////////////////////////////////////////////////////////////////////////////////////////////////Initialaizing 520 521kilo=0; 522maxi=0; 523sum=0; 524avr=0; 525counter=0; 526 527 /////////logo 528 tft.setRotation(3); 529 tft.fillScreen(WHITE); 530 tft.fillScreen(MAGENTA); 531 tft.fillScreen(WHITE); 532 tft.setTextColor(BLUE); 533 tft.setTextSize(7); 534 tft.setCursor(100, 50); 535 tft.println("M A T T"); 536 tft.setTextColor(CYAN); tft.setTextSize(3); 537 tft.setCursor(5, 150); 538 tft.println("Medical Adhesive Tape Test"); 539 tft.setTextColor(BLACK); tft.setTextSize(2); 540 tft.setCursor(20, 230); 541 tft.println("Designed and Developed by DNP co."); 542 tft.setCursor(20, 260); 543 tft.println("www.DNP-CO.ir"); 544 tft.setCursor(20, 290); 545 tft.println("Tel: +98-912 522 1037"); 546 delay(5000); 547/////////////////////// 548 549 tft.fillScreen(BLACK); 550 tft.setTextColor(WHITE); tft.setTextSize(1); 551 tft.setCursor(10, 10); 552 tft.println("Version. 2.6 Sep 2017"); 553 tft.setTextColor(WHITE); tft.setTextSize(3); 554 tft.setCursor(100, 50); 555 tft.println("Initializing..."); 556 tft.setTextColor(YELLOW); tft.setTextSize(2); 557 tft.setCursor(30, 100); 558 tft.println("Self Test:"); 559 tft.setCursor(30, 120); 560 tft.println("Limit Sensors, Motor, ROM, Loadcell "); 561 562 tft.setTextColor(WHITE); tft.setTextSize(2); 563 tft.setCursor(150, 150); 564 tft.println("Please wait..."); 565 566 tft.setTextColor(WHITE); tft.setTextSize(2); 567 tft.setCursor(10, 290); 568 tft.println("www.DNP-CO.ir 09125221037"); 569 570for (int n=3; n>0; n--){ 571 572 tft.setTextColor(YELLOW); tft.setTextSize(2); 573 tft.setCursor(210, 220); 574 tft.println(n); 575// tft.setCursor(210, 240); 576 // tft.println(kilo); 577 delay(1000); 578 tft.setTextColor(BLACK); tft.setTextSize(2); 579 tft.setCursor(210, 220); 580 tft.println(n); 581 // tft.setCursor(210, 240); 582 // tft.println(kilo); 583} 584//////////////////////////////////////////////////////////////////////////////////////////////////////////////////Auto Position 585tft.fillScreen(BLACK); 586 tft.setTextColor(YELLOW); tft.setTextSize(3); 587 tft.setCursor(50, 50); 588 tft.println("Auto Set Postition..."); 589 tft.setTextColor(WHITE); tft.setTextSize(2); 590 tft.setCursor(5, 100); 591 tft.println("Please wait while the haed is going to be set in the zero position."); 592 593 tft.setTextColor(WHITE); tft.setTextSize(2); 594 tft.setCursor(10, 270); 595 tft.println("www.DNP-CO.ir 09125221037"); 596 while (true) 597 { 598 599 600 digitalWrite(down, HIGH); 601 digitalWrite(up, HIGH); 602 delayMicroseconds(200); 603 digitalWrite(up, LOW); 604 delayMicroseconds(200); 605 if (digitalRead(senup)== HIGH){ 606 delay(10); 607 if(digitalRead(senup)==HIGH){ 608 break; 609 } 610 } 611 } 612 613 for (int m=200; m>0; m--){ 614 digitalWrite(up, HIGH); 615 digitalWrite(down, HIGH); 616delayMicroseconds(200); 617digitalWrite(down, LOW); 618delayMicroseconds(200); 619 620 } 621///////////////////////////////////////////////////////////////////////////////////////////////////////////////////Manual / Auto selection 622 tft.fillScreen(BLACK); 623 tft.setTextColor(YELLOW); tft.setTextSize(3); 624 tft.setCursor(20, 50); 625 tft.println("Please select Test Mode: "); 626 tft.setTextColor(WHITE); tft.setTextSize(3); 627 tft.setCursor(5, 130); 628 tft.println("For Manual press 1."); 629 tft.setCursor(5, 180); 630 tft.println("For Auto press 2"); 631 while (1){ 632 if (digitalRead(f1) == LOW){ 633manualmode(); 634 } 635if (digitalRead(f2) == LOW){ 636 tft.fillScreen(BLACK); 637tft.setTextColor(YELLOW); tft.setTextSize(3); 638 tft.setCursor(20, 50); 639 tft.println("Please select the type of test"); 640tft.setTextColor(WHITE); tft.setTextSize(2); 641 642 tft.setCursor(10, 200); 643 tft.println("For Tension Test press F1."); 644 tft.setCursor(10, 230); 645 tft.println("For Adhesive Test press F2."); 646 while (1){ 647 if (digitalRead(f1) == LOW){ 648tension(); 649 } 650 if (digitalRead(f2) == LOW){ 651 652 tft.fillScreen(BLACK); 653tft.setTextColor(YELLOW); tft.setTextSize(3); 654 tft.setCursor(20, 50); 655 tft.println("Adhesie test selection:"); 656tft.setTextColor(WHITE); tft.setTextSize(2); 657 tft.setCursor(10, 150); 658 tft.println("Roller Plate = F1"); 659 tft.setCursor(10, 180); 660 tft.println("1 Inch Square= F2."); 661tft.setCursor(10, 210); 662 tft.println("180 degree test = F3."); 663 tft.setTextColor(MAGENTA); 664 tft.setCursor(10, 270); 665 tft.println("To cancel press STOP."); 666 667while (true){ 668 if (digitalRead(f1) == LOW){ 669 rollerplate(); 670 671 } 672 if (digitalRead(f2) == LOW){ 673 674mili(); 675 } 676 if (digitalRead(f3) == LOW){ 677degree(); 678} 679 if (digitalRead(stopkey) == LOW){ 680terminate(); 681} 682} 683} 684} 685} 686} 687tft.fillScreen(BLACK); 688} 689///////////////////////////////////////////////////////////////////////////////////////////////////////////////////TENSION 690 void tension (void){ 691 tft.fillScreen(BLACK); 692tft.setTextColor(YELLOW); tft.setTextSize(3); 693 tft.setCursor(20, 50); 694 tft.println("Tension test."); 695tft.setTextColor(MAGENTA); 696tft.setTextSize(3); 697 tft.setCursor(10, 100); 698 tft.println("Please wait... "); 699 tft.setTextColor(WHITE); tft.setTextSize(2); 700 tft.setCursor(10, 200); 701 tft.println("The head is going to be set in the proper position."); 702 703 while (digitalRead(sendown) == LOW) 704 { 705 706 digitalWrite(up, HIGH); 707 digitalWrite(down, HIGH); 708delayMicroseconds(200); 709digitalWrite(down, LOW); 710delayMicroseconds(200); 711} 712 for (int m=1000; m>0; m--){ 713 digitalWrite(down, HIGH); 714 digitalWrite(up, HIGH); 715delayMicroseconds(200); 716digitalWrite(up, LOW); 717delayMicroseconds(200); 718 719 } 720 tft.fillScreen(BLACK); 721tft.setTextColor(YELLOW); tft.setTextSize(3); 722 tft.setCursor(20, 50); 723 tft.println("Tension test."); 724tft.setTextColor(MAGENTA); 725tft.setTextSize(3); 726 tft.setCursor(10, 100); 727 tft.println("Please attache appropriateclamp according to the width of tape."); 728 tft.setTextColor(WHITE); tft.setTextSize(2); 729 tft.setCursor(10, 200); 730 tft.println("Press START to start."); 731 tft.setCursor(10, 230); 732 tft.println("Press STOP to cancel."); 733 734while (true){ 735 if (digitalRead (startkey) == LOW){ 736 break;} 737 if (digitalRead (stopkey) == LOW){ 738 739terminate();} 740 741} 742 tft.fillScreen(BLACK); 743tft.setTextColor(YELLOW); tft.setTextSize(3); 744 tft.setCursor(20, 50); 745 tft.println("Test is in progress..."); 746tft.setTextColor(MAGENTA); 747tft.setTextSize(3); 748 tft.setCursor(10, 100); 749 tft.println("please wait to finish the test."); 750 tft.setTextColor(WHITE); tft.setTextSize(2); 751 tft.setCursor(10, 200); 752 753 tft.println("Press STOP to cancel."); 754 scale.tare(); 755 for (int i=0; i<1000 ; i++){ 756 if (digitalRead(senmid)== HIGH)break; 757 digitalWrite(down, HIGH); 758 digitalWrite(up, HIGH); 759 delay(1); 760 digitalWrite(up, LOW); 761 delay(1); 762 } 763 while (digitalRead(senmid) == LOW) 764 { 765 766 kilo = scale.get_units(); 767 kilo=kilo/10000; 768 kilo=kilo*1.15; 769counter ++; 770if (kilo > 70) alarm(); 771sum = sum+kilo; 772avr = sum/counter; 773if (kilo>maxi) maxi=kilo; 774 775if (digitalRead (stopkey) == LOW){ 776//....................................................................................................................................................................................... 777terminate();} 778for (int i=0; i<500 ; i++){ 779 if (digitalRead(senmid)== HIGH)break; 780 digitalWrite(down, HIGH); 781 digitalWrite(up, HIGH); 782 delay(1); 783 digitalWrite(up, LOW); 784 delay(1); 785 } 786 if(kilo < avr)break; 787 } 788////////////////////////result show 789tft.setRotation(3); 790tft.fillScreen(BLACK); 791tft.setTextColor(YELLOW); tft.setTextSize(3); 792tft.setCursor(5, 50); 793tft.println("Test Is Finshed."); 794//tft.setCursor(30, 104); 795//tft.setTextColor(WHITE); tft.setTextSize(2); 796//tft.println("Avarege Force:"); 797//tft.setTextColor(YELLOW); tft.setTextSize(2); 798//tft.setCursor(300,100); 799//tft.println(avr); 800//tft.setCursor(390, 100); 801//tft.println("Newton"); 802tft.setCursor(30, 134); 803tft.setTextColor(WHITE); tft.setTextSize(2); 804tft.println("Maximum Force:"); 805tft.setCursor(300, 130); 806tft.setTextColor(YELLOW); tft.setTextSize(3); 807tft.println(maxi); 808tft.setTextColor(YELLOW); tft.setTextSize(2); 809tft.setCursor(390, 130); 810tft.println(" Newton"); 811tft.setCursor(30, 164); 812tft.setTextColor(WHITE); tft.setTextSize(2); 813tft.println("Number of samples:"); 814tft.setCursor(300, 160); 815tft.setTextColor(YELLOW); tft.setTextSize(3); 816tft.println(counter); 817tft.setCursor(30, 194); 818tft.setTextColor(WHITE); tft.setTextSize(2); 819tft.println("Speed rate:"); 820tft.setCursor(300, 190); 821tft.setTextColor(YELLOW); tft.setTextSize(3); 822tft.println("5 mm/s"); 823tft.setTextColor(CYAN); tft.setTextSize(2); 824tft.setCursor(5, 260); 825tft.println("To print results press PRINT."); 826tft.setTextColor(MAGENTA); tft.setTextSize(2); 827tft.setCursor(5, 290); 828tft.println("To restart press STOP."); 829 while (1){ 830if (digitalRead (stopkey) == LOW){ 831 loop(); 832} 833if (digitalRead (printkey) == LOW){ 834 tft.reset(); 835 836 printer.begin(); 837 printer.inverseOn(); 838 printer.justify('C'); 839 printer.setSize('L'); 840 printer.println("...MATT..."); 841 printer.inverseOff(); 842 printer.setSize('S'); 843 printer.println("Medical Adhesive Tape Test"); 844 printer.feed(1); 845 printer.justify('L'); 846 printer.println("Test Type: AUTOMATIC"); 847 printer.feed(1); 848 printer.boldOn(); 849 printer.println("Tension Test"); 850 printer.boldOff(); 851 printer.feed(3); 852 // printer.setSize('S'); 853 // printer.print("Average Force: "); 854 // printer.print(avr); 855 // printer.println(" N"); 856 printer.feed(1); 857 printer.print("Maximum Force: "); 858 printer.print(maxi); 859 printer.println(" Newton"); 860printer.feed(1); 861 printer.print("Number of samples: "); 862 printer.println(counter); 863 printer.feed(1); 864 printer.print("Speed ratio: "); 865 printer.println("5 mm/s"); 866 867 printer.feed(2); 868 printer.justify('C'); 869 printer.setSize('M'); 870 printer.println("WWW.DNP-CO.IR"); 871 printer.feed(1); 872 printer.println("Tel: 09125221037"); 873 printer.feed(2); 874 printer.setSize('S'); 875 printer.justify('C'); 876 printer.println("...End of report..."); 877 printer.feed(3); 878 printer.wake(); 879 printer.setDefault(); 880 tft.begin(0x9341); 881 tft.setRotation(3); 882 loop(); 883} 884} ///////////////////////////////////// 885 } 886 ////////////////////////////////////////////////////////////////////////////////ROLLER PLATE 887void rollerplate (void){ 888 tft.fillScreen(BLACK); 889tft.setTextColor(YELLOW); tft.setTextSize(3); 890 tft.setCursor(20, 50); 891 tft.println("Roller Plate Test."); 892tft.setTextColor(MAGENTA); 893tft.setTextSize(3); 894 tft.setCursor(10, 100); 895 tft.println("Please wait... "); 896 tft.setTextColor(WHITE); tft.setTextSize(2); 897 tft.setCursor(10, 200); 898 tft.println("The head is going to be set in the proper position"); 899 while (digitalRead(sendown) == LOW) 900 { 901 digitalWrite(up, HIGH); 902 digitalWrite(down, HIGH); 903delayMicroseconds(200); 904digitalWrite(down, LOW); 905delayMicroseconds(200); 906} 907 for (int m=500; m>0; m--){ 908 digitalWrite(down, HIGH); 909 digitalWrite(up, HIGH); 910delayMicroseconds(200); 911digitalWrite(up, LOW); 912delayMicroseconds(200); 913 914 } 915tft.fillScreen(BLACK); 916tft.setTextColor(YELLOW); tft.setTextSize(3); 917 tft.setCursor(20, 50); 918 tft.println("Tension test."); 919tft.setTextColor(MAGENTA); 920tft.setTextSize(3); 921 tft.setCursor(10, 105); 922 tft.println("Please attache Roller Plate. "); 923 tft.setTextColor(WHITE); tft.setTextSize(2); 924 tft.setCursor(10, 200); 925 tft.println("Press START to start."); 926 tft.setCursor(10, 230); 927 tft.println("Press STOP to cancel."); 928while (true){ 929if (digitalRead (startkey) == LOW){ 930break; 931 } 932 if (digitalRead (stopkey) == LOW){ 933terminate(); 934 } 935} 936 tft.fillScreen(BLACK); 937tft.setTextColor(YELLOW); tft.setTextSize(3); 938 tft.setCursor(20, 50); 939 tft.println("Test is in progress..."); 940tft.setTextColor(MAGENTA); 941tft.setTextSize(3); 942 tft.setCursor(10, 100); 943 tft.println("Please wait to finish the test."); 944 tft.setTextColor(WHITE); tft.setTextSize(2); 945 tft.setCursor(10, 200); 946 947 tft.println("Press STOP to cancel."); 948 scale.tare(); 949 950 while (digitalRead(senmid) == LOW) 951 { 952 while (digitalRead(senmid) == LOW) { 953 kilo = scale.get_units(); 954 kilo=kilo/10000; 955 kilo=kilo*1.15; 956counter ++; 957if (kilo > 70) alarm(); 958sum = sum+kilo; 959avr = sum/counter; 960if (kilo>maxi) maxi=kilo; 961for (int i=0; i<100 ; i++){ 962 digitalWrite(down, HIGH); 963 digitalWrite(up, HIGH); 964 delay(1); 965 digitalWrite(up, LOW); 966 delay(1); 967 digitalWrite (stopkey, HIGH); 968 int key =0; 969 key = digitalRead (stopkey); 970 if (key == LOW) { 971 972 terminate(); } 973 }} 974 975 } 976 for (int m=500; m>0; m--){ 977 digitalWrite(up, HIGH); 978 digitalWrite(down, HIGH); 979 delay(1); 980 digitalWrite(down, LOW); 981 delay(1); 982 983 } 984 985 986 tft.setRotation(3); 987tft.fillScreen(BLACK); 988tft.setTextColor(YELLOW); tft.setTextSize(3); 989tft.setCursor(5, 50); 990tft.println("Test Is Finshed."); 991tft.setCursor(30, 104); 992tft.setTextColor(WHITE); tft.setTextSize(2); 993tft.println("Avarege Force:"); 994tft.setTextColor(YELLOW); tft.setTextSize(3); 995tft.setCursor(300,100); 996tft.println(avr); 997tft.setTextColor(WHITE); tft.setTextSize(2); 998tft.setCursor(390, 100); 999tft.println(" Newton"); 1000tft.setCursor(30, 134); 1001tft.setTextColor(WHITE); tft.setTextSize(2); 1002tft.println("Maximum Force:"); 1003tft.setCursor(300, 130); 1004tft.setTextColor(YELLOW); tft.setTextSize(3); 1005tft.println(maxi); 1006tft.setTextColor(WHITE); tft.setTextSize(2); 1007tft.setCursor(390, 130); 1008tft.println(" Newton"); 1009tft.setCursor(30, 164); 1010tft.setTextColor(WHITE); tft.setTextSize(2); 1011tft.println("Number of samples:"); 1012tft.setCursor(300, 160); 1013tft.setTextColor(YELLOW); tft.setTextSize(3); 1014tft.println(counter); 1015tft.setCursor(30, 194); 1016tft.setTextColor(WHITE); tft.setTextSize(2); 1017tft.println("Speed rate:"); 1018tft.setCursor(300, 190); 1019tft.setTextColor(YELLOW); tft.setTextSize(3); 1020tft.println("5 mm/s"); 1021tft.setTextColor(CYAN); tft.setTextSize(2); 1022tft.setCursor(5, 260); 1023tft.println("To print results press PRINT."); 1024tft.setTextColor(MAGENTA); tft.setTextSize(2); 1025tft.setCursor(5, 290); 1026tft.println("To restart press STOP."); 1027 while (1){ 1028if (digitalRead (stopkey) == LOW){ 1029 tft.fillScreen(BLACK); 1030tft.setTextColor(YELLOW); tft.setTextSize(4); 1031tft.setCursor(5, 50); 1032tft.println("WARRNING!!!"); 1033tft.setCursor(30, 104); 1034tft.setTextColor(WHITE); tft.setTextSize(3); 1035tft.println("Remove plate's cable from the head."); 1036tft.setTextColor(MAGENTA); tft.setTextSize(2); 1037tft.setCursor(5, 290); 1038tft.println("To restart press STOP."); 1039while(true){ 1040if (digitalRead (stopkey) == LOW){ 1041 loop();}} 1042} 1043if (digitalRead (printkey) == LOW){ 1044 tft.reset(); 1045 1046 printer.begin(); 1047 printer.inverseOn(); 1048 printer.justify('C'); 1049 printer.setSize('L'); 1050 printer.println("...MATT..."); 1051 printer.inverseOff(); 1052 printer.setSize('S'); 1053 printer.println("Medical Adhesive Tape Test"); 1054 printer.feed(1); 1055 printer.justify('L'); 1056 printer.println("Test Type: AUTOMATIC"); 1057 printer.feed(1); 1058 printer.boldOn(); 1059 printer.println("Adhesive Test: Roller Plate"); 1060 printer.boldOff(); 1061 printer.feed(2); 1062 printer.setSize('S'); 1063 printer.print("Average Force: "); 1064 printer.print(avr); 1065 printer.println(" Newton"); 1066 printer.feed(1); 1067 printer.print("Maximum Force: "); 1068 printer.print(maxi); 1069 printer.println(" Newton"); 1070printer.feed(1); 1071 printer.print("Number of samples: "); 1072 printer.println(counter); 1073 printer.feed(1); 1074 printer.print("Speed ratio: "); 1075 printer.println("5 mm/s"); 1076 1077 printer.feed(2); 1078 printer.justify('C'); 1079 printer.setSize('M'); 1080 printer.println("WWW.DNP-CO.IR"); 1081 printer.feed(1); 1082 printer.println("Tel: 09125221037"); 1083 printer.feed(2); 1084 printer.setSize('S'); 1085 printer.justify('C'); 1086 printer.println("...End of report..."); 1087 printer.feed(3); 1088 printer.wake(); 1089 printer.setDefault(); 1090 tft.begin(0x9341); 1091 tft.setRotation(3); 1092 1093 tft.fillScreen(BLACK); 1094tft.setTextColor(YELLOW); tft.setTextSize(4); 1095tft.setCursor(5, 50); 1096tft.println("WARRNING!!!"); 1097tft.setCursor(30, 104); 1098tft.setTextColor(WHITE); tft.setTextSize(3); 1099tft.println("Remove plate's cable from the head."); 1100 1101tft.setTextColor(MAGENTA); tft.setTextSize(2); 1102tft.setCursor(5, 290); 1103tft.println("To restart press STOP."); 1104while(true){ 1105if (digitalRead (stopkey) == LOW){ 1106 loop();}} 1107} 1108} 1109} 1110 1111/////////////////////////////////////////////////////////////////////////////////////////////////////////////MANUAL MODE 1112 void manualmode (void) 1113 { 1114 1115 tft.fillScreen(BLACK); 1116tft.setTextColor(YELLOW); tft.setTextSize(3); 1117 tft.setCursor(20, 50); 1118 tft.println("Manual Mode is selected"); 1119tft.setTextColor(WHITE); tft.setTextSize(2); 1120 tft.setCursor(10, 150); 1121 tft.println("Press START to continiu."); 1122 tft.setCursor(10, 200); 1123 tft.println("Press STOP to cancel."); 1124 while (1){ 1125 if (digitalRead (startkey) == LOW){ 1126 goto manual; 1127 } 1128 if (digitalRead (stopkey) == LOW){ 1129 terminate(); 1130 } 1131 } 1132 manual: 1133 /////////////////////////////////////////////////////////////////////////////////////////////////////////joystick 1134 kilo=0; 1135 maxi=0; 1136 counter=0; 1137 avr=0; 1138maxi=0; 1139sum=0; 1140int value =0; 1141 tft.fillScreen(BLACK); 1142tft.setTextColor(YELLOW); tft.setTextSize(2); 1143 tft.setCursor(5, 50); 1144 tft.println("Use Joystick to move head up and down."); 1145 tft.setCursor(5, 100); 1146 tft.println(""); 1147 tft.setCursor(5, 150); 1148 tft.println("To finish test press STOP."); 1149 tft.setTextColor(WHITE); tft.setTextSize(4); 1150 1151scale.tare(); 1152while(true) 1153 { 1154 delay(500); 1155 value = analogRead(joystic); 1156 value = value/100; 1157 if (digitalRead (stopkey) == LOW){ 1158 break; 1159 }/*////// 1160 kilo = scale.get_units(); 1161 kilo=kilo/10000; 1162 kilo=kilo*1.15; 1163counter ++; 1164if (kilo > 70) alarm(); 1165sum = sum+kilo; 1166avr = sum/counter; 1167if (kilo>maxi) maxi=kilo; 1168 */////// 1169 1170 while (value>7){ 1171for(int i=200; i>1; i--){ 1172 digitalWrite(down, HIGH); 1173 digitalWrite(up, HIGH); 1174delayMicroseconds(700); 1175digitalWrite(up, LOW); 1176delayMicroseconds(700); 1177} 1178 kilo = scale.get_units(); 1179 kilo=kilo/10000; 1180 kilo=kilo*1.15; 1181counter ++; 1182if (kilo > 70) alarm(); 1183sum = sum+kilo; 1184avr = sum/counter; 1185if (kilo>maxi) maxi=kilo; 1186 value = analogRead(joystic); 1187 value = value/100; 1188 } 1189 1190 while( value<3){ 1191 1192 digitalWrite(up, HIGH); 1193 digitalWrite(down, HIGH); 1194delayMicroseconds(200); 1195digitalWrite(down, LOW); 1196delayMicroseconds(200); 1197value = analogRead(joystic); 1198 value = value/100; 1199 } 1200} 1201tft.setRotation(3); 1202tft.fillScreen(BLACK); 1203tft.setTextColor(YELLOW); tft.setTextSize(3); 1204tft.setCursor(5, 50); 1205tft.println("Test Is Finshed."); 1206tft.setCursor(30, 104); 1207tft.setTextColor(WHITE); tft.setTextSize(2); 1208tft.println("Avarege Force:"); 1209tft.setTextColor(YELLOW); tft.setTextSize(3); 1210tft.setCursor(300,100); 1211tft.println(avr); 1212tft.setTextColor(WHITE); tft.setTextSize(2); 1213tft.setCursor(390, 100); 1214tft.println(" Newton"); 1215tft.setCursor(30, 134); 1216tft.setTextColor(WHITE); tft.setTextSize(2); 1217tft.println("Maximum Force:"); 1218tft.setCursor(300, 130); 1219tft.setTextColor(YELLOW); tft.setTextSize(3); 1220tft.println(maxi); 1221tft.setTextColor(WHITE); tft.setTextSize(2); 1222tft.setCursor(390, 130); 1223tft.println(" Newton"); 1224tft.setCursor(30, 164); 1225tft.setTextColor(WHITE); tft.setTextSize(2); 1226tft.println("Number of samples:"); 1227tft.setCursor(300, 160); 1228tft.setTextColor(YELLOW); tft.setTextSize(3); 1229tft.println(counter); 1230 1231 1232tft.setTextColor(MAGENTA); tft.setTextSize(2); 1233tft.setCursor(5, 260); 1234tft.println("To restart press STOP."); 1235 while (1){ 1236if (digitalRead (stopkey) == LOW){ 1237 goto manual; 1238} 1239if (digitalRead (resetkey) == LOW){ 1240 loop(); 1241} 1242if (digitalRead (printkey) == LOW){ 1243 tft.reset(); 1244 1245 printer.begin(); 1246 printer.inverseOn(); 1247 printer.justify('C'); 1248 printer.setSize('L'); 1249 printer.println("...MATT..."); 1250 printer.inverseOff(); 1251 printer.setSize('S'); 1252 printer.println("Medical Adhesive Tape Test"); 1253 printer.feed(1); 1254 printer.justify('L'); 1255 printer.println("Test Type: MANUAL"); 1256 printer.feed(1); 1257 printer.boldOn(); 1258 printer.println("Tension Test"); 1259 printer.boldOff(); 1260 printer.feed(2); 1261 printer.setSize('S'); 1262 printer.print("Average Force: "); 1263 printer.print(avr); 1264 printer.println(" Newton"); 1265 printer.feed(1); 1266 printer.print("Maximum Force: "); 1267 printer.print(maxi); 1268 printer.println(" Newton"); 1269printer.feed(1); 1270 printer.print("Number of samples: "); 1271 1272 printer.feed(2); 1273 printer.justify('C'); 1274 printer.setSize('M'); 1275 printer.println("WWW.DNP-CO.IR"); 1276 printer.feed(1); 1277 printer.println("Tel: 09125221037"); 1278 printer.feed(2); 1279 printer.setSize('S'); 1280 printer.justify('C'); 1281 printer.println("...End of report..."); 1282 printer.feed(3); 1283 printer.wake(); 1284 printer.setDefault(); 1285 tft.begin(0x9341); 1286 tft.setRotation(3); 1287 goto manual; 1288 1289} 1290} 1291 1292 } 1293 1294 1295 1296
MATT.ino
arduino
1r// ***In the name of allah***// 2//this program is written by Mahdi 3 Hajy Alimohamadi for MATT machin. its inclouded all function for load cell, thermal 4 printer, joystic , TFT LCD// 5//date of last freamware 02/2017 6#include "Adafruit_Thermal.h" 7Adafruit_Thermal 8 printer(&Serial2); 9#include <SPFD5408_Adafruit_GFX.h> // Core graphics library 10#include 11 <SPFD5408_Adafruit_TFTLCD.h> // Hardware-specific library 12#include <SPFD5408_TouchScreen.h> 13#include 14 <SD.h> 15#include <SPI.h> 16#include "HX711.h" 17#define calibration_factor 18 -7050.0 19#define SD_CS 10 20#define LCD_CS A3 // Chip Select goes to Analog 21 3 22#define LCD_CD A2 // Command/Data goes to Analog 2 23#define LCD_WR A1 // 24 LCD Write goes to Analog 1 25#define LCD_RD A0 // LCD Read goes to Analog 0 26#define 27 LCD_RESET A4 // Can alternately just connect to Arduino's reset pin 28 // Assign 29 human-readable names to some common 16-bit color values: 30#define BLACK 0x0000 31#define 32 BLUE 0x001F 33#define RED 0xF800 34#define GREEN 0x07E0 35#define CYAN 36 0x07FF 37#define MAGENTA 0xF81F 38#define YELLOW 0xFFE0 39#define WHITE 40 0xFFFF 41 #define DOUT 22 42#define CLK 23 43HX711 scale(DOUT, CLK); 44Adafruit_TFTLCD 45 tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET); 46int down= 39; 47int up = 38; 48int 49 senup = 51; 50int senmid = 52; 51int sendown = 53; 52int joystic = A15; 53int 54 bott = 26; 55 float kilo = 0; 56 float avr =0; 57 float maxi=0; 58 float sum=0; 59 60 int counter=0; 61const int f1 = 50; 62const int f2 = 49; 63const int f3 = 48; 64const 65 int f4 = 47; 66const int f5 = 46; 67const int f6 = 45; 68const int startkey = 69 44; 70const int stopkey = 43; 71const int printkey = 42; 72const int stor = 41; 73const 74 int resetkey = 40; 75 76void setup(void) 77{ 78 79 80 81 Serial2.begin(9600); 82//scale.set_scale(calibration_factor); 83 //This value is obtained by using the SparkFun_HX711_Calibration sketch 84 scale.tare(); 85 86 // SDFP540 (0x9341) 87 88 tft.begin(0x9341); 89 90 pinMode (bott, INPUT_PULLUP); 91 92 pinMode(down, OUTPUT); 93 pinMode(up, OUTPUT); 94 pinMode(senup, INPUT); 95 96 pinMode(senmid, INPUT); 97 pinMode(sendown, INPUT); 98 pinMode(f1, INPUT_PULLUP); 99 100 pinMode(f2, INPUT_PULLUP); 101 pinMode(f3, INPUT_PULLUP); 102 pinMode(f4, 103 INPUT_PULLUP); 104 pinMode(f5, INPUT_PULLUP); 105 pinMode(f6, INPUT_PULLUP); 106 107 pinMode(startkey, INPUT_PULLUP); 108 pinMode(stopkey, INPUT_PULLUP); 109 110 pinMode(printkey, INPUT_PULLUP); 111 pinMode(resetkey, INPUT_PULLUP); 112 pinMode(stor, 113 INPUT_PULLUP); 114int value = 0; 115 116 /* printer.feed(1); 117 printer.justify('L'); 118 119 printer.println("Test Type: MANUAL"); 120 printer.feed(1); 121 printer.boldOn(); 122 123 printer.println("Ahesive Test : Roller Plate"); 124 printer.boldOff(); 125 126 printer.feed(2); 127 printer.setSize('S'); 128 printer.print("Average Force: 129 "); 130 printer.print(avr); 131 printer.println(" N"); 132 printer.feed(1); 133 134 printer.print("Maximum Force: "); 135 printer.print(maxi); 136 printer.println(" 137 N"); 138printer.feed(1); 139 printer.print("Number of samples:"); 140 printer.println(counter); 141 142 printer.feed(1); 143 printer.println("Speed ratio: "); 144 printer.println(counter); 145 146 147 printer.feed(2); 148 printer.justify('C'); 149 printer.setSize('M'); 150 printer.println("WWW.DNP-CO.IR"); 151 152 printer.feed(1); 153 printer.println("Tel: 09125221037"); 154 printer.feed(2); 155 156 printer.setSize('S'); 157 printer.justify('C'); 158 printer.println("...End 159 of report..."); 160 printer.feed(3); 161 printer.wake(); 162 printer.setDefault(); 163 164 */ 165 166} 167//////////////////////////////////////////////////////////////////////////////1inch 168 square 169void mili (void){ 170tft.fillScreen(BLACK); 171tft.setTextColor(YELLOW); 172 tft.setTextSize(3); 173 tft.setCursor(20, 50); 174 tft.println(" 175 1 Inch Square Test."); 176tft.setTextColor(MAGENTA); 177tft.setTextSize(3); 178 179 tft.setCursor(10, 100); 180 tft.println("Please wait... "); 181 182 tft.setTextColor(WHITE); tft.setTextSize(2); 183 tft.setCursor(10, 184 200); 185 tft.println("The head is going to be set in the proper position"); 186 187 188 for(int i=25000; i>1; i--){ 189 digitalWrite(up, HIGH); 190 digitalWrite(down, 191 HIGH); 192 delayMicroseconds(200); 193 digitalWrite(down, 194 LOW); 195 delayMicroseconds(200); 196 } 197tft.fillScreen(BLACK); 198tft.setTextColor(YELLOW); 199 tft.setTextSize(3); 200 tft.setCursor(20, 50); 201 tft.println("1 202 Inch Square Test."); 203tft.setTextColor(MAGENTA); 204tft.setTextSize(3); 205 206 tft.setCursor(10, 100); 207 tft.println("Please use a loop of adhesive 208 tape with length of 25 cm and attach to the moving clamp."); 209 tft.setTextColor(WHITE); 210 tft.setTextSize(2); 211 tft.setCursor(10, 220); 212 tft.println("Press 213 START to start."); 214 tft.setCursor(10, 250); 215 tft.println("Press 216 STOP to cancel."); 217while (true){ 218if (digitalRead (startkey) == LOW){ 219 220 tft.fillScreen(BLACK); 221tft.setTextColor(YELLOW); tft.setTextSize(3); 222 tft.setCursor(20, 223 50); 224 tft.println("Test is in progress..."); 225tft.setTextColor(MAGENTA); 226 227tft.setTextSize(3); 228 tft.setCursor(10, 100); 229 tft.println("Please 230 wait to finish the test."); 231 tft.setTextColor(WHITE); tft.setTextSize(2); 232 233 tft.setCursor(10, 200); 234 for(int i=2000; i>1; i--){ 235 digitalWrite(up, 236 HIGH); 237 digitalWrite(down, HIGH); 238 delay(1); 239 240 digitalWrite(down, LOW); 241 delay(1); 242 } 243 delay(500); 244 245 scale.tare(); 246 247 for(int j=30; j>1; j--){ 248 kilo = scale.get_units(); 249 250 kilo=kilo/10000; 251 kilo=kilo*1.15; 252counter ++; 253if (kilo > 70) alarm(); 254sum 255 = sum+kilo; 256avr = sum/counter; 257if (kilo>maxi) maxi=kilo; 258 for(int i=100; 259 i>1; i--){ 260 261 digitalWrite(down, HIGH); 262 digitalWrite(up, HIGH); 263 264 delay(1); 265 digitalWrite(up, LOW); 266 delay(1); 267 268 } 269 270} 271tft.setRotation(3); 272tft.fillScreen(BLACK); 273tft.setTextColor(YELLOW); 274 tft.setTextSize(3); 275tft.setCursor(5, 50); 276tft.println("Test Is Finished."); 277//tft.setCursor(30, 278 104); 279//tft.setTextColor(WHITE); tft.setTextSize(2); 280//tft.println("Avarege 281 Force:"); 282//tft.setTextColor(YELLOW); tft.setTextSize(3); 283//tft.setCursor(300,100); 284//tft.println(avr); 285//tft.setCursor(390, 286 100); 287//tft.println("N"); 288tft.setCursor(30, 134); 289tft.setTextColor(WHITE); 290 tft.setTextSize(2); 291tft.println("Maximum Force:"); 292tft.setCursor(300, 293 130); 294tft.setTextColor(YELLOW); tft.setTextSize(3); 295tft.println(maxi); 296tft.setTextColor(WHITE); 297 tft.setTextSize(2); 298tft.setCursor(390, 130); 299tft.println(" Newton"); 300tft.setCursor(30, 301 164); 302tft.setTextColor(WHITE); tft.setTextSize(2); 303tft.println("Number of 304 samples:"); 305tft.setCursor(300, 160); 306tft.setTextColor(YELLOW); tft.setTextSize(3); 307tft.println(counter); 308 309tft.setCursor(30, 194); 310tft.setTextColor(WHITE); tft.setTextSize(2); 311tft.println("Speed 312 rate:"); 313tft.setCursor(300, 190); 314tft.setTextColor(YELLOW); tft.setTextSize(3); 315tft.println("5 316 mm/s"); 317tft.setTextColor(CYAN); tft.setTextSize(2); 318tft.setCursor(5, 260); 319tft.println("To 320 print results press PRINT."); 321tft.setTextColor(MAGENTA); tft.setTextSize(2); 322tft.setCursor(5, 323 290); 324tft.println("To restart press STOP."); 325 while (1){ 326if 327 (digitalRead (stopkey) == LOW){ 328 loop(); 329} 330if (digitalRead (printkey) 331 == LOW){ 332 tft.reset(); 333 334 printer.begin(); 335 printer.inverseOn(); 336 337 printer.justify('C'); 338 printer.setSize('L'); 339 printer.println("...MATT..."); 340 341 printer.inverseOff(); 342 printer.setSize('S'); 343 printer.println("Medical 344 Adhesive Tape Test"); 345 printer.feed(1); 346 printer.justify('L'); 347 printer.println("Test 348 Type: AUTOMATIC"); 349 printer.feed(1); 350 printer.boldOn(); 351 printer.println("Adhesive 352 Test: 1Inch Square Test"); 353 printer.boldOff(); 354 printer.feed(2); 355 printer.setSize('S'); 356 357 // printer.print("Average Force: "); 358 //printer.print(avr); 359 //printer.println(" 360 N"); 361 printer.feed(1); 362 printer.print("Maximum Force: "); 363 printer.print(maxi); 364 365 printer.println(" Newton"); 366printer.feed(1); 367 printer.print("Number 368 of samples: "); 369 printer.println(counter); 370 printer.feed(1); 371 printer.print("Speed 372 ratio: "); 373 printer.println("5 mm/s"); 374 375 printer.feed(2); 376 377 printer.justify('C'); 378 printer.setSize('M'); 379 printer.println("WWW.DNP-CO.IR"); 380 381 printer.feed(1); 382 printer.println("Tel: 09125221037"); 383 printer.feed(2); 384 385 printer.setSize('S'); 386 printer.justify('C'); 387 printer.println("...End 388 of report..."); 389 printer.feed(3); 390 printer.wake(); 391 printer.setDefault(); 392 393 tft.begin(0x9341); 394 tft.setRotation(3); 395 loop(); 396} 397} 398 399} 400 401} 402} 403////////////////////////////////////////////////////////////////////////TERMINATION 404 405 void terminate (void) { 406 tft.fillScreen(BLACK); 407tft.setTextColor(YELLOW); 408 tft.setTextSize(3); 409 tft.setCursor(5, 50); 410 tft.println("Test 411 Is Terminated By User"); 412 tft.setTextColor(WHITE); tft.setTextSize(2); 413 414 tft.setCursor(5, 150); 415 tft.println("To print final result prees 416 PRINT."); 417 tft.setCursor(5, 180); 418 tft.println("To 419 store final result press STORE."); 420 tft.setTextColor(MAGENTA); 421 tft.setTextSize(2); 422 tft.setCursor(5, 240); 423 tft.println("To 424 restart press STOP."); 425while (1){ 426 if (digitalRead (stopkey) == LOW){ 427 428 loop(); 429 } 430 delay(1); 431} 432 433} 434 435/////////////////////////////////////////////////////////////////////////////////////////////-180degree 436void 437 degree (void){ 438tft.fillScreen(BLACK); 439tft.setTextColor(YELLOW); tft.setTextSize(3); 440 441 tft.setCursor(20, 50); 442 tft.println(" 180 Degree Test."); 443tft.setTextColor(MAGENTA); 444 445tft.setTextSize(3); 446 tft.setCursor(10, 100); 447 tft.println("Please 448 wait... "); 449 tft.setTextColor(WHITE); tft.setTextSize(2); 450 tft.setCursor(10, 451 200); 452 tft.println("The head is going to be set in the proper position"); 453 454 455 for(int i=25000; i>1; i--){ 456 digitalWrite(up, HIGH); 457 digitalWrite(down, 458 HIGH); 459 delayMicroseconds(200); 460 digitalWrite(down, 461 LOW); 462 delayMicroseconds(200); 463 } 464tft.fillScreen(BLACK); 465tft.setTextColor(YELLOW); 466 tft.setTextSize(3); 467 tft.setCursor(20, 50); 468 tft.println("180 469 Degree Test."); 470tft.setTextColor(MAGENTA); 471tft.setTextSize(3); 472 tft.setCursor(10, 473 100); 474 tft.println("Please use appropret clamp and attache one side the 475 specimen to the moving clamp and attache other side to plate."); 476 tft.setTextColor(WHITE); 477 tft.setTextSize(2); 478 tft.setCursor(10, 260); 479 tft.println("Press 480 START to start."); 481 tft.setCursor(10, 290); 482 tft.println("Press 483 STOP to cancel."); 484while (true){ 485if (digitalRead (startkey) == LOW){ 486 487 tft.fillScreen(BLACK); 488tft.setTextColor(YELLOW); tft.setTextSize(3); 489 tft.setCursor(20, 490 50); 491 tft.println("Test is in progress..."); 492tft.setTextColor(MAGENTA); 493 494tft.setTextSize(3); 495 tft.setCursor(10, 100); 496 tft.println("please 497 wait to finish te test."); 498 tft.setTextColor(WHITE); tft.setTextSize(2); 499 500 tft.setCursor(10, 200); 501 502 scale.tare(); 503 504 for(int 505 j=110; j>1; j--){ 506 kilo = scale.get_units(); 507 kilo=kilo/10000; 508 kilo=kilo*1.15; 509counter 510 ++; 511if (kilo > 70) alarm(); 512sum = sum+kilo; 513avr = sum/counter; 514if (kilo>maxi) 515 maxi=kilo; 516 for(int i=100; i>1; i--){ 517 518 digitalWrite(down, HIGH); 519 520 digitalWrite(up, HIGH); 521 delay(1); 522 digitalWrite(up, 523 LOW); 524 delay(1); 525 } 526 527} 528 529tft.setRotation(3); 530tft.fillScreen(BLACK); 531tft.setTextColor(YELLOW); 532 tft.setTextSize(3); 533tft.setCursor(5, 50); 534tft.println("Test Is Finshed."); 535tft.setCursor(30, 536 104); 537tft.setTextColor(WHITE); tft.setTextSize(2); 538tft.println("Avarege 539 Force:"); 540tft.setTextColor(YELLOW); tft.setTextSize(3); 541tft.setCursor(300,100); 542tft.println(avr); 543tft.setTextColor(WHITE); 544 tft.setTextSize(2); 545tft.setCursor(390, 100); 546tft.println(" Newton"); 547tft.setCursor(30, 548 134); 549tft.setTextColor(WHITE); tft.setTextSize(2); 550tft.println("Maximum 551 Force:"); 552tft.setCursor(300, 130); 553tft.setTextColor(YELLOW); tft.setTextSize(3); 554tft.println(maxi); 555tft.setTextColor(WHITE); 556 tft.setTextSize(2); 557tft.setCursor(390, 130); 558tft.println(" Newton"); 559tft.setCursor(30, 560 164); 561tft.setTextColor(WHITE); tft.setTextSize(2); 562tft.println("Number of 563 samples:"); 564tft.setCursor(300, 160); 565tft.setTextColor(YELLOW); tft.setTextSize(3); 566tft.println(counter); 567 568tft.setCursor(30, 194); 569tft.setTextColor(WHITE); tft.setTextSize(2); 570tft.println("Speed 571 rate:"); 572tft.setCursor(300, 190); 573tft.setTextColor(YELLOW); tft.setTextSize(3); 574tft.println("5 575 mm/s"); 576tft.setTextColor(CYAN); tft.setTextSize(2); 577tft.setCursor(5, 260); 578tft.println("To 579 print results press PRINT."); 580tft.setTextColor(MAGENTA); tft.setTextSize(2); 581tft.setCursor(5, 582 290); 583tft.println("To restart press STOP."); 584 while (1){ 585if 586 (digitalRead (stopkey) == LOW){ 587 loop(); 588} 589if (digitalRead (printkey) 590 == LOW){ 591 tft.reset(); 592 593 printer.begin(); 594 printer.inverseOn(); 595 596 printer.justify('C'); 597 printer.setSize('L'); 598 printer.println("...MATT..."); 599 600 printer.inverseOff(); 601 printer.setSize('S'); 602 printer.println("Medical 603 Adhesive Tape Test"); 604 printer.feed(1); 605 printer.justify('L'); 606 printer.println("Test 607 Type: AUTOMATIC"); 608 printer.feed(1); 609 printer.boldOn(); 610 printer.println("Adhesive 611 Test: 180 degree"); 612 printer.boldOff(); 613 printer.feed(2); 614 printer.setSize('S'); 615 616 printer.print("Average Force: "); 617 printer.print(avr); 618 printer.println(" 619 Newton"); 620 printer.feed(1); 621 printer.print("Maximum Force: "); 622 623 printer.print(maxi); 624 printer.println(" Newton"); 625printer.feed(1); 626 627 printer.print("Number of samples: "); 628 printer.println(counter); 629 630 printer.feed(1); 631 printer.print("Speed ratio: "); 632 printer.println("5 633 mm/s"); 634 635 printer.feed(2); 636 printer.justify('C'); 637 printer.setSize('M'); 638 639 printer.println("WWW.DNP-CO.IR"); 640 printer.feed(1); 641 printer.println("Tel: 642 09125221037"); 643 printer.feed(2); 644 printer.setSize('S'); 645 printer.justify('C'); 646 647 printer.println("...End of report..."); 648 printer.feed(3); 649 printer.wake(); 650 651 printer.setDefault(); 652 tft.begin(0x9341); 653 tft.setRotation(3); 654 655 loop(); 656} 657} 658 659 660} 661}} 662 663/////////////////////////////////////////////////////////alarm 664void 665 alarm (void){ 666 tft.fillScreen(BLACK); 667tft.setTextColor(YELLOW); tft.setTextSize(3); 668 669 tft.setCursor(5, 50); 670 tft.println("ALARM!"); 671 tft.setTextColor(WHITE); 672 tft.setTextSize(2); 673 tft.setCursor(5, 150); 674 tft.println("The 675 force is raeched limit (>40 N)"); 676 tft.setCursor(5, 180); 677 678 tft.println("Please remove tape ad restart test."); 679 tft.setTextColor(MAGENTA); 680 tft.setTextSize(2); 681 tft.setCursor(5, 240); 682 tft.println("To 683 restart press STOP."); 684 while(true){ 685 if (digitalRead (stopkey) 686 == LOW){ 687terminate(); 688 689}}} 690 ////////////////////////////////////////////////////////////////////////////////////////////////////////MAIN 691 LOOP 692void loop(void) 693{ 694 695 696//////////////////////////////////////////////////////////////////////////////////////////////////////////Initialaizing 697 698 699kilo=0; 700maxi=0; 701sum=0; 702avr=0; 703counter=0; 704 705 /////////logo 706 707 tft.setRotation(3); 708 tft.fillScreen(WHITE); 709 tft.fillScreen(MAGENTA); 710 711 tft.fillScreen(WHITE); 712 tft.setTextColor(BLUE); 713 tft.setTextSize(7); 714 715 tft.setCursor(100, 50); 716 tft.println("M A T T"); 717 tft.setTextColor(CYAN); 718 tft.setTextSize(3); 719 tft.setCursor(5, 150); 720 tft.println("Medical 721 Adhesive Tape Test"); 722 tft.setTextColor(BLACK); tft.setTextSize(2); 723 724 tft.setCursor(20, 230); 725 tft.println("Designed and Developed by DNP 726 co."); 727 tft.setCursor(20, 260); 728 tft.println("www.DNP-CO.ir"); 729 730 tft.setCursor(20, 290); 731 tft.println("Tel: +98-912 522 1037"); 732 733 delay(5000); 734/////////////////////// 735 736 tft.fillScreen(BLACK); 737 738 tft.setTextColor(WHITE); tft.setTextSize(1); 739 tft.setCursor(10, 10); 740 741 tft.println("Version. 2.6 Sep 2017"); 742 tft.setTextColor(WHITE); tft.setTextSize(3); 743 744 tft.setCursor(100, 50); 745 tft.println("Initializing..."); 746 tft.setTextColor(YELLOW); 747 tft.setTextSize(2); 748 tft.setCursor(30, 100); 749 tft.println("Self Test:"); 750 751 tft.setCursor(30, 120); 752 tft.println("Limit Sensors, Motor, ROM, Loadcell 753 "); 754 755 tft.setTextColor(WHITE); tft.setTextSize(2); 756 tft.setCursor(150, 757 150); 758 tft.println("Please wait..."); 759 760 tft.setTextColor(WHITE); 761 tft.setTextSize(2); 762 tft.setCursor(10, 290); 763 tft.println("www.DNP-CO.ir 764 09125221037"); 765 766for (int n=3; n>0; n--){ 767 768 tft.setTextColor(YELLOW); 769 tft.setTextSize(2); 770 tft.setCursor(210, 220); 771 tft.println(n); 772// 773 tft.setCursor(210, 240); 774 // tft.println(kilo); 775 delay(1000); 776 777 tft.setTextColor(BLACK); tft.setTextSize(2); 778 tft.setCursor(210, 779 220); 780 tft.println(n); 781 // tft.setCursor(210, 240); 782 // tft.println(kilo); 783} 784//////////////////////////////////////////////////////////////////////////////////////////////////////////////////Auto 785 Position 786tft.fillScreen(BLACK); 787 tft.setTextColor(YELLOW); tft.setTextSize(3); 788 789 tft.setCursor(50, 50); 790 tft.println("Auto Set Postition..."); 791 792 tft.setTextColor(WHITE); tft.setTextSize(2); 793 tft.setCursor(5, 794 100); 795 tft.println("Please wait while the haed is going to be set 796 in the zero position."); 797 798 tft.setTextColor(WHITE); tft.setTextSize(2); 799 800 tft.setCursor(10, 270); 801 tft.println("www.DNP-CO.ir 09125221037"); 802 803 while (true) 804 { 805 806 807 digitalWrite(down, HIGH); 808 digitalWrite(up, 809 HIGH); 810 delayMicroseconds(200); 811 digitalWrite(up, 812 LOW); 813 delayMicroseconds(200); 814 if (digitalRead(senup)== HIGH){ 815 816 delay(10); 817 if(digitalRead(senup)==HIGH){ 818 break; 819 820 } 821 } 822 } 823 824 for (int m=200; m>0; m--){ 825 digitalWrite(up, 826 HIGH); 827 digitalWrite(down, HIGH); 828delayMicroseconds(200); 829digitalWrite(down, 830 LOW); 831delayMicroseconds(200); 832 833 } 834///////////////////////////////////////////////////////////////////////////////////////////////////////////////////Manual 835 / Auto selection 836 tft.fillScreen(BLACK); 837 tft.setTextColor(YELLOW); 838 tft.setTextSize(3); 839 tft.setCursor(20, 50); 840 tft.println("Please 841 select Test Mode: "); 842 tft.setTextColor(WHITE); tft.setTextSize(3); 843 844 tft.setCursor(5, 130); 845 tft.println("For Manual press 1."); 846 tft.setCursor(5, 847 180); 848 tft.println("For Auto press 2"); 849 while (1){ 850 if (digitalRead(f1) 851 == LOW){ 852manualmode(); 853 } 854if (digitalRead(f2) == LOW){ 855 tft.fillScreen(BLACK); 856tft.setTextColor(YELLOW); 857 tft.setTextSize(3); 858 tft.setCursor(20, 50); 859 tft.println("Please 860 select the type of test"); 861tft.setTextColor(WHITE); tft.setTextSize(2); 862 863 864 tft.setCursor(10, 200); 865 tft.println("For Tension Test 866 press F1."); 867 tft.setCursor(10, 230); 868 tft.println("For 869 Adhesive Test press F2."); 870 while (1){ 871 if (digitalRead(f1) == LOW){ 872tension(); 873 874 } 875 if (digitalRead(f2) == LOW){ 876 877 tft.fillScreen(BLACK); 878tft.setTextColor(YELLOW); 879 tft.setTextSize(3); 880 tft.setCursor(20, 50); 881 tft.println("Adhesie 882 test selection:"); 883tft.setTextColor(WHITE); tft.setTextSize(2); 884 tft.setCursor(10, 885 150); 886 tft.println("Roller Plate = F1"); 887 tft.setCursor(10, 888 180); 889 tft.println("1 Inch Square= F2."); 890tft.setCursor(10, 210); 891 892 tft.println("180 degree test = F3."); 893 tft.setTextColor(MAGENTA); 894 895 tft.setCursor(10, 270); 896 tft.println("To cancel press STOP."); 897 898while 899 (true){ 900 if (digitalRead(f1) == LOW){ 901 rollerplate(); 902 903 904 } 905 if (digitalRead(f2) == LOW){ 906 907mili(); 908 } 909 if 910 (digitalRead(f3) == LOW){ 911degree(); 912} 913 if (digitalRead(stopkey) 914 == LOW){ 915terminate(); 916} 917} 918} 919} 920} 921} 922tft.fillScreen(BLACK); 923} 924///////////////////////////////////////////////////////////////////////////////////////////////////////////////////TENSION 925 926 void tension (void){ 927 tft.fillScreen(BLACK); 928tft.setTextColor(YELLOW); tft.setTextSize(3); 929 930 tft.setCursor(20, 50); 931 tft.println("Tension test."); 932tft.setTextColor(MAGENTA); 933 934tft.setTextSize(3); 935 tft.setCursor(10, 100); 936 tft.println("Please 937 wait... "); 938 tft.setTextColor(WHITE); tft.setTextSize(2); 939 tft.setCursor(10, 940 200); 941 tft.println("The head is going to be set in the proper position."); 942 943 944 while (digitalRead(sendown) == LOW) 945 { 946 947 digitalWrite(up, 948 HIGH); 949 digitalWrite(down, HIGH); 950delayMicroseconds(200); 951digitalWrite(down, 952 LOW); 953delayMicroseconds(200); 954} 955 for (int m=1000; m>0; m--){ 956 957 digitalWrite(down, HIGH); 958 digitalWrite(up, HIGH); 959delayMicroseconds(200); 960digitalWrite(up, 961 LOW); 962delayMicroseconds(200); 963 964 } 965 tft.fillScreen(BLACK); 966tft.setTextColor(YELLOW); 967 tft.setTextSize(3); 968 tft.setCursor(20, 50); 969 tft.println("Tension 970 test."); 971tft.setTextColor(MAGENTA); 972tft.setTextSize(3); 973 tft.setCursor(10, 974 100); 975 tft.println("Please attache appropriateclamp according to the 976 width of tape."); 977 tft.setTextColor(WHITE); tft.setTextSize(2); 978 979 tft.setCursor(10, 200); 980 tft.println("Press START to start."); 981 982 tft.setCursor(10, 230); 983 tft.println("Press 984 STOP to cancel."); 985 986while (true){ 987 if (digitalRead (startkey) == LOW){ 988 989 break;} 990 if (digitalRead (stopkey) == LOW){ 991 992terminate();} 993 994 995} 996 tft.fillScreen(BLACK); 997tft.setTextColor(YELLOW); tft.setTextSize(3); 998 999 tft.setCursor(20, 50); 1000 tft.println("Test is in progress..."); 1001tft.setTextColor(MAGENTA); 1002 1003tft.setTextSize(3); 1004 tft.setCursor(10, 100); 1005 tft.println("please 1006 wait to finish the test."); 1007 tft.setTextColor(WHITE); tft.setTextSize(2); 1008 1009 tft.setCursor(10, 200); 1010 1011 tft.println("Press STOP to 1012 cancel."); 1013 scale.tare(); 1014 for (int i=0; i<1000 ; i++){ 1015 if (digitalRead(senmid)== 1016 HIGH)break; 1017 digitalWrite(down, HIGH); 1018 digitalWrite(up, HIGH); 1019 delay(1); 1020 1021 digitalWrite(up, LOW); 1022 delay(1); 1023 } 1024 1025 while (digitalRead(senmid) == LOW) 1026 { 1027 1028 kilo = scale.get_units(); 1029 1030 kilo=kilo/10000; 1031 kilo=kilo*1.15; 1032counter ++; 1033if (kilo > 70) alarm(); 1034sum 1035 = sum+kilo; 1036avr = sum/counter; 1037if (kilo>maxi) maxi=kilo; 1038 1039if (digitalRead 1040 (stopkey) == LOW){ 1041//....................................................................................................................................................................................... 1042terminate();} 1043for 1044 (int i=0; i<500 ; i++){ 1045 if (digitalRead(senmid)== HIGH)break; 1046 digitalWrite(down, 1047 HIGH); 1048 digitalWrite(up, HIGH); 1049 delay(1); 1050 1051 digitalWrite(up, LOW); 1052 delay(1); 1053 } 1054 if(kilo < avr)break; 1055 1056 } 1057////////////////////////result show 1058tft.setRotation(3); 1059tft.fillScreen(BLACK); 1060tft.setTextColor(YELLOW); 1061 tft.setTextSize(3); 1062tft.setCursor(5, 50); 1063tft.println("Test Is Finshed."); 1064//tft.setCursor(30, 1065 104); 1066//tft.setTextColor(WHITE); tft.setTextSize(2); 1067//tft.println("Avarege 1068 Force:"); 1069//tft.setTextColor(YELLOW); tft.setTextSize(2); 1070//tft.setCursor(300,100); 1071//tft.println(avr); 1072//tft.setCursor(390, 1073 100); 1074//tft.println("Newton"); 1075tft.setCursor(30, 134); 1076tft.setTextColor(WHITE); 1077 tft.setTextSize(2); 1078tft.println("Maximum Force:"); 1079tft.setCursor(300, 1080 130); 1081tft.setTextColor(YELLOW); tft.setTextSize(3); 1082tft.println(maxi); 1083tft.setTextColor(YELLOW); 1084 tft.setTextSize(2); 1085tft.setCursor(390, 130); 1086tft.println(" Newton"); 1087tft.setCursor(30, 1088 164); 1089tft.setTextColor(WHITE); tft.setTextSize(2); 1090tft.println("Number of 1091 samples:"); 1092tft.setCursor(300, 160); 1093tft.setTextColor(YELLOW); tft.setTextSize(3); 1094tft.println(counter); 1095 1096tft.setCursor(30, 194); 1097tft.setTextColor(WHITE); tft.setTextSize(2); 1098tft.println("Speed 1099 rate:"); 1100tft.setCursor(300, 190); 1101tft.setTextColor(YELLOW); tft.setTextSize(3); 1102tft.println("5 1103 mm/s"); 1104tft.setTextColor(CYAN); tft.setTextSize(2); 1105tft.setCursor(5, 260); 1106tft.println("To 1107 print results press PRINT."); 1108tft.setTextColor(MAGENTA); tft.setTextSize(2); 1109tft.setCursor(5, 1110 290); 1111tft.println("To restart press STOP."); 1112 while (1){ 1113if 1114 (digitalRead (stopkey) == LOW){ 1115 loop(); 1116} 1117if (digitalRead (printkey) 1118 == LOW){ 1119 tft.reset(); 1120 1121 printer.begin(); 1122 printer.inverseOn(); 1123 1124 printer.justify('C'); 1125 printer.setSize('L'); 1126 printer.println("...MATT..."); 1127 1128 printer.inverseOff(); 1129 printer.setSize('S'); 1130 printer.println("Medical 1131 Adhesive Tape Test"); 1132 printer.feed(1); 1133 printer.justify('L'); 1134 printer.println("Test 1135 Type: AUTOMATIC"); 1136 printer.feed(1); 1137 printer.boldOn(); 1138 printer.println("Tension 1139 Test"); 1140 printer.boldOff(); 1141 printer.feed(3); 1142 // printer.setSize('S'); 1143 1144 // printer.print("Average Force: "); 1145 // printer.print(avr); 1146 // printer.println(" 1147 N"); 1148 printer.feed(1); 1149 printer.print("Maximum Force: "); 1150 printer.print(maxi); 1151 1152 printer.println(" Newton"); 1153printer.feed(1); 1154 printer.print("Number 1155 of samples: "); 1156 printer.println(counter); 1157 printer.feed(1); 1158 printer.print("Speed 1159 ratio: "); 1160 printer.println("5 mm/s"); 1161 1162 printer.feed(2); 1163 1164 printer.justify('C'); 1165 printer.setSize('M'); 1166 printer.println("WWW.DNP-CO.IR"); 1167 1168 printer.feed(1); 1169 printer.println("Tel: 09125221037"); 1170 printer.feed(2); 1171 1172 printer.setSize('S'); 1173 printer.justify('C'); 1174 printer.println("...End 1175 of report..."); 1176 printer.feed(3); 1177 printer.wake(); 1178 printer.setDefault(); 1179 1180 tft.begin(0x9341); 1181 tft.setRotation(3); 1182 loop(); 1183} 1184} ///////////////////////////////////// 1185 1186 } 1187 ////////////////////////////////////////////////////////////////////////////////ROLLER 1188 PLATE 1189void rollerplate (void){ 1190 tft.fillScreen(BLACK); 1191tft.setTextColor(YELLOW); 1192 tft.setTextSize(3); 1193 tft.setCursor(20, 50); 1194 tft.println("Roller 1195 Plate Test."); 1196tft.setTextColor(MAGENTA); 1197tft.setTextSize(3); 1198 tft.setCursor(10, 1199 100); 1200 tft.println("Please wait... "); 1201 tft.setTextColor(WHITE); 1202 tft.setTextSize(2); 1203 tft.setCursor(10, 200); 1204 tft.println("The 1205 head is going to be set in the proper position"); 1206 while (digitalRead(sendown) 1207 == LOW) 1208 { 1209 digitalWrite(up, HIGH); 1210 digitalWrite(down, HIGH); 1211delayMicroseconds(200); 1212digitalWrite(down, 1213 LOW); 1214delayMicroseconds(200); 1215} 1216 for (int m=500; m>0; m--){ 1217 1218 digitalWrite(down, HIGH); 1219 digitalWrite(up, HIGH); 1220delayMicroseconds(200); 1221digitalWrite(up, 1222 LOW); 1223delayMicroseconds(200); 1224 1225 } 1226tft.fillScreen(BLACK); 1227tft.setTextColor(YELLOW); 1228 tft.setTextSize(3); 1229 tft.setCursor(20, 50); 1230 tft.println("Tension 1231 test."); 1232tft.setTextColor(MAGENTA); 1233tft.setTextSize(3); 1234 tft.setCursor(10, 1235 105); 1236 tft.println("Please attache Roller Plate. "); 1237 1238 tft.setTextColor(WHITE); tft.setTextSize(2); 1239 tft.setCursor(10, 1240 200); 1241 tft.println("Press START to start."); 1242 tft.setCursor(10, 1243 230); 1244 tft.println("Press STOP to cancel."); 1245while (true){ 1246if 1247 (digitalRead (startkey) == LOW){ 1248break; 1249 } 1250 if (digitalRead (stopkey) 1251 == LOW){ 1252terminate(); 1253 } 1254} 1255 tft.fillScreen(BLACK); 1256tft.setTextColor(YELLOW); 1257 tft.setTextSize(3); 1258 tft.setCursor(20, 50); 1259 tft.println("Test 1260 is in progress..."); 1261tft.setTextColor(MAGENTA); 1262tft.setTextSize(3); 1263 1264 tft.setCursor(10, 100); 1265 tft.println("Please wait to finish the 1266 test."); 1267 tft.setTextColor(WHITE); tft.setTextSize(2); 1268 tft.setCursor(10, 1269 200); 1270 1271 tft.println("Press STOP to cancel."); 1272 scale.tare(); 1273 1274 1275 while (digitalRead(senmid) == LOW) 1276 { 1277 while (digitalRead(senmid) 1278 == LOW) { 1279 kilo = scale.get_units(); 1280 kilo=kilo/10000; 1281 kilo=kilo*1.15; 1282counter 1283 ++; 1284if (kilo > 70) alarm(); 1285sum = sum+kilo; 1286avr = sum/counter; 1287if (kilo>maxi) 1288 maxi=kilo; 1289for (int i=0; i<100 ; i++){ 1290 digitalWrite(down, HIGH); 1291 digitalWrite(up, 1292 HIGH); 1293 delay(1); 1294 digitalWrite(up, LOW); 1295 1296 delay(1); 1297 digitalWrite (stopkey, HIGH); 1298 int key =0; 1299 key = digitalRead 1300 (stopkey); 1301 if (key == LOW) { 1302 1303 terminate(); } 1304 }} 1305 1306 } 1307 1308 for (int m=500; m>0; m--){ 1309 digitalWrite(up, HIGH); 1310 digitalWrite(down, 1311 HIGH); 1312 delay(1); 1313 digitalWrite(down, LOW); 1314 1315 delay(1); 1316 1317 } 1318 1319 1320 tft.setRotation(3); 1321tft.fillScreen(BLACK); 1322tft.setTextColor(YELLOW); 1323 tft.setTextSize(3); 1324tft.setCursor(5, 50); 1325tft.println("Test Is Finshed."); 1326tft.setCursor(30, 1327 104); 1328tft.setTextColor(WHITE); tft.setTextSize(2); 1329tft.println("Avarege 1330 Force:"); 1331tft.setTextColor(YELLOW); tft.setTextSize(3); 1332tft.setCursor(300,100); 1333tft.println(avr); 1334tft.setTextColor(WHITE); 1335 tft.setTextSize(2); 1336tft.setCursor(390, 100); 1337tft.println(" Newton"); 1338tft.setCursor(30, 1339 134); 1340tft.setTextColor(WHITE); tft.setTextSize(2); 1341tft.println("Maximum 1342 Force:"); 1343tft.setCursor(300, 130); 1344tft.setTextColor(YELLOW); tft.setTextSize(3); 1345tft.println(maxi); 1346tft.setTextColor(WHITE); 1347 tft.setTextSize(2); 1348tft.setCursor(390, 130); 1349tft.println(" Newton"); 1350tft.setCursor(30, 1351 164); 1352tft.setTextColor(WHITE); tft.setTextSize(2); 1353tft.println("Number of 1354 samples:"); 1355tft.setCursor(300, 160); 1356tft.setTextColor(YELLOW); tft.setTextSize(3); 1357tft.println(counter); 1358 1359tft.setCursor(30, 194); 1360tft.setTextColor(WHITE); tft.setTextSize(2); 1361tft.println("Speed 1362 rate:"); 1363tft.setCursor(300, 190); 1364tft.setTextColor(YELLOW); tft.setTextSize(3); 1365tft.println("5 1366 mm/s"); 1367tft.setTextColor(CYAN); tft.setTextSize(2); 1368tft.setCursor(5, 260); 1369tft.println("To 1370 print results press PRINT."); 1371tft.setTextColor(MAGENTA); tft.setTextSize(2); 1372tft.setCursor(5, 1373 290); 1374tft.println("To restart press STOP."); 1375 while (1){ 1376if 1377 (digitalRead (stopkey) == LOW){ 1378 tft.fillScreen(BLACK); 1379tft.setTextColor(YELLOW); 1380 tft.setTextSize(4); 1381tft.setCursor(5, 50); 1382tft.println("WARRNING!!!"); 1383tft.setCursor(30, 1384 104); 1385tft.setTextColor(WHITE); tft.setTextSize(3); 1386tft.println("Remove plate's 1387 cable from the head."); 1388tft.setTextColor(MAGENTA); tft.setTextSize(2); 1389tft.setCursor(5, 1390 290); 1391tft.println("To restart press STOP."); 1392while(true){ 1393if (digitalRead 1394 (stopkey) == LOW){ 1395 loop();}} 1396} 1397if (digitalRead (printkey) == LOW){ 1398 1399 tft.reset(); 1400 1401 printer.begin(); 1402 printer.inverseOn(); 1403 1404 printer.justify('C'); 1405 printer.setSize('L'); 1406 printer.println("...MATT..."); 1407 1408 printer.inverseOff(); 1409 printer.setSize('S'); 1410 printer.println("Medical 1411 Adhesive Tape Test"); 1412 printer.feed(1); 1413 printer.justify('L'); 1414 printer.println("Test 1415 Type: AUTOMATIC"); 1416 printer.feed(1); 1417 printer.boldOn(); 1418 printer.println("Adhesive 1419 Test: Roller Plate"); 1420 printer.boldOff(); 1421 printer.feed(2); 1422 printer.setSize('S'); 1423 1424 printer.print("Average Force: "); 1425 printer.print(avr); 1426 printer.println(" 1427 Newton"); 1428 printer.feed(1); 1429 printer.print("Maximum Force: "); 1430 1431 printer.print(maxi); 1432 printer.println(" Newton"); 1433printer.feed(1); 1434 1435 printer.print("Number of samples: "); 1436 printer.println(counter); 1437 1438 printer.feed(1); 1439 printer.print("Speed ratio: "); 1440 printer.println("5 1441 mm/s"); 1442 1443 printer.feed(2); 1444 printer.justify('C'); 1445 printer.setSize('M'); 1446 1447 printer.println("WWW.DNP-CO.IR"); 1448 printer.feed(1); 1449 printer.println("Tel: 1450 09125221037"); 1451 printer.feed(2); 1452 printer.setSize('S'); 1453 printer.justify('C'); 1454 1455 printer.println("...End of report..."); 1456 printer.feed(3); 1457 printer.wake(); 1458 1459 printer.setDefault(); 1460 tft.begin(0x9341); 1461 tft.setRotation(3); 1462 1463 1464 tft.fillScreen(BLACK); 1465tft.setTextColor(YELLOW); tft.setTextSize(4); 1466tft.setCursor(5, 1467 50); 1468tft.println("WARRNING!!!"); 1469tft.setCursor(30, 104); 1470tft.setTextColor(WHITE); 1471 tft.setTextSize(3); 1472tft.println("Remove plate's cable from the head."); 1473 1474tft.setTextColor(MAGENTA); 1475 tft.setTextSize(2); 1476tft.setCursor(5, 290); 1477tft.println("To restart press 1478 STOP."); 1479while(true){ 1480if (digitalRead (stopkey) == LOW){ 1481 loop();}} 1482} 1483} 1484 1485} 1486 1487/////////////////////////////////////////////////////////////////////////////////////////////////////////////MANUAL 1488 MODE 1489 void manualmode (void) 1490 { 1491 1492 tft.fillScreen(BLACK); 1493tft.setTextColor(YELLOW); 1494 tft.setTextSize(3); 1495 tft.setCursor(20, 50); 1496 tft.println("Manual 1497 Mode is selected"); 1498tft.setTextColor(WHITE); tft.setTextSize(2); 1499 tft.setCursor(10, 1500 150); 1501 tft.println("Press START to continiu."); 1502 tft.setCursor(10, 1503 200); 1504 tft.println("Press STOP to cancel."); 1505 while (1){ 1506 1507 if (digitalRead (startkey) == LOW){ 1508 goto manual; 1509 } 1510 if (digitalRead 1511 (stopkey) == LOW){ 1512 terminate(); 1513 } 1514 } 1515 manual: 1516 /////////////////////////////////////////////////////////////////////////////////////////////////////////joystick 1517 1518 kilo=0; 1519 maxi=0; 1520 counter=0; 1521 avr=0; 1522maxi=0; 1523sum=0; 1524int value 1525 =0; 1526 tft.fillScreen(BLACK); 1527tft.setTextColor(YELLOW); tft.setTextSize(2); 1528 1529 tft.setCursor(5, 50); 1530 tft.println("Use Joystick to move head 1531 up and down."); 1532 tft.setCursor(5, 100); 1533 tft.println(""); 1534 1535 tft.setCursor(5, 150); 1536 tft.println("To finish 1537 test press STOP."); 1538 tft.setTextColor(WHITE); tft.setTextSize(4); 1539 1540scale.tare(); 1541 1542while(true) 1543 { 1544 delay(500); 1545 value = analogRead(joystic); 1546 value 1547 = value/100; 1548 if (digitalRead (stopkey) == LOW){ 1549 break; 1550 }/*////// 1551 1552 kilo = scale.get_units(); 1553 kilo=kilo/10000; 1554 kilo=kilo*1.15; 1555counter 1556 ++; 1557if (kilo > 70) alarm(); 1558sum = sum+kilo; 1559avr = sum/counter; 1560if (kilo>maxi) 1561 maxi=kilo; 1562 */////// 1563 1564 while (value>7){ 1565for(int i=200; i>1; i--){ 1566 1567 digitalWrite(down, HIGH); 1568 digitalWrite(up, HIGH); 1569delayMicroseconds(700); 1570digitalWrite(up, 1571 LOW); 1572delayMicroseconds(700); 1573} 1574 kilo = scale.get_units(); 1575 kilo=kilo/10000; 1576 1577 kilo=kilo*1.15; 1578counter ++; 1579if (kilo > 70) alarm(); 1580sum = sum+kilo; 1581avr 1582 = sum/counter; 1583if (kilo>maxi) maxi=kilo; 1584 value = analogRead(joystic); 1585 1586 value = value/100; 1587 } 1588 1589 while( value<3){ 1590 1591 digitalWrite(up, 1592 HIGH); 1593 digitalWrite(down, HIGH); 1594delayMicroseconds(200); 1595digitalWrite(down, 1596 LOW); 1597delayMicroseconds(200); 1598value = analogRead(joystic); 1599 value 1600 = value/100; 1601 } 1602} 1603tft.setRotation(3); 1604tft.fillScreen(BLACK); 1605tft.setTextColor(YELLOW); 1606 tft.setTextSize(3); 1607tft.setCursor(5, 50); 1608tft.println("Test Is Finshed."); 1609tft.setCursor(30, 1610 104); 1611tft.setTextColor(WHITE); tft.setTextSize(2); 1612tft.println("Avarege 1613 Force:"); 1614tft.setTextColor(YELLOW); tft.setTextSize(3); 1615tft.setCursor(300,100); 1616tft.println(avr); 1617tft.setTextColor(WHITE); 1618 tft.setTextSize(2); 1619tft.setCursor(390, 100); 1620tft.println(" Newton"); 1621tft.setCursor(30, 1622 134); 1623tft.setTextColor(WHITE); tft.setTextSize(2); 1624tft.println("Maximum 1625 Force:"); 1626tft.setCursor(300, 130); 1627tft.setTextColor(YELLOW); tft.setTextSize(3); 1628tft.println(maxi); 1629tft.setTextColor(WHITE); 1630 tft.setTextSize(2); 1631tft.setCursor(390, 130); 1632tft.println(" Newton"); 1633tft.setCursor(30, 1634 164); 1635tft.setTextColor(WHITE); tft.setTextSize(2); 1636tft.println("Number of 1637 samples:"); 1638tft.setCursor(300, 160); 1639tft.setTextColor(YELLOW); tft.setTextSize(3); 1640tft.println(counter); 1641 1642 1643 1644tft.setTextColor(MAGENTA); tft.setTextSize(2); 1645tft.setCursor(5, 1646 260); 1647tft.println("To restart press STOP."); 1648 while (1){ 1649if 1650 (digitalRead (stopkey) == LOW){ 1651 goto manual; 1652} 1653if (digitalRead (resetkey) 1654 == LOW){ 1655 loop(); 1656} 1657if (digitalRead (printkey) == LOW){ 1658 tft.reset(); 1659 1660 1661 printer.begin(); 1662 printer.inverseOn(); 1663 printer.justify('C'); 1664 printer.setSize('L'); 1665 1666 printer.println("...MATT..."); 1667 printer.inverseOff(); 1668 printer.setSize('S'); 1669 1670 printer.println("Medical Adhesive Tape Test"); 1671 printer.feed(1); 1672 printer.justify('L'); 1673 1674 printer.println("Test Type: MANUAL"); 1675 printer.feed(1); 1676 printer.boldOn(); 1677 1678 printer.println("Tension Test"); 1679 printer.boldOff(); 1680 printer.feed(2); 1681 1682 printer.setSize('S'); 1683 printer.print("Average Force: "); 1684 printer.print(avr); 1685 1686 printer.println(" Newton"); 1687 printer.feed(1); 1688 printer.print("Maximum 1689 Force: "); 1690 printer.print(maxi); 1691 printer.println(" Newton"); 1692printer.feed(1); 1693 1694 printer.print("Number of samples: "); 1695 1696 printer.feed(2); 1697 printer.justify('C'); 1698 1699 printer.setSize('M'); 1700 printer.println("WWW.DNP-CO.IR"); 1701 printer.feed(1); 1702 1703 printer.println("Tel: 09125221037"); 1704 printer.feed(2); 1705 printer.setSize('S'); 1706 1707 printer.justify('C'); 1708 printer.println("...End of report..."); 1709 printer.feed(3); 1710 1711 printer.wake(); 1712 printer.setDefault(); 1713 tft.begin(0x9341); 1714 1715 tft.setRotation(3); 1716 goto manual; 1717 1718} 1719} 1720 1721 } 1722 1723 1724 1725
MATT.ino
arduino
1r// ***In the name of allah***// 2//this program is written by Mahdi 3 Hajy Alimohamadi for MATT machin. its inclouded all function for load cell, thermal 4 printer, joystic , TFT LCD// 5//date of last freamware 02/2017 6#include "Adafruit_Thermal.h" 7Adafruit_Thermal 8 printer(&Serial2); 9#include <SPFD5408_Adafruit_GFX.h> // Core graphics library 10#include 11 <SPFD5408_Adafruit_TFTLCD.h> // Hardware-specific library 12#include <SPFD5408_TouchScreen.h> 13#include 14 <SD.h> 15#include <SPI.h> 16#include "HX711.h" 17#define calibration_factor 18 -7050.0 19#define SD_CS 10 20#define LCD_CS A3 // Chip Select goes to Analog 21 3 22#define LCD_CD A2 // Command/Data goes to Analog 2 23#define LCD_WR A1 // 24 LCD Write goes to Analog 1 25#define LCD_RD A0 // LCD Read goes to Analog 0 26#define 27 LCD_RESET A4 // Can alternately just connect to Arduino's reset pin 28 // Assign 29 human-readable names to some common 16-bit color values: 30#define BLACK 0x0000 31#define 32 BLUE 0x001F 33#define RED 0xF800 34#define GREEN 0x07E0 35#define CYAN 36 0x07FF 37#define MAGENTA 0xF81F 38#define YELLOW 0xFFE0 39#define WHITE 40 0xFFFF 41 #define DOUT 22 42#define CLK 23 43HX711 scale(DOUT, CLK); 44Adafruit_TFTLCD 45 tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET); 46int down= 39; 47int up = 38; 48int 49 senup = 51; 50int senmid = 52; 51int sendown = 53; 52int joystic = A15; 53int 54 bott = 26; 55 float kilo = 0; 56 float avr =0; 57 float maxi=0; 58 float sum=0; 59 60 int counter=0; 61const int f1 = 50; 62const int f2 = 49; 63const int f3 = 48; 64const 65 int f4 = 47; 66const int f5 = 46; 67const int f6 = 45; 68const int startkey = 69 44; 70const int stopkey = 43; 71const int printkey = 42; 72const int stor = 41; 73const 74 int resetkey = 40; 75 76void setup(void) 77{ 78 79 80 81 Serial2.begin(9600); 82//scale.set_scale(calibration_factor); 83 //This value is obtained by using the SparkFun_HX711_Calibration sketch 84 scale.tare(); 85 86 // SDFP540 (0x9341) 87 88 tft.begin(0x9341); 89 90 pinMode (bott, INPUT_PULLUP); 91 92 pinMode(down, OUTPUT); 93 pinMode(up, OUTPUT); 94 pinMode(senup, INPUT); 95 96 pinMode(senmid, INPUT); 97 pinMode(sendown, INPUT); 98 pinMode(f1, INPUT_PULLUP); 99 100 pinMode(f2, INPUT_PULLUP); 101 pinMode(f3, INPUT_PULLUP); 102 pinMode(f4, 103 INPUT_PULLUP); 104 pinMode(f5, INPUT_PULLUP); 105 pinMode(f6, INPUT_PULLUP); 106 107 pinMode(startkey, INPUT_PULLUP); 108 pinMode(stopkey, INPUT_PULLUP); 109 110 pinMode(printkey, INPUT_PULLUP); 111 pinMode(resetkey, INPUT_PULLUP); 112 pinMode(stor, 113 INPUT_PULLUP); 114int value = 0; 115 116 /* printer.feed(1); 117 printer.justify('L'); 118 119 printer.println("Test Type: MANUAL"); 120 printer.feed(1); 121 printer.boldOn(); 122 123 printer.println("Ahesive Test : Roller Plate"); 124 printer.boldOff(); 125 126 printer.feed(2); 127 printer.setSize('S'); 128 printer.print("Average Force: 129 "); 130 printer.print(avr); 131 printer.println(" N"); 132 printer.feed(1); 133 134 printer.print("Maximum Force: "); 135 printer.print(maxi); 136 printer.println(" 137 N"); 138printer.feed(1); 139 printer.print("Number of samples:"); 140 printer.println(counter); 141 142 printer.feed(1); 143 printer.println("Speed ratio: "); 144 printer.println(counter); 145 146 147 printer.feed(2); 148 printer.justify('C'); 149 printer.setSize('M'); 150 printer.println("WWW.DNP-CO.IR"); 151 152 printer.feed(1); 153 printer.println("Tel: 09125221037"); 154 printer.feed(2); 155 156 printer.setSize('S'); 157 printer.justify('C'); 158 printer.println("...End 159 of report..."); 160 printer.feed(3); 161 printer.wake(); 162 printer.setDefault(); 163 164 */ 165 166} 167//////////////////////////////////////////////////////////////////////////////1inch 168 square 169void mili (void){ 170tft.fillScreen(BLACK); 171tft.setTextColor(YELLOW); 172 tft.setTextSize(3); 173 tft.setCursor(20, 50); 174 tft.println(" 175 1 Inch Square Test."); 176tft.setTextColor(MAGENTA); 177tft.setTextSize(3); 178 179 tft.setCursor(10, 100); 180 tft.println("Please wait... "); 181 182 tft.setTextColor(WHITE); tft.setTextSize(2); 183 tft.setCursor(10, 184 200); 185 tft.println("The head is going to be set in the proper position"); 186 187 188 for(int i=25000; i>1; i--){ 189 digitalWrite(up, HIGH); 190 digitalWrite(down, 191 HIGH); 192 delayMicroseconds(200); 193 digitalWrite(down, 194 LOW); 195 delayMicroseconds(200); 196 } 197tft.fillScreen(BLACK); 198tft.setTextColor(YELLOW); 199 tft.setTextSize(3); 200 tft.setCursor(20, 50); 201 tft.println("1 202 Inch Square Test."); 203tft.setTextColor(MAGENTA); 204tft.setTextSize(3); 205 206 tft.setCursor(10, 100); 207 tft.println("Please use a loop of adhesive 208 tape with length of 25 cm and attach to the moving clamp."); 209 tft.setTextColor(WHITE); 210 tft.setTextSize(2); 211 tft.setCursor(10, 220); 212 tft.println("Press 213 START to start."); 214 tft.setCursor(10, 250); 215 tft.println("Press 216 STOP to cancel."); 217while (true){ 218if (digitalRead (startkey) == LOW){ 219 220 tft.fillScreen(BLACK); 221tft.setTextColor(YELLOW); tft.setTextSize(3); 222 tft.setCursor(20, 223 50); 224 tft.println("Test is in progress..."); 225tft.setTextColor(MAGENTA); 226 227tft.setTextSize(3); 228 tft.setCursor(10, 100); 229 tft.println("Please 230 wait to finish the test."); 231 tft.setTextColor(WHITE); tft.setTextSize(2); 232 233 tft.setCursor(10, 200); 234 for(int i=2000; i>1; i--){ 235 digitalWrite(up, 236 HIGH); 237 digitalWrite(down, HIGH); 238 delay(1); 239 240 digitalWrite(down, LOW); 241 delay(1); 242 } 243 delay(500); 244 245 scale.tare(); 246 247 for(int j=30; j>1; j--){ 248 kilo = scale.get_units(); 249 250 kilo=kilo/10000; 251 kilo=kilo*1.15; 252counter ++; 253if (kilo > 70) alarm(); 254sum 255 = sum+kilo; 256avr = sum/counter; 257if (kilo>maxi) maxi=kilo; 258 for(int i=100; 259 i>1; i--){ 260 261 digitalWrite(down, HIGH); 262 digitalWrite(up, HIGH); 263 264 delay(1); 265 digitalWrite(up, LOW); 266 delay(1); 267 268 } 269 270} 271tft.setRotation(3); 272tft.fillScreen(BLACK); 273tft.setTextColor(YELLOW); 274 tft.setTextSize(3); 275tft.setCursor(5, 50); 276tft.println("Test Is Finished."); 277//tft.setCursor(30, 278 104); 279//tft.setTextColor(WHITE); tft.setTextSize(2); 280//tft.println("Avarege 281 Force:"); 282//tft.setTextColor(YELLOW); tft.setTextSize(3); 283//tft.setCursor(300,100); 284//tft.println(avr); 285//tft.setCursor(390, 286 100); 287//tft.println("N"); 288tft.setCursor(30, 134); 289tft.setTextColor(WHITE); 290 tft.setTextSize(2); 291tft.println("Maximum Force:"); 292tft.setCursor(300, 293 130); 294tft.setTextColor(YELLOW); tft.setTextSize(3); 295tft.println(maxi); 296tft.setTextColor(WHITE); 297 tft.setTextSize(2); 298tft.setCursor(390, 130); 299tft.println(" Newton"); 300tft.setCursor(30, 301 164); 302tft.setTextColor(WHITE); tft.setTextSize(2); 303tft.println("Number of 304 samples:"); 305tft.setCursor(300, 160); 306tft.setTextColor(YELLOW); tft.setTextSize(3); 307tft.println(counter); 308 309tft.setCursor(30, 194); 310tft.setTextColor(WHITE); tft.setTextSize(2); 311tft.println("Speed 312 rate:"); 313tft.setCursor(300, 190); 314tft.setTextColor(YELLOW); tft.setTextSize(3); 315tft.println("5 316 mm/s"); 317tft.setTextColor(CYAN); tft.setTextSize(2); 318tft.setCursor(5, 260); 319tft.println("To 320 print results press PRINT."); 321tft.setTextColor(MAGENTA); tft.setTextSize(2); 322tft.setCursor(5, 323 290); 324tft.println("To restart press STOP."); 325 while (1){ 326if 327 (digitalRead (stopkey) == LOW){ 328 loop(); 329} 330if (digitalRead (printkey) 331 == LOW){ 332 tft.reset(); 333 334 printer.begin(); 335 printer.inverseOn(); 336 337 printer.justify('C'); 338 printer.setSize('L'); 339 printer.println("...MATT..."); 340 341 printer.inverseOff(); 342 printer.setSize('S'); 343 printer.println("Medical 344 Adhesive Tape Test"); 345 printer.feed(1); 346 printer.justify('L'); 347 printer.println("Test 348 Type: AUTOMATIC"); 349 printer.feed(1); 350 printer.boldOn(); 351 printer.println("Adhesive 352 Test: 1Inch Square Test"); 353 printer.boldOff(); 354 printer.feed(2); 355 printer.setSize('S'); 356 357 // printer.print("Average Force: "); 358 //printer.print(avr); 359 //printer.println(" 360 N"); 361 printer.feed(1); 362 printer.print("Maximum Force: "); 363 printer.print(maxi); 364 365 printer.println(" Newton"); 366printer.feed(1); 367 printer.print("Number 368 of samples: "); 369 printer.println(counter); 370 printer.feed(1); 371 printer.print("Speed 372 ratio: "); 373 printer.println("5 mm/s"); 374 375 printer.feed(2); 376 377 printer.justify('C'); 378 printer.setSize('M'); 379 printer.println("WWW.DNP-CO.IR"); 380 381 printer.feed(1); 382 printer.println("Tel: 09125221037"); 383 printer.feed(2); 384 385 printer.setSize('S'); 386 printer.justify('C'); 387 printer.println("...End 388 of report..."); 389 printer.feed(3); 390 printer.wake(); 391 printer.setDefault(); 392 393 tft.begin(0x9341); 394 tft.setRotation(3); 395 loop(); 396} 397} 398 399} 400 401} 402} 403////////////////////////////////////////////////////////////////////////TERMINATION 404 405 void terminate (void) { 406 tft.fillScreen(BLACK); 407tft.setTextColor(YELLOW); 408 tft.setTextSize(3); 409 tft.setCursor(5, 50); 410 tft.println("Test 411 Is Terminated By User"); 412 tft.setTextColor(WHITE); tft.setTextSize(2); 413 414 tft.setCursor(5, 150); 415 tft.println("To print final result prees 416 PRINT."); 417 tft.setCursor(5, 180); 418 tft.println("To 419 store final result press STORE."); 420 tft.setTextColor(MAGENTA); 421 tft.setTextSize(2); 422 tft.setCursor(5, 240); 423 tft.println("To 424 restart press STOP."); 425while (1){ 426 if (digitalRead (stopkey) == LOW){ 427 428 loop(); 429 } 430 delay(1); 431} 432 433} 434 435/////////////////////////////////////////////////////////////////////////////////////////////-180degree 436void 437 degree (void){ 438tft.fillScreen(BLACK); 439tft.setTextColor(YELLOW); tft.setTextSize(3); 440 441 tft.setCursor(20, 50); 442 tft.println(" 180 Degree Test."); 443tft.setTextColor(MAGENTA); 444 445tft.setTextSize(3); 446 tft.setCursor(10, 100); 447 tft.println("Please 448 wait... "); 449 tft.setTextColor(WHITE); tft.setTextSize(2); 450 tft.setCursor(10, 451 200); 452 tft.println("The head is going to be set in the proper position"); 453 454 455 for(int i=25000; i>1; i--){ 456 digitalWrite(up, HIGH); 457 digitalWrite(down, 458 HIGH); 459 delayMicroseconds(200); 460 digitalWrite(down, 461 LOW); 462 delayMicroseconds(200); 463 } 464tft.fillScreen(BLACK); 465tft.setTextColor(YELLOW); 466 tft.setTextSize(3); 467 tft.setCursor(20, 50); 468 tft.println("180 469 Degree Test."); 470tft.setTextColor(MAGENTA); 471tft.setTextSize(3); 472 tft.setCursor(10, 473 100); 474 tft.println("Please use appropret clamp and attache one side the 475 specimen to the moving clamp and attache other side to plate."); 476 tft.setTextColor(WHITE); 477 tft.setTextSize(2); 478 tft.setCursor(10, 260); 479 tft.println("Press 480 START to start."); 481 tft.setCursor(10, 290); 482 tft.println("Press 483 STOP to cancel."); 484while (true){ 485if (digitalRead (startkey) == LOW){ 486 487 tft.fillScreen(BLACK); 488tft.setTextColor(YELLOW); tft.setTextSize(3); 489 tft.setCursor(20, 490 50); 491 tft.println("Test is in progress..."); 492tft.setTextColor(MAGENTA); 493 494tft.setTextSize(3); 495 tft.setCursor(10, 100); 496 tft.println("please 497 wait to finish te test."); 498 tft.setTextColor(WHITE); tft.setTextSize(2); 499 500 tft.setCursor(10, 200); 501 502 scale.tare(); 503 504 for(int 505 j=110; j>1; j--){ 506 kilo = scale.get_units(); 507 kilo=kilo/10000; 508 kilo=kilo*1.15; 509counter 510 ++; 511if (kilo > 70) alarm(); 512sum = sum+kilo; 513avr = sum/counter; 514if (kilo>maxi) 515 maxi=kilo; 516 for(int i=100; i>1; i--){ 517 518 digitalWrite(down, HIGH); 519 520 digitalWrite(up, HIGH); 521 delay(1); 522 digitalWrite(up, 523 LOW); 524 delay(1); 525 } 526 527} 528 529tft.setRotation(3); 530tft.fillScreen(BLACK); 531tft.setTextColor(YELLOW); 532 tft.setTextSize(3); 533tft.setCursor(5, 50); 534tft.println("Test Is Finshed."); 535tft.setCursor(30, 536 104); 537tft.setTextColor(WHITE); tft.setTextSize(2); 538tft.println("Avarege 539 Force:"); 540tft.setTextColor(YELLOW); tft.setTextSize(3); 541tft.setCursor(300,100); 542tft.println(avr); 543tft.setTextColor(WHITE); 544 tft.setTextSize(2); 545tft.setCursor(390, 100); 546tft.println(" Newton"); 547tft.setCursor(30, 548 134); 549tft.setTextColor(WHITE); tft.setTextSize(2); 550tft.println("Maximum 551 Force:"); 552tft.setCursor(300, 130); 553tft.setTextColor(YELLOW); tft.setTextSize(3); 554tft.println(maxi); 555tft.setTextColor(WHITE); 556 tft.setTextSize(2); 557tft.setCursor(390, 130); 558tft.println(" Newton"); 559tft.setCursor(30, 560 164); 561tft.setTextColor(WHITE); tft.setTextSize(2); 562tft.println("Number of 563 samples:"); 564tft.setCursor(300, 160); 565tft.setTextColor(YELLOW); tft.setTextSize(3); 566tft.println(counter); 567 568tft.setCursor(30, 194); 569tft.setTextColor(WHITE); tft.setTextSize(2); 570tft.println("Speed 571 rate:"); 572tft.setCursor(300, 190); 573tft.setTextColor(YELLOW); tft.setTextSize(3); 574tft.println("5 575 mm/s"); 576tft.setTextColor(CYAN); tft.setTextSize(2); 577tft.setCursor(5, 260); 578tft.println("To 579 print results press PRINT."); 580tft.setTextColor(MAGENTA); tft.setTextSize(2); 581tft.setCursor(5, 582 290); 583tft.println("To restart press STOP."); 584 while (1){ 585if 586 (digitalRead (stopkey) == LOW){ 587 loop(); 588} 589if (digitalRead (printkey) 590 == LOW){ 591 tft.reset(); 592 593 printer.begin(); 594 printer.inverseOn(); 595 596 printer.justify('C'); 597 printer.setSize('L'); 598 printer.println("...MATT..."); 599 600 printer.inverseOff(); 601 printer.setSize('S'); 602 printer.println("Medical 603 Adhesive Tape Test"); 604 printer.feed(1); 605 printer.justify('L'); 606 printer.println("Test 607 Type: AUTOMATIC"); 608 printer.feed(1); 609 printer.boldOn(); 610 printer.println("Adhesive 611 Test: 180 degree"); 612 printer.boldOff(); 613 printer.feed(2); 614 printer.setSize('S'); 615 616 printer.print("Average Force: "); 617 printer.print(avr); 618 printer.println(" 619 Newton"); 620 printer.feed(1); 621 printer.print("Maximum Force: "); 622 623 printer.print(maxi); 624 printer.println(" Newton"); 625printer.feed(1); 626 627 printer.print("Number of samples: "); 628 printer.println(counter); 629 630 printer.feed(1); 631 printer.print("Speed ratio: "); 632 printer.println("5 633 mm/s"); 634 635 printer.feed(2); 636 printer.justify('C'); 637 printer.setSize('M'); 638 639 printer.println("WWW.DNP-CO.IR"); 640 printer.feed(1); 641 printer.println("Tel: 642 09125221037"); 643 printer.feed(2); 644 printer.setSize('S'); 645 printer.justify('C'); 646 647 printer.println("...End of report..."); 648 printer.feed(3); 649 printer.wake(); 650 651 printer.setDefault(); 652 tft.begin(0x9341); 653 tft.setRotation(3); 654 655 loop(); 656} 657} 658 659 660} 661}} 662 663/////////////////////////////////////////////////////////alarm 664void 665 alarm (void){ 666 tft.fillScreen(BLACK); 667tft.setTextColor(YELLOW); tft.setTextSize(3); 668 669 tft.setCursor(5, 50); 670 tft.println("ALARM!"); 671 tft.setTextColor(WHITE); 672 tft.setTextSize(2); 673 tft.setCursor(5, 150); 674 tft.println("The 675 force is raeched limit (>40 N)"); 676 tft.setCursor(5, 180); 677 678 tft.println("Please remove tape ad restart test."); 679 tft.setTextColor(MAGENTA); 680 tft.setTextSize(2); 681 tft.setCursor(5, 240); 682 tft.println("To 683 restart press STOP."); 684 while(true){ 685 if (digitalRead (stopkey) 686 == LOW){ 687terminate(); 688 689}}} 690 ////////////////////////////////////////////////////////////////////////////////////////////////////////MAIN 691 LOOP 692void loop(void) 693{ 694 695 696//////////////////////////////////////////////////////////////////////////////////////////////////////////Initialaizing 697 698 699kilo=0; 700maxi=0; 701sum=0; 702avr=0; 703counter=0; 704 705 /////////logo 706 707 tft.setRotation(3); 708 tft.fillScreen(WHITE); 709 tft.fillScreen(MAGENTA); 710 711 tft.fillScreen(WHITE); 712 tft.setTextColor(BLUE); 713 tft.setTextSize(7); 714 715 tft.setCursor(100, 50); 716 tft.println("M A T T"); 717 tft.setTextColor(CYAN); 718 tft.setTextSize(3); 719 tft.setCursor(5, 150); 720 tft.println("Medical 721 Adhesive Tape Test"); 722 tft.setTextColor(BLACK); tft.setTextSize(2); 723 724 tft.setCursor(20, 230); 725 tft.println("Designed and Developed by DNP 726 co."); 727 tft.setCursor(20, 260); 728 tft.println("www.DNP-CO.ir"); 729 730 tft.setCursor(20, 290); 731 tft.println("Tel: +98-912 522 1037"); 732 733 delay(5000); 734/////////////////////// 735 736 tft.fillScreen(BLACK); 737 738 tft.setTextColor(WHITE); tft.setTextSize(1); 739 tft.setCursor(10, 10); 740 741 tft.println("Version. 2.6 Sep 2017"); 742 tft.setTextColor(WHITE); tft.setTextSize(3); 743 744 tft.setCursor(100, 50); 745 tft.println("Initializing..."); 746 tft.setTextColor(YELLOW); 747 tft.setTextSize(2); 748 tft.setCursor(30, 100); 749 tft.println("Self Test:"); 750 751 tft.setCursor(30, 120); 752 tft.println("Limit Sensors, Motor, ROM, Loadcell 753 "); 754 755 tft.setTextColor(WHITE); tft.setTextSize(2); 756 tft.setCursor(150, 757 150); 758 tft.println("Please wait..."); 759 760 tft.setTextColor(WHITE); 761 tft.setTextSize(2); 762 tft.setCursor(10, 290); 763 tft.println("www.DNP-CO.ir 764 09125221037"); 765 766for (int n=3; n>0; n--){ 767 768 tft.setTextColor(YELLOW); 769 tft.setTextSize(2); 770 tft.setCursor(210, 220); 771 tft.println(n); 772// 773 tft.setCursor(210, 240); 774 // tft.println(kilo); 775 delay(1000); 776 777 tft.setTextColor(BLACK); tft.setTextSize(2); 778 tft.setCursor(210, 779 220); 780 tft.println(n); 781 // tft.setCursor(210, 240); 782 // tft.println(kilo); 783} 784//////////////////////////////////////////////////////////////////////////////////////////////////////////////////Auto 785 Position 786tft.fillScreen(BLACK); 787 tft.setTextColor(YELLOW); tft.setTextSize(3); 788 789 tft.setCursor(50, 50); 790 tft.println("Auto Set Postition..."); 791 792 tft.setTextColor(WHITE); tft.setTextSize(2); 793 tft.setCursor(5, 794 100); 795 tft.println("Please wait while the haed is going to be set 796 in the zero position."); 797 798 tft.setTextColor(WHITE); tft.setTextSize(2); 799 800 tft.setCursor(10, 270); 801 tft.println("www.DNP-CO.ir 09125221037"); 802 803 while (true) 804 { 805 806 807 digitalWrite(down, HIGH); 808 digitalWrite(up, 809 HIGH); 810 delayMicroseconds(200); 811 digitalWrite(up, 812 LOW); 813 delayMicroseconds(200); 814 if (digitalRead(senup)== HIGH){ 815 816 delay(10); 817 if(digitalRead(senup)==HIGH){ 818 break; 819 820 } 821 } 822 } 823 824 for (int m=200; m>0; m--){ 825 digitalWrite(up, 826 HIGH); 827 digitalWrite(down, HIGH); 828delayMicroseconds(200); 829digitalWrite(down, 830 LOW); 831delayMicroseconds(200); 832 833 } 834///////////////////////////////////////////////////////////////////////////////////////////////////////////////////Manual 835 / Auto selection 836 tft.fillScreen(BLACK); 837 tft.setTextColor(YELLOW); 838 tft.setTextSize(3); 839 tft.setCursor(20, 50); 840 tft.println("Please 841 select Test Mode: "); 842 tft.setTextColor(WHITE); tft.setTextSize(3); 843 844 tft.setCursor(5, 130); 845 tft.println("For Manual press 1."); 846 tft.setCursor(5, 847 180); 848 tft.println("For Auto press 2"); 849 while (1){ 850 if (digitalRead(f1) 851 == LOW){ 852manualmode(); 853 } 854if (digitalRead(f2) == LOW){ 855 tft.fillScreen(BLACK); 856tft.setTextColor(YELLOW); 857 tft.setTextSize(3); 858 tft.setCursor(20, 50); 859 tft.println("Please 860 select the type of test"); 861tft.setTextColor(WHITE); tft.setTextSize(2); 862 863 864 tft.setCursor(10, 200); 865 tft.println("For Tension Test 866 press F1."); 867 tft.setCursor(10, 230); 868 tft.println("For 869 Adhesive Test press F2."); 870 while (1){ 871 if (digitalRead(f1) == LOW){ 872tension(); 873 874 } 875 if (digitalRead(f2) == LOW){ 876 877 tft.fillScreen(BLACK); 878tft.setTextColor(YELLOW); 879 tft.setTextSize(3); 880 tft.setCursor(20, 50); 881 tft.println("Adhesie 882 test selection:"); 883tft.setTextColor(WHITE); tft.setTextSize(2); 884 tft.setCursor(10, 885 150); 886 tft.println("Roller Plate = F1"); 887 tft.setCursor(10, 888 180); 889 tft.println("1 Inch Square= F2."); 890tft.setCursor(10, 210); 891 892 tft.println("180 degree test = F3."); 893 tft.setTextColor(MAGENTA); 894 895 tft.setCursor(10, 270); 896 tft.println("To cancel press STOP."); 897 898while 899 (true){ 900 if (digitalRead(f1) == LOW){ 901 rollerplate(); 902 903 904 } 905 if (digitalRead(f2) == LOW){ 906 907mili(); 908 } 909 if 910 (digitalRead(f3) == LOW){ 911degree(); 912} 913 if (digitalRead(stopkey) 914 == LOW){ 915terminate(); 916} 917} 918} 919} 920} 921} 922tft.fillScreen(BLACK); 923} 924///////////////////////////////////////////////////////////////////////////////////////////////////////////////////TENSION 925 926 void tension (void){ 927 tft.fillScreen(BLACK); 928tft.setTextColor(YELLOW); tft.setTextSize(3); 929 930 tft.setCursor(20, 50); 931 tft.println("Tension test."); 932tft.setTextColor(MAGENTA); 933 934tft.setTextSize(3); 935 tft.setCursor(10, 100); 936 tft.println("Please 937 wait... "); 938 tft.setTextColor(WHITE); tft.setTextSize(2); 939 tft.setCursor(10, 940 200); 941 tft.println("The head is going to be set in the proper position."); 942 943 944 while (digitalRead(sendown) == LOW) 945 { 946 947 digitalWrite(up, 948 HIGH); 949 digitalWrite(down, HIGH); 950delayMicroseconds(200); 951digitalWrite(down, 952 LOW); 953delayMicroseconds(200); 954} 955 for (int m=1000; m>0; m--){ 956 957 digitalWrite(down, HIGH); 958 digitalWrite(up, HIGH); 959delayMicroseconds(200); 960digitalWrite(up, 961 LOW); 962delayMicroseconds(200); 963 964 } 965 tft.fillScreen(BLACK); 966tft.setTextColor(YELLOW); 967 tft.setTextSize(3); 968 tft.setCursor(20, 50); 969 tft.println("Tension 970 test."); 971tft.setTextColor(MAGENTA); 972tft.setTextSize(3); 973 tft.setCursor(10, 974 100); 975 tft.println("Please attache appropriateclamp according to the 976 width of tape."); 977 tft.setTextColor(WHITE); tft.setTextSize(2); 978 979 tft.setCursor(10, 200); 980 tft.println("Press START to start."); 981 982 tft.setCursor(10, 230); 983 tft.println("Press 984 STOP to cancel."); 985 986while (true){ 987 if (digitalRead (startkey) == LOW){ 988 989 break;} 990 if (digitalRead (stopkey) == LOW){ 991 992terminate();} 993 994 995} 996 tft.fillScreen(BLACK); 997tft.setTextColor(YELLOW); tft.setTextSize(3); 998 999 tft.setCursor(20, 50); 1000 tft.println("Test is in progress..."); 1001tft.setTextColor(MAGENTA); 1002 1003tft.setTextSize(3); 1004 tft.setCursor(10, 100); 1005 tft.println("please 1006 wait to finish the test."); 1007 tft.setTextColor(WHITE); tft.setTextSize(2); 1008 1009 tft.setCursor(10, 200); 1010 1011 tft.println("Press STOP to 1012 cancel."); 1013 scale.tare(); 1014 for (int i=0; i<1000 ; i++){ 1015 if (digitalRead(senmid)== 1016 HIGH)break; 1017 digitalWrite(down, HIGH); 1018 digitalWrite(up, HIGH); 1019 delay(1); 1020 1021 digitalWrite(up, LOW); 1022 delay(1); 1023 } 1024 1025 while (digitalRead(senmid) == LOW) 1026 { 1027 1028 kilo = scale.get_units(); 1029 1030 kilo=kilo/10000; 1031 kilo=kilo*1.15; 1032counter ++; 1033if (kilo > 70) alarm(); 1034sum 1035 = sum+kilo; 1036avr = sum/counter; 1037if (kilo>maxi) maxi=kilo; 1038 1039if (digitalRead 1040 (stopkey) == LOW){ 1041//....................................................................................................................................................................................... 1042terminate();} 1043for 1044 (int i=0; i<500 ; i++){ 1045 if (digitalRead(senmid)== HIGH)break; 1046 digitalWrite(down, 1047 HIGH); 1048 digitalWrite(up, HIGH); 1049 delay(1); 1050 1051 digitalWrite(up, LOW); 1052 delay(1); 1053 } 1054 if(kilo < avr)break; 1055 1056 } 1057////////////////////////result show 1058tft.setRotation(3); 1059tft.fillScreen(BLACK); 1060tft.setTextColor(YELLOW); 1061 tft.setTextSize(3); 1062tft.setCursor(5, 50); 1063tft.println("Test Is Finshed."); 1064//tft.setCursor(30, 1065 104); 1066//tft.setTextColor(WHITE); tft.setTextSize(2); 1067//tft.println("Avarege 1068 Force:"); 1069//tft.setTextColor(YELLOW); tft.setTextSize(2); 1070//tft.setCursor(300,100); 1071//tft.println(avr); 1072//tft.setCursor(390, 1073 100); 1074//tft.println("Newton"); 1075tft.setCursor(30, 134); 1076tft.setTextColor(WHITE); 1077 tft.setTextSize(2); 1078tft.println("Maximum Force:"); 1079tft.setCursor(300, 1080 130); 1081tft.setTextColor(YELLOW); tft.setTextSize(3); 1082tft.println(maxi); 1083tft.setTextColor(YELLOW); 1084 tft.setTextSize(2); 1085tft.setCursor(390, 130); 1086tft.println(" Newton"); 1087tft.setCursor(30, 1088 164); 1089tft.setTextColor(WHITE); tft.setTextSize(2); 1090tft.println("Number of 1091 samples:"); 1092tft.setCursor(300, 160); 1093tft.setTextColor(YELLOW); tft.setTextSize(3); 1094tft.println(counter); 1095 1096tft.setCursor(30, 194); 1097tft.setTextColor(WHITE); tft.setTextSize(2); 1098tft.println("Speed 1099 rate:"); 1100tft.setCursor(300, 190); 1101tft.setTextColor(YELLOW); tft.setTextSize(3); 1102tft.println("5 1103 mm/s"); 1104tft.setTextColor(CYAN); tft.setTextSize(2); 1105tft.setCursor(5, 260); 1106tft.println("To 1107 print results press PRINT."); 1108tft.setTextColor(MAGENTA); tft.setTextSize(2); 1109tft.setCursor(5, 1110 290); 1111tft.println("To restart press STOP."); 1112 while (1){ 1113if 1114 (digitalRead (stopkey) == LOW){ 1115 loop(); 1116} 1117if (digitalRead (printkey) 1118 == LOW){ 1119 tft.reset(); 1120 1121 printer.begin(); 1122 printer.inverseOn(); 1123 1124 printer.justify('C'); 1125 printer.setSize('L'); 1126 printer.println("...MATT..."); 1127 1128 printer.inverseOff(); 1129 printer.setSize('S'); 1130 printer.println("Medical 1131 Adhesive Tape Test"); 1132 printer.feed(1); 1133 printer.justify('L'); 1134 printer.println("Test 1135 Type: AUTOMATIC"); 1136 printer.feed(1); 1137 printer.boldOn(); 1138 printer.println("Tension 1139 Test"); 1140 printer.boldOff(); 1141 printer.feed(3); 1142 // printer.setSize('S'); 1143 1144 // printer.print("Average Force: "); 1145 // printer.print(avr); 1146 // printer.println(" 1147 N"); 1148 printer.feed(1); 1149 printer.print("Maximum Force: "); 1150 printer.print(maxi); 1151 1152 printer.println(" Newton"); 1153printer.feed(1); 1154 printer.print("Number 1155 of samples: "); 1156 printer.println(counter); 1157 printer.feed(1); 1158 printer.print("Speed 1159 ratio: "); 1160 printer.println("5 mm/s"); 1161 1162 printer.feed(2); 1163 1164 printer.justify('C'); 1165 printer.setSize('M'); 1166 printer.println("WWW.DNP-CO.IR"); 1167 1168 printer.feed(1); 1169 printer.println("Tel: 09125221037"); 1170 printer.feed(2); 1171 1172 printer.setSize('S'); 1173 printer.justify('C'); 1174 printer.println("...End 1175 of report..."); 1176 printer.feed(3); 1177 printer.wake(); 1178 printer.setDefault(); 1179 1180 tft.begin(0x9341); 1181 tft.setRotation(3); 1182 loop(); 1183} 1184} ///////////////////////////////////// 1185 1186 } 1187 ////////////////////////////////////////////////////////////////////////////////ROLLER 1188 PLATE 1189void rollerplate (void){ 1190 tft.fillScreen(BLACK); 1191tft.setTextColor(YELLOW); 1192 tft.setTextSize(3); 1193 tft.setCursor(20, 50); 1194 tft.println("Roller 1195 Plate Test."); 1196tft.setTextColor(MAGENTA); 1197tft.setTextSize(3); 1198 tft.setCursor(10, 1199 100); 1200 tft.println("Please wait... "); 1201 tft.setTextColor(WHITE); 1202 tft.setTextSize(2); 1203 tft.setCursor(10, 200); 1204 tft.println("The 1205 head is going to be set in the proper position"); 1206 while (digitalRead(sendown) 1207 == LOW) 1208 { 1209 digitalWrite(up, HIGH); 1210 digitalWrite(down, HIGH); 1211delayMicroseconds(200); 1212digitalWrite(down, 1213 LOW); 1214delayMicroseconds(200); 1215} 1216 for (int m=500; m>0; m--){ 1217 1218 digitalWrite(down, HIGH); 1219 digitalWrite(up, HIGH); 1220delayMicroseconds(200); 1221digitalWrite(up, 1222 LOW); 1223delayMicroseconds(200); 1224 1225 } 1226tft.fillScreen(BLACK); 1227tft.setTextColor(YELLOW); 1228 tft.setTextSize(3); 1229 tft.setCursor(20, 50); 1230 tft.println("Tension 1231 test."); 1232tft.setTextColor(MAGENTA); 1233tft.setTextSize(3); 1234 tft.setCursor(10, 1235 105); 1236 tft.println("Please attache Roller Plate. "); 1237 1238 tft.setTextColor(WHITE); tft.setTextSize(2); 1239 tft.setCursor(10, 1240 200); 1241 tft.println("Press START to start."); 1242 tft.setCursor(10, 1243 230); 1244 tft.println("Press STOP to cancel."); 1245while (true){ 1246if 1247 (digitalRead (startkey) == LOW){ 1248break; 1249 } 1250 if (digitalRead (stopkey) 1251 == LOW){ 1252terminate(); 1253 } 1254} 1255 tft.fillScreen(BLACK); 1256tft.setTextColor(YELLOW); 1257 tft.setTextSize(3); 1258 tft.setCursor(20, 50); 1259 tft.println("Test 1260 is in progress..."); 1261tft.setTextColor(MAGENTA); 1262tft.setTextSize(3); 1263 1264 tft.setCursor(10, 100); 1265 tft.println("Please wait to finish the 1266 test."); 1267 tft.setTextColor(WHITE); tft.setTextSize(2); 1268 tft.setCursor(10, 1269 200); 1270 1271 tft.println("Press STOP to cancel."); 1272 scale.tare(); 1273 1274 1275 while (digitalRead(senmid) == LOW) 1276 { 1277 while (digitalRead(senmid) 1278 == LOW) { 1279 kilo = scale.get_units(); 1280 kilo=kilo/10000; 1281 kilo=kilo*1.15; 1282counter 1283 ++; 1284if (kilo > 70) alarm(); 1285sum = sum+kilo; 1286avr = sum/counter; 1287if (kilo>maxi) 1288 maxi=kilo; 1289for (int i=0; i<100 ; i++){ 1290 digitalWrite(down, HIGH); 1291 digitalWrite(up, 1292 HIGH); 1293 delay(1); 1294 digitalWrite(up, LOW); 1295 1296 delay(1); 1297 digitalWrite (stopkey, HIGH); 1298 int key =0; 1299 key = digitalRead 1300 (stopkey); 1301 if (key == LOW) { 1302 1303 terminate(); } 1304 }} 1305 1306 } 1307 1308 for (int m=500; m>0; m--){ 1309 digitalWrite(up, HIGH); 1310 digitalWrite(down, 1311 HIGH); 1312 delay(1); 1313 digitalWrite(down, LOW); 1314 1315 delay(1); 1316 1317 } 1318 1319 1320 tft.setRotation(3); 1321tft.fillScreen(BLACK); 1322tft.setTextColor(YELLOW); 1323 tft.setTextSize(3); 1324tft.setCursor(5, 50); 1325tft.println("Test Is Finshed."); 1326tft.setCursor(30, 1327 104); 1328tft.setTextColor(WHITE); tft.setTextSize(2); 1329tft.println("Avarege 1330 Force:"); 1331tft.setTextColor(YELLOW); tft.setTextSize(3); 1332tft.setCursor(300,100); 1333tft.println(avr); 1334tft.setTextColor(WHITE); 1335 tft.setTextSize(2); 1336tft.setCursor(390, 100); 1337tft.println(" Newton"); 1338tft.setCursor(30, 1339 134); 1340tft.setTextColor(WHITE); tft.setTextSize(2); 1341tft.println("Maximum 1342 Force:"); 1343tft.setCursor(300, 130); 1344tft.setTextColor(YELLOW); tft.setTextSize(3); 1345tft.println(maxi); 1346tft.setTextColor(WHITE); 1347 tft.setTextSize(2); 1348tft.setCursor(390, 130); 1349tft.println(" Newton"); 1350tft.setCursor(30, 1351 164); 1352tft.setTextColor(WHITE); tft.setTextSize(2); 1353tft.println("Number of 1354 samples:"); 1355tft.setCursor(300, 160); 1356tft.setTextColor(YELLOW); tft.setTextSize(3); 1357tft.println(counter); 1358 1359tft.setCursor(30, 194); 1360tft.setTextColor(WHITE); tft.setTextSize(2); 1361tft.println("Speed 1362 rate:"); 1363tft.setCursor(300, 190); 1364tft.setTextColor(YELLOW); tft.setTextSize(3); 1365tft.println("5 1366 mm/s"); 1367tft.setTextColor(CYAN); tft.setTextSize(2); 1368tft.setCursor(5, 260); 1369tft.println("To 1370 print results press PRINT."); 1371tft.setTextColor(MAGENTA); tft.setTextSize(2); 1372tft.setCursor(5, 1373 290); 1374tft.println("To restart press STOP."); 1375 while (1){ 1376if 1377 (digitalRead (stopkey) == LOW){ 1378 tft.fillScreen(BLACK); 1379tft.setTextColor(YELLOW); 1380 tft.setTextSize(4); 1381tft.setCursor(5, 50); 1382tft.println("WARRNING!!!"); 1383tft.setCursor(30, 1384 104); 1385tft.setTextColor(WHITE); tft.setTextSize(3); 1386tft.println("Remove plate's 1387 cable from the head."); 1388tft.setTextColor(MAGENTA); tft.setTextSize(2); 1389tft.setCursor(5, 1390 290); 1391tft.println("To restart press STOP."); 1392while(true){ 1393if (digitalRead 1394 (stopkey) == LOW){ 1395 loop();}} 1396} 1397if (digitalRead (printkey) == LOW){ 1398 1399 tft.reset(); 1400 1401 printer.begin(); 1402 printer.inverseOn(); 1403 1404 printer.justify('C'); 1405 printer.setSize('L'); 1406 printer.println("...MATT..."); 1407 1408 printer.inverseOff(); 1409 printer.setSize('S'); 1410 printer.println("Medical 1411 Adhesive Tape Test"); 1412 printer.feed(1); 1413 printer.justify('L'); 1414 printer.println("Test 1415 Type: AUTOMATIC"); 1416 printer.feed(1); 1417 printer.boldOn(); 1418 printer.println("Adhesive 1419 Test: Roller Plate"); 1420 printer.boldOff(); 1421 printer.feed(2); 1422 printer.setSize('S'); 1423 1424 printer.print("Average Force: "); 1425 printer.print(avr); 1426 printer.println(" 1427 Newton"); 1428 printer.feed(1); 1429 printer.print("Maximum Force: "); 1430 1431 printer.print(maxi); 1432 printer.println(" Newton"); 1433printer.feed(1); 1434 1435 printer.print("Number of samples: "); 1436 printer.println(counter); 1437 1438 printer.feed(1); 1439 printer.print("Speed ratio: "); 1440 printer.println("5 1441 mm/s"); 1442 1443 printer.feed(2); 1444 printer.justify('C'); 1445 printer.setSize('M'); 1446 1447 printer.println("WWW.DNP-CO.IR"); 1448 printer.feed(1); 1449 printer.println("Tel: 1450 09125221037"); 1451 printer.feed(2); 1452 printer.setSize('S'); 1453 printer.justify('C'); 1454 1455 printer.println("...End of report..."); 1456 printer.feed(3); 1457 printer.wake(); 1458 1459 printer.setDefault(); 1460 tft.begin(0x9341); 1461 tft.setRotation(3); 1462 1463 1464 tft.fillScreen(BLACK); 1465tft.setTextColor(YELLOW); tft.setTextSize(4); 1466tft.setCursor(5, 1467 50); 1468tft.println("WARRNING!!!"); 1469tft.setCursor(30, 104); 1470tft.setTextColor(WHITE); 1471 tft.setTextSize(3); 1472tft.println("Remove plate's cable from the head."); 1473 1474tft.setTextColor(MAGENTA); 1475 tft.setTextSize(2); 1476tft.setCursor(5, 290); 1477tft.println("To restart press 1478 STOP."); 1479while(true){ 1480if (digitalRead (stopkey) == LOW){ 1481 loop();}} 1482} 1483} 1484 1485} 1486 1487/////////////////////////////////////////////////////////////////////////////////////////////////////////////MANUAL 1488 MODE 1489 void manualmode (void) 1490 { 1491 1492 tft.fillScreen(BLACK); 1493tft.setTextColor(YELLOW); 1494 tft.setTextSize(3); 1495 tft.setCursor(20, 50); 1496 tft.println("Manual 1497 Mode is selected"); 1498tft.setTextColor(WHITE); tft.setTextSize(2); 1499 tft.setCursor(10, 1500 150); 1501 tft.println("Press START to continiu."); 1502 tft.setCursor(10, 1503 200); 1504 tft.println("Press STOP to cancel."); 1505 while (1){ 1506 1507 if (digitalRead (startkey) == LOW){ 1508 goto manual; 1509 } 1510 if (digitalRead 1511 (stopkey) == LOW){ 1512 terminate(); 1513 } 1514 } 1515 manual: 1516 /////////////////////////////////////////////////////////////////////////////////////////////////////////joystick 1517 1518 kilo=0; 1519 maxi=0; 1520 counter=0; 1521 avr=0; 1522maxi=0; 1523sum=0; 1524int value 1525 =0; 1526 tft.fillScreen(BLACK); 1527tft.setTextColor(YELLOW); tft.setTextSize(2); 1528 1529 tft.setCursor(5, 50); 1530 tft.println("Use Joystick to move head 1531 up and down."); 1532 tft.setCursor(5, 100); 1533 tft.println(""); 1534 1535 tft.setCursor(5, 150); 1536 tft.println("To finish 1537 test press STOP."); 1538 tft.setTextColor(WHITE); tft.setTextSize(4); 1539 1540scale.tare(); 1541 1542while(true) 1543 { 1544 delay(500); 1545 value = analogRead(joystic); 1546 value 1547 = value/100; 1548 if (digitalRead (stopkey) == LOW){ 1549 break; 1550 }/*////// 1551 1552 kilo = scale.get_units(); 1553 kilo=kilo/10000; 1554 kilo=kilo*1.15; 1555counter 1556 ++; 1557if (kilo > 70) alarm(); 1558sum = sum+kilo; 1559avr = sum/counter; 1560if (kilo>maxi) 1561 maxi=kilo; 1562 */////// 1563 1564 while (value>7){ 1565for(int i=200; i>1; i--){ 1566 1567 digitalWrite(down, HIGH); 1568 digitalWrite(up, HIGH); 1569delayMicroseconds(700); 1570digitalWrite(up, 1571 LOW); 1572delayMicroseconds(700); 1573} 1574 kilo = scale.get_units(); 1575 kilo=kilo/10000; 1576 1577 kilo=kilo*1.15; 1578counter ++; 1579if (kilo > 70) alarm(); 1580sum = sum+kilo; 1581avr 1582 = sum/counter; 1583if (kilo>maxi) maxi=kilo; 1584 value = analogRead(joystic); 1585 1586 value = value/100; 1587 } 1588 1589 while( value<3){ 1590 1591 digitalWrite(up, 1592 HIGH); 1593 digitalWrite(down, HIGH); 1594delayMicroseconds(200); 1595digitalWrite(down, 1596 LOW); 1597delayMicroseconds(200); 1598value = analogRead(joystic); 1599 value 1600 = value/100; 1601 } 1602} 1603tft.setRotation(3); 1604tft.fillScreen(BLACK); 1605tft.setTextColor(YELLOW); 1606 tft.setTextSize(3); 1607tft.setCursor(5, 50); 1608tft.println("Test Is Finshed."); 1609tft.setCursor(30, 1610 104); 1611tft.setTextColor(WHITE); tft.setTextSize(2); 1612tft.println("Avarege 1613 Force:"); 1614tft.setTextColor(YELLOW); tft.setTextSize(3); 1615tft.setCursor(300,100); 1616tft.println(avr); 1617tft.setTextColor(WHITE); 1618 tft.setTextSize(2); 1619tft.setCursor(390, 100); 1620tft.println(" Newton"); 1621tft.setCursor(30, 1622 134); 1623tft.setTextColor(WHITE); tft.setTextSize(2); 1624tft.println("Maximum 1625 Force:"); 1626tft.setCursor(300, 130); 1627tft.setTextColor(YELLOW); tft.setTextSize(3); 1628tft.println(maxi); 1629tft.setTextColor(WHITE); 1630 tft.setTextSize(2); 1631tft.setCursor(390, 130); 1632tft.println(" Newton"); 1633tft.setCursor(30, 1634 164); 1635tft.setTextColor(WHITE); tft.setTextSize(2); 1636tft.println("Number of 1637 samples:"); 1638tft.setCursor(300, 160); 1639tft.setTextColor(YELLOW); tft.setTextSize(3); 1640tft.println(counter); 1641 1642 1643 1644tft.setTextColor(MAGENTA); tft.setTextSize(2); 1645tft.setCursor(5, 1646 260); 1647tft.println("To restart press STOP."); 1648 while (1){ 1649if 1650 (digitalRead (stopkey) == LOW){ 1651 goto manual; 1652} 1653if (digitalRead (resetkey) 1654 == LOW){ 1655 loop(); 1656} 1657if (digitalRead (printkey) == LOW){ 1658 tft.reset(); 1659 1660 1661 printer.begin(); 1662 printer.inverseOn(); 1663 printer.justify('C'); 1664 printer.setSize('L'); 1665 1666 printer.println("...MATT..."); 1667 printer.inverseOff(); 1668 printer.setSize('S'); 1669 1670 printer.println("Medical Adhesive Tape Test"); 1671 printer.feed(1); 1672 printer.justify('L'); 1673 1674 printer.println("Test Type: MANUAL"); 1675 printer.feed(1); 1676 printer.boldOn(); 1677 1678 printer.println("Tension Test"); 1679 printer.boldOff(); 1680 printer.feed(2); 1681 1682 printer.setSize('S'); 1683 printer.print("Average Force: "); 1684 printer.print(avr); 1685 1686 printer.println(" Newton"); 1687 printer.feed(1); 1688 printer.print("Maximum 1689 Force: "); 1690 printer.print(maxi); 1691 printer.println(" Newton"); 1692printer.feed(1); 1693 1694 printer.print("Number of samples: "); 1695 1696 printer.feed(2); 1697 printer.justify('C'); 1698 1699 printer.setSize('M'); 1700 printer.println("WWW.DNP-CO.IR"); 1701 printer.feed(1); 1702 1703 printer.println("Tel: 09125221037"); 1704 printer.feed(2); 1705 printer.setSize('S'); 1706 1707 printer.justify('C'); 1708 printer.println("...End of report..."); 1709 printer.feed(3); 1710 1711 printer.wake(); 1712 printer.setDefault(); 1713 tft.begin(0x9341); 1714 1715 tft.setRotation(3); 1716 goto manual; 1717 1718} 1719} 1720 1721 } 1722 1723 1724 1725
Downloadable files
06_ccGet7s3ps.jpg
06_ccGet7s3ps.jpg

05_WQVB5TrWIS.jpg
05_WQVB5TrWIS.jpg

02_Gu5tr5pXHS.jpg
02_Gu5tr5pXHS.jpg

01_Rb97dPSBxA.jpg
01_Rb97dPSBxA.jpg

02_sBdSVgNIak.jpg
02_sBdSVgNIak.jpg

06_ccGet7s3ps.jpg
06_ccGet7s3ps.jpg

01_Rb97dPSBxA.jpg
01_Rb97dPSBxA.jpg

05_WQVB5TrWIS.jpg
05_WQVB5TrWIS.jpg

02_Gu5tr5pXHS.jpg
02_Gu5tr5pXHS.jpg

Comments
Only logged in users can leave comments