Giter Club home page Giter Club logo

pillspiller's Introduction

PillSpiller

Second year embedded project programmed to dispense pills using Raspberry Pi Pico WH. The program is implemented in the C language and built in the Pico SDK environment.

Device

image
Figure 1: Main parts of the pill dispenser device.

Components:

Project Goal

The goal of the project is to implement an automated pill dispenser that dispenses daily medicine to a patient. The dispenser has eight compartments. One of them is used for calibrating the dispenser wheel position leaving the other seven for pills. Dispenser wheel will turn daily at a fixed time to dispense the daily medicine and the piezoelectric sensor will be used to confirm that pill(s) were dispensed. The dispenser state is stored in non-volatile memory so that the state of the device (number of pills left, daily dispensing log, etc) will persist over restarts. The state of the device is communicated to a server using LoRaWAN network. For testing purposes, the time between dispensing pills is reduced to 30 seconds.

Minimum Requirements

When the dispenser is started it waits for a button to be pressed and blinks an LED while waiting. When the button is pressed the dispenser is calibrated by turning the wheel at least one full turn and then stopping the wheel so that the compartment with the sensor opening is aligned with the drop tube. After calibration the program keeps the LED on until user presses another button. Then it dispenses pills every 30 seconds starting from the button press. When the wheel is turned, the piezo sensor is used to detect if a pill was dispensed or not. If no pill was detected the LED blinks 5 times. When all pills have been dispensed (wheel turned 7 times) the program starts over (wait for calibration, etc.).

Advanced Requirements

Device remembers the state of the device across boot/power down. Device connect to LoRaWAN and reports status of the device when there is a status change (boot, pill dispensed/not dispensed, dispenser empty, power off during turning, etc.) Device can detect if it was reset / powered off while motor was turning. Device can recalibrate automatically after power off during middle of a turn without dispensing the pills that still remain.

Methods and Material

Processing Environment

Raspberry Pi Pico WH and Raspberry Pi Debug Probe

The Raspberry Pi Pico WH, paired with the Raspberry Pi Debug Probe, forms the core processing unit of the embedded device. Raspberry Pi Pico features a RP2040 microcontroller chip and a dual-core Arm Cortex M0+ processor, as illustrated on the left side of Figure 2. [1] The board supports a wide range of peripherals and also offers a 2.4 GHz wireless LAN connection.

image
Figure 2: showcases the Raspberry Pi Pico WH on the left and Raspberry Pi Debug Probe on the right. [1][2]

During the developmental phase of the project, the Raspberry Pi Debug Probe, depicted on the right side of Figure 1, plays a pivotal role. This USB device offers solderless, plug-and-play debug functionality through a standard ARM Serial Wire Debug (SWD) interface. [2]

I2C EEPROM

In order to store the state of the device throughout the boot process and the log messages, the implementation of a non-volatile memory storage is required. For this objective, an electrically erasable programmable read-only memory, the Elecrow’s Crowtail - I2C EEPROM, has been selected.

image
Figure 3: showcases the Crowtail i2c EEPROM, the non-volatile memory of the system. [3]

EEPROM is a modifiable memory, displayed in Figure 3, where bytes or pages can be erased and written to repeatedly by applying electrical voltage. It is widely used to store small amounts of data in electronic devices. The capacity of Crowtail - I2C EEPROM is 256k bits, providing ample storage for the device state. [4]

LoRaWAN Communication

LoRa, a radio communication technique derived from chirp spread spectrum (CSS) technology, encodes information on radio waves using chirp pulses. The LoRaWAN protocol further defines the communication protocol and system architecture for devices utilizing LoRa technology. [5]

The current state of the dispenser and essential information are transmitted through the LoRaWAN network. To facilitate this communication, the project has adopted the Grove LoRa-E5, showcased in Figure 4. This module establishes a connection to the processing environment through a UART connection.

