Masážní křeslo založené na Stone HMI a Arduinu

Tvoříte zajímavý projekt? Pochlubte se s ním.
Pravidla fóra
Vkládejte prosím jen HOTOVÉ projekty, které chcete představit ostatním.
Odpovědět
Arthur
Příspěvky: 36
Registrován: 02 čer 2021, 03:37
Reputation: 0

Masážní křeslo založené na Stone HMI a Arduinu

Příspěvek od Arthur » 03 srp 2021, 09:20

Přehled projektu

Zde děláme je aplikace domácí masážní křeslo, bude STONE TFT Po zapnutí sériové obrazovky LCD se objeví startovací rozhraní. Po krátkém pobytu přejde na konkrétní rozhraní. Toto rozhraní slouží k nastavení našeho aktuálního času. Při nastavování se objeví klávesnice. Po nastavení klepněte na tlačítko OK a přejděte do rozhraní pro výběr masážního režimu. Zde jsem nastavil tři režimy: masáž hlavy, masáž zad a komplexní režim. V tomto režimu lze nastavit intenzitu masáže, lze nastavit vysoký, střední a nízký stupeň a k indikaci intenzity bude sloužit příslušná kontrolka LED; lze také nastavit časy masáže, po dosažení nastaveného počtu se automaticky zastaví; v komplexním modelu se bude masírovat hlava a záda současně, a když to není potřeba, lze ji vypnout. Těchto úkonů se dosahuje prostřednictvím obrazovky sériového portu dotykové obrazovky STONE pro přenos příkazů.

Obrázek

Moduly potřebné pro projekt:

STONE STWI070WT-01

② Arduino UNO;

③ Pohon krokového motoru a modul;

④ Modul LED pole;

Návrh grafického uživatelského rozhraní

Obrázek

Nastavení klíčových příkazů:

Každému tlačítku je třeba přiřadit odpovídající akci, proto jsou provedena následující nastavení:

Kód: Vybrat vše

//HEAD

uint8_t   HeadGearHigh[9]       = {0xA5, 0x5A, 0x06, 0x83, 0x00, 0x0E, 0x01, 0x00, 0x03};

uint8_t   HeadGearMiddle[9]     = {0xA5, 0x5A, 0x06, 0x83, 0x00, 0x0E, 0x01, 0x00, 0x02};

uint8_t   HeadGearLow[9]        = {0xA5, 0x5A, 0x06, 0x83, 0x00, 0x0E, 0x01, 0x00, 0x01};

 

uint8_t   HeadTiming[9]         = {0xA5, 0x5A, 0x06, 0x83, 0x00, 0x11, 0x01, 0x00, 0x09};

 

uint8_t   HeadModeStart[9]    = {0xA5, 0x5A, 0x06, 0x83, 0x00, 0x19, 0x01, 0x41, 0x61};

uint8_t   HeadModeStop[9]     = {0xA5, 0x5A, 0x06, 0x83, 0x00, 0x24, 0x01, 0x46, 0x66};

 

//BACK

uint8_t   BackGearHigh[9]       = {0xA5, 0x5A, 0x06, 0x83, 0x00, 0x1A, 0x01, 0x00, 0x01};

uint8_t   BackGearMiddle[9]     = {0xA5, 0x5A, 0x06, 0x83, 0x00, 0x1A, 0x01, 0x00, 0x02};

uint8_t   BackGearLow[9]      = {0xA5, 0x5A, 0x06, 0x83, 0x00, 0x1A, 0x01, 0x00, 0x03};

 

uint8_t   BackModeStart[9]      = {0xA5, 0x5A, 0x06, 0x83, 0x00, 0x0C, 0x01, 0x42, 0x62};

uint8_t   BackModeStop[9]     = {0xA5, 0x5A, 0x06, 0x83, 0x00, 0x0D, 0x01, 0x43, 0x63};

 

//Integrated

uint8_t   IntegratedModeStart[9]= {0xA5, 0x5A, 0x06, 0x83, 0x00, 0x0F, 0x01, 0x44, 0x64};

uint8_t   IntegratedModeStop[9] = {0xA5, 0x5A, 0x06, 0x83, 0x00, 0x1F, 0x01, 0x45, 0x65};
Připojení

Obrázek

Kód

Kód: Vybrat vše

//#include <Stepper.h>
#include "stdlib.h"
#include <AccelStepper.h>

const float STEPCYCLE = 2050;//A Cycle by Step is 2050;
//  myStepper.setSpeed(100);//5V, it can be set up to 180

const float TheMaxSpeed = 1000.0;  // change this to fit the number of steps per revolution

const float headspeed_str[4] = 
{
  0,
  TheMaxSpeed / 4,
  TheMaxSpeed / 2,
  TheMaxSpeed,
};

const float backspeed_str[4] = 
{
  0,
  TheMaxSpeed,
  TheMaxSpeed / 2,
  TheMaxSpeed / 4,
};

// for your motor

// initialize the stepper library on pins 8 through 11:
AccelStepper HeadStepper(AccelStepper::FULL4WIRE, 15, 0, 2, 4);//The middle two IO are reversed
AccelStepper BackStepper(AccelStepper::FULL4WIRE, 16, 5, 17, 18);//The middle two IO are reversed


const int ledPin_1 =  14;      // the number of the LED pin
const int ledPin_2 =  27;      // the number of the LED pin
const int ledPin_3 =  26;      // the number of the LED pin
const int ledPin_4 =  25;      // the number of the LED pin
const int ledPin_5 =  33;      // the number of the LED pin
const int ledPin_6 =  21;      // the number of the LED pin
const int ledPin_7 =  22;      // the number of the LED pin
const int ledPin_8 =  23;      // the number of the LED pin

//buf
uint8_t   cout_i = 0;
uint8_t   RecievedTemp[9]       = {0};
float     settingbuf[2]       = {TheMaxSpeed, 0};
float   MorenCycle      = 100;

//HEAD
uint8_t   HeadGearHigh[9]       = {0xA5, 0x5A, 0x06, 0x83, 0x00, 0x0E, 0x01, 0x00, 0x03};
uint8_t   HeadGearMiddle[9]     = {0xA5, 0x5A, 0x06, 0x83, 0x00, 0x0E, 0x01, 0x00, 0x02};
uint8_t   HeadGearLow[9]        = {0xA5, 0x5A, 0x06, 0x83, 0x00, 0x0E, 0x01, 0x00, 0x01};

uint8_t   HeadTiming[9]         = {0xA5, 0x5A, 0x06, 0x83, 0x00, 0x11, 0x01, 0x00, 0x09};

uint8_t   HeadModeStart[9]    = {0xA5, 0x5A, 0x06, 0x83, 0x00, 0x19, 0x01, 0x41, 0x61};
uint8_t   HeadModeStop[9]     = {0xA5, 0x5A, 0x06, 0x83, 0x00, 0x24, 0x01, 0x46, 0x66};

//BACK
uint8_t   BackGearHigh[9]       = {0xA5, 0x5A, 0x06, 0x83, 0x00, 0x1A, 0x01, 0x00, 0x01};
uint8_t   BackGearMiddle[9]     = {0xA5, 0x5A, 0x06, 0x83, 0x00, 0x1A, 0x01, 0x00, 0x02};
uint8_t   BackGearLow[9]      = {0xA5, 0x5A, 0x06, 0x83, 0x00, 0x1A, 0x01, 0x00, 0x03};

uint8_t   BackModeStart[9]      = {0xA5, 0x5A, 0x06, 0x83, 0x00, 0x0C, 0x01, 0x42, 0x62};
uint8_t   BackModeStop[9]     = {0xA5, 0x5A, 0x06, 0x83, 0x00, 0x0D, 0x01, 0x43, 0x63};

//Integrated
uint8_t   IntegratedModeStart[9]= {0xA5, 0x5A, 0x06, 0x83, 0x00, 0x0F, 0x01, 0x44, 0x64};
uint8_t   IntegratedModeStop[9] = {0xA5, 0x5A, 0x06, 0x83, 0x00, 0x1F, 0x01, 0x45, 0x65};
void setup() 
{
//Serial port initialization
    Serial.begin(115200);
    
//The motor starts running separately
//  HeadStepper_Setting_Run(TheMaxSpeed, 5);
//  BackStepper_Setting_Run(TheMaxSpeed, 5);

  // initialize the LED pin as an output:
  pinMode(ledPin_1, OUTPUT);
  pinMode(ledPin_2, OUTPUT);
  pinMode(ledPin_3, OUTPUT);
  pinMode(ledPin_4, OUTPUT);
  pinMode(ledPin_5, OUTPUT);
  pinMode(ledPin_6, OUTPUT);
  pinMode(ledPin_7, OUTPUT);
  pinMode(ledPin_8, OUTPUT);
  
  digitalWrite(ledPin_1, HIGH);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(ledPin_2, HIGH);  // turn the LED on (HIGH is the voltage level)
  digitalWrite(ledPin_3, HIGH);  // turn the LED on (HIGH is the voltage level)
  digitalWrite(ledPin_4, HIGH);  // turn the LED on (HIGH is the voltage level)
  digitalWrite(ledPin_5, HIGH);  // turn the LED on (HIGH is the voltage level)
  digitalWrite(ledPin_6, HIGH);  // turn the LED on (HIGH is the voltage level)
  digitalWrite(ledPin_7, HIGH);  // turn the LED on (HIGH is the voltage level)
  digitalWrite(ledPin_8, HIGH);  // turn the LED on (HIGH is the voltage level)

}

void loop() 
{
  if(Serial.available() != 0)
  {
    for(cout_i = 0; cout_i < 9; cout_i ++)
    {
        RecievedTemp[cout_i] = Serial.read();
    }
//    if(HeadStepper.isRunning() == true)
//    {
//      HeadStepper.stop();    
//    }
//    if(BackStepper.isRunning() == true)
//    {
//      BackStepper.stop();    
//    }

//  else
//  {
//    Stepper2_Setting_Run(TheMaxSpeed, 5);
//  }
//  Serial.write(RecievedTemp, 9);
  switch(RecievedTemp[5])
  {
  case 0x0E://head gear
        if(HeadStepper.isRunning() == true)
      {
        HeadStepper.stop();    
      }
    
      settingbuf[0] = headspeed_str[RecievedTemp[8]];

    if(RecievedTemp[8] == 1)
    {
      digitalWrite(ledPin_1, LOW);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_2, LOW);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_3, LOW);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_4, HIGH);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_5, HIGH);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_6, HIGH);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_7, HIGH);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_8, HIGH);   // turn the LED on (HIGH is the voltage level)
    }
    else if(RecievedTemp[8] == 2)
      {
      digitalWrite(ledPin_1, LOW);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_2, LOW);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_3, LOW);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_4, LOW);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_5, LOW);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_6, LOW);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_7, HIGH);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_8, HIGH);   // turn the LED on (HIGH is the voltage level)
      }
    else
      {
      digitalWrite(ledPin_1, LOW);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_2, LOW);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_3, LOW);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_4, LOW);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_5, LOW);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_6, LOW);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_7, LOW);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_8, LOW);   // turn the LED on (HIGH is the voltage level)
      }
    break;
  case 0x11://head timing
        if(HeadStepper.isRunning() == true)
      {
        HeadStepper.stop();    
      }
    
    settingbuf[1] = RecievedTemp[8];
    break;
  case 0x19://head start
    if(settingbuf[1] == 0)
    {
      settingbuf[1] = 5;
    } 
    break;
  case 0x24://head stop
      if(HeadStepper.isRunning() == true)
      {
          HeadStepper.stop();    
      }
    break;
    
  case 0x1A://backgear
    if(BackStepper.isRunning() == true)
      {
          BackStepper.stop();    
      }
      settingbuf[0] = backspeed_str[RecievedTemp[8]];
    if(RecievedTemp[8] == 3)
    {
      digitalWrite(ledPin_1, LOW);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_2, LOW);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_3, LOW);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_4, HIGH);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_5, HIGH);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_6, HIGH);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_7, HIGH);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_8, HIGH);   // turn the LED on (HIGH is the voltage level)
    }
      else if(RecievedTemp[8] == 2)
      {
      digitalWrite(ledPin_1, LOW);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_2, LOW);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_3, LOW);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_4, LOW);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_5, LOW);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_6, LOW);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_7, HIGH);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_8, HIGH);   // turn the LED on (HIGH is the voltage level)
      }
      else
      {
      digitalWrite(ledPin_1, LOW);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_2, LOW);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_3, LOW);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_4, LOW);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_5, LOW);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_6, LOW);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_7, LOW);   // turn the LED on (HIGH is the voltage level)
      digitalWrite(ledPin_8, LOW);   // turn the LED on (HIGH is the voltage level)
      }
    break;
  case 0x0C://backstart
    BackStepper_Setting_Run(settingbuf[0], MorenCycle);
      break;
  case 0x0D://backstop
      if(BackStepper.isRunning() == true)
    {
      BackStepper.stop();    
    }
    break;
  case 0x0F://integratestart
    if(HeadStepper.isRunning() == true)
    {
        HeadStepper.stop();  
    }
    if(BackStepper.isRunning() == true)
    {
      BackStepper.stop();    
    }    
    break;
  case 0x1F://integratedstop
    if(HeadStepper.isRunning() == true)
    {
      HeadStepper.stop();  
    }
    if(BackStepper.isRunning() == true)
    {
      BackStepper.stop();  
    }   
    break;
  default:
    break;
  }
//    Serial.write(&Targetvalue, 1);
//    Serial.print(Targetvalue);
  }
}
demonstrační obrázek

Obrázek

Obrázek

Odpovědět

Kdo je online

Uživatelé prohlížející si toto fórum: Žádní registrovaní uživatelé a 2 hosti