Shahariar
Published © CC BY-SA

Touch HMI Medical Commode for Visually Impaired Patients

A demonstration of touch control-based user interface for portable medical commode with all the quirks of a fully-fledged toilet

IntermediateWork in progress12 hours321
Touch HMI Medical Commode for Visually Impaired Patients

Things used in this project

Hardware components

PSoC 4 Prototyping Kit
Cypress PSoC 4 Prototyping Kit
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×2
Fermion: Voice Recorder Module (Breakout)
DFRobot Fermion: Voice Recorder Module (Breakout)
×1
Grove - OLED Display 1.12'' V2
Seeed Studio Grove - OLED Display 1.12'' V2
×1
Stereo Enclosed Speaker - 3W 8Ω
DFRobot Stereo Enclosed Speaker - 3W 8Ω
×1
Grove - Vibration Motor
Seeed Studio Grove - Vibration Motor
×4
BOOSTXL-ULN2003 ULN2003A Dual Stepper Motor BoosterPack
Texas Instruments BOOSTXL-ULN2003 ULN2003A Dual Stepper Motor BoosterPack
×2
Laser Diode, Visible
Laser Diode, Visible
×4
Axial Fan, 10" Exhaust
Axial Fan, 10" Exhaust
×1
DFRobot Water Pump
×1
Hair Dryer 2000W Generic
×1
Plastic Portable Commode
×1
Flexible Pipes
×1

Software apps and online services

PSoC Creator
Cypress PSoC Creator

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

sch int

PSoC Internal Schematic

sch_final_corrv1_veHabqF3TD.bmp

Code

main.c

C/C++
final code (bug fixed)
#include <project.h>
#include <stdlib.h>
#include <stdio.h>
#include "ssd1306.h"

#define DISPLAY_ADDRESS 0x3C // I2C Oled address 0x3C

uint8_t which_button; // keeps track of which button is touched
uint8_t wash_speed = 0; //  finger position on linear slider
uint16_t x_pos; //  x position of finger on trackpad
uint16_t y_pos; //  y position of finger on trackpad


// following function will display text msg on OLED screen //

void show_info_on_OLED (char line1[7],char line2[7])
{
        display_clear();    
        gfx_setCursor(0,0);
        gfx_print(line1);
        gfx_setCursor(0,32);
        gfx_print(line2);
        display_update();
    
}

// main loop

int main()
{
    // Start I2C to drive OLED display
    I2COLED_Start();
    
    // start 2 PWM blocks to control servos 
    PWM_1_Start();
    PWM_2_Start();
    //PWM_3_Start();
    
    // enable global interrupt
    CyGlobalIntEnable;
    
    // start capsense and set baseline for parasitic capacitance compensation
    CapSense_Start();
    CapSense_InitializeAllBaselines();
    // Baseline is critical for proper operation of capsense
    // when this function is doing its thing, do not touch anything !
    
    // init OLED display and set font, orientation, color
    display_init(DISPLAY_ADDRESS);
    gfx_setRotation(2);
    gfx_setTextSize(3);   
    gfx_setTextColor(WHITE);
    
          /// welcome message /// 
    //    show_info_on_OLED("CAPSENS"," PSOC 4");
    //    CyDelay(2000);
    //    show_info_on_OLED(" TOUCH ","CONTROL");    
            
        
    for(;;)
{

        
        while ( CapSense_IsBusy() !=0 )
        {
        } // wait until something is being sensed on capsense electrodes    
         
          // process all capsense interfaces/sensors
            CapSense_ProcessAllWidgets();
            CapSense_IsAnyWidgetActive();
        
        // get latest finger position on touchpad 
        if( CapSense_IsWidgetActive(CapSense_TOUCHPAD0_WDGT_ID)) 
        {
        uint32_t xy = CapSense_GetXYCoordinates(CapSense_TOUCHPAD0_WDGT_ID);
        show_info_on_OLED(" AIMING"," NOZZLE");
                
        // separate xy coordinate of finger pos on touchpad 
            if (xy != 0xFFFF)
            {
            y_pos = xy >> 16;
            x_pos = (uint16)xy; 
            }

        }
        
        
    // process touch buttons pressed by user and perform operation
        if( CapSense_IsWidgetActive(CapSense_BUTTON0_WDGT_ID)) 
        {
        which_button = 0;
        show_info_on_OLED("HOT AIR"," DRYER");
        Hot_Air_Dryer_Write(!(Hot_Air_Dryer_Read()));
        ButtonLED2_Write(!ButtonLED2_Read());
        CyDelay(700);
        }    
        else if( CapSense_IsWidgetActive(CapSense_BUTTON1_WDGT_ID))
        {
        which_button = 1;
        show_info_on_OLED("ENABLE","WASHING");
        ButtonLED6_Write(!ButtonLED6_Read());
        CyDelay(700);
        }    
        else if( CapSense_IsWidgetActive(CapSense_BUTTON2_WDGT_ID))
        {
        which_button = 2;              
        show_info_on_OLED("DISABLE","WASHING");
       // ButtonLED5_Write(!ButtonLED5_Read());
       CyDelay(700);
  
        }    
        else if( CapSense_IsWidgetActive(CapSense_BUTTON3_WDGT_ID))
        {
        which_button = 3;
        show_info_on_OLED("ANTINUM","MASSAGE");
        Anti_Numb_Massage_Write(!(Anti_Numb_Massage_Read()));
        ButtonLED1_Write(!ButtonLED1_Read());
        CyDelay(700);
        }    
        else if( CapSense_IsWidgetActive(CapSense_BUTTON4_WDGT_ID))
        {
        which_button = 4;
        show_info_on_OLED("NO ODOR","EXT FAN");
        Odor_Extractor_Fan_Write(!(Odor_Extractor_Fan_Read()));
        ButtonLED3_Write(!ButtonLED3_Read());
        CyDelay(700);
        }
        else if( CapSense_IsWidgetActive(CapSense_BUTTON5_WDGT_ID))
        {
         which_button = 5;
         show_info_on_OLED("PRIVACY","  MODE ");
         ButtonLED4_Write(!ButtonLED4_Read());
         for(int i = 0; i <3; i ++)
        {
         WhiteNoise_PrivacyMode_Write(0);
         CyDelay(250);
         WhiteNoise_PrivacyMode_Write(1);
         CyDelay(250);
         } 
        }
        
        // process touch slider to adjust wash speed
        
        if(CapSense_IsWidgetActive(CapSense_LINEARSLIDER0_WDGT_ID))
        {
        wash_speed = CapSense_GetCentroidPos(CapSense_LINEARSLIDER0_WDGT_ID);
        show_info_on_OLED("WASHING"," SPEED ");
        }
        
        // control servo to aim water sprayer nozzle
        
        if (x_pos<=100 && which_button == 1)
        {
        PWM_1_WriteCompare(4380+(x_pos));
        }
        
         if (y_pos<=100 && which_button == 1)
        {
        PWM_2_WriteCompare(4460+(y_pos));
        }
        
        //  disable spray water pump's pwm drive 
        if (which_button == 2)
        {
        PWM_3_Stop();
        }
        
        //  enable spray water pump's pwm drive 
        
        if (which_button == 1)
        {
        PWM_3_Start();
        
        // adjust water flow rate with pwm ducy
            if (wash_speed>=10 &&  wash_speed<=100 )
            {
            PWM_3_WriteCompare(480*(wash_speed/10));    
            }
        }
        
        // scan all capsense for new user input
        CapSense_ScanAllWidgets();     
        //CapSense_UpdateEnabledBaselines();
         
    } // end of forever
} // end of main

full code

C/C++
Unzip and Import to PSoC Creator 4.4 IDE
No preview (download only).

Credits

Shahariar

Shahariar

71 projects • 263 followers
"What Kills a 'Great life' is a 'Good Life', which is Living a Life Inside While Loop"

Comments