image
Figure 4: Hardware specifications of the Grove - LoRa-E5, the LoRaWAN communication module for the project. [6]

Designed by Seeed studio, the Grove LoRa-E5 is a wireless radio module that supports both LoRa and LoRaWan protocols. [6] Each communication instance is controlled through AT commands. Once a connection with the server is established, each message is sent individually, with each transmission prompting a 10-second waiting period.

Dispenser Assembly

This subchapter introduces the aspect of the project with which the user directly interacts. Divided into two parts, the first section delves into the intricacies of the physical pill dispenser, while the second part places emphasis on the hardware's sensor components.

Stepper Motor

The base of the pill dispenser comprises two plastic components, crafted with a 3D printer: the base and the wheel, as illustrated in Figure 5. In addition to the plastic compartment, the base houses the stepper motor, as well as the the optical and piezoelectric sensors.

image
Figure 5: Showcase of pill dispenser: the wheel on the left, base on the right, and the two sensors - piezoelectric and optical.

The plastic part of the base features an opening designed for pill dispensing. At the bottom of this aperture, resides the piezo sensor that detects the descent of the pill(s). The wheel connects to the base through the stepper motor shaft and incorporates a calibration opening that facilitates the functionality of the optical sensor, known as the opto fork. The wheel is divided into 8 equal compartments: one for calibration and seven for storing drugs corresponding to each day of the week.

image
Figure 6: Elecrow’s Stepper motor driver. [7]

The project utilizes a 28BYJ-48 stepper motor, characterized as a 5-wire unipolar motor with 4 coils. Controlled through a stepper motor driver, it facilitates the precise rotation of the dispenser wheel, employing a half-stepping mechanism for accuracy. The specific stepper motor driver utilized is Elecrow’s ULN2003 Stepper Motor Driver, displayed in Figure 5, connected to the processing environment. This driver utilizes ULN2003A to amplify the signal, ensuring efficient and controlled operation. [7]

Sensors of the System

The system incorporates two sensors: an optical sensor to precisely detect the location of the dispenser wheel and a piezoelectric sensor to verify the dispensing of the pill(s) from the respective compartment. Each is discussed in their own subchapter.

Optical Sensor

Optical fork sensors, also known as optical sensors, typically consist of a "fork" structure resembling two parallel arms joined together. One arm emits light beams, while the other arm detects whether the beams are interrupted or not. These sensors find applications in various industries for detecting the presence or absence of objects.

In the project, the optical fork sensor with a plastic housing is embedded into the base plastic of the pill dispenser. The programmed functionality, utilizing the opto fork, allows for the detection of the calibration opening on the dispense wheel. This detection facilitates the precise calibration of the wheel by recognizing signals indicating the absence of an interrupting object.

Piezoelectric Sensor

A piezoelectric sensor leverages the piezoelectric effect to convert mechanical stimuli, such as changes in pressure, acceleration, temperature, strain, or force, into an electrical charge. [8] This unique property makes piezoelectric sensors versatile instruments capable of capturing and translating various physical phenomena into measurable electrical signals.

In the context of the pill dispenser, the piezoelectric sensor is strategically employed at the bottom of the pill dispensing opening. It detects the impact caused by the falling pill, allowing the system to validate the successful dispensing of medication. This utilization highlights the sensor's crucial role in providing real-time feedback on the dispenser's operational status, ensuring precision and reliability in the medication dispensing process.

Operation Principle

image
Figure 7: Logic of implemented program.

References

1 Raspberry Pi Pico WH
2 Raspberry Debug Probe
3 Partco. Crowtail I2C EEPROM 2.0 (24C256).
4 Elecrow. Crowtail - I2C EEPROM.
5 Wikipedia. LoRa.
6 Seeed studio. Grove - LoRa-E5.
7 Electrow. ULN2003 Stepper Motor Driver.
8 Wikipedia. Piezoelectric sensor.

pillspiller's People

Contributors

gemmus avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.