Working Principle

Part 1: User Interface (RPi)

How to Run the Program?

The code for the Arduino Mega should be opened in Arduino IDE (on the RPi), while the code for the RPi is a Python File which should be opened and run with Thonny (on the RPi).

How to Add an Entry to Dispense Pills at a Specified Time?

Running the main Python program should open a Menu window in full screen mode, displaying a table and buttons below it, as shown below.

When “Add Row” is pressed, the Entry window will open in full screen mode for users to key in the quantity of each type of pills to be dispensed at the specified timing. Users will slide the slider bars on the touchscreen to register their user inputs as shown below.

Users will press “Save” to confirm their entry, or “Exit” if they wish to cancel their new entry. If “Save” is pressed, the new entry will show up on the table in the main Menu window.

How to Edit an Existing Entry?

To edit an existing entry, users must first tap on the existing entry before the “Edit Row” button. The Entry window will pop up in full screen mode again, for users to key in their inputs for a new entry that will overwrite the previous entry upon pressing “Save”. Users can again press “Exit” if they wish to cancel their edits.

How to Delete an Existing Entry?

To delete an existing entry, users must first tap on the existing entry before the “Delete Row” button.

A pop-up will appear on the screen to confirm if users wish to delete the selected entry permanently. If “OK” is selected, the entry will be permanently deleted, else select “Cancel” to prevent the deletion from occurring.

How to Exit the Program?

Press “Exit” on the Menu window to exit the program.

 

Part 2: Dispensing Mechanism (Arduino + Printed Parts)

Program Flowchart

When the specified time for dispensing pills has been reached (i.e. current time = dispense time in an existing entry), information about the specific entry – quantity of each type of pills to be dispensed – is sent from the RPi to the Arduino Mega.

For each pill to be dispensed, the stepper motor alternates ACW and CW rotation (~80°) to “jiggle” the pills in the dispensing cup, such that one pill will fit into the groove in the inner disc within the dispensing cup. The stepper motor then rotates ACW ~240° to dispense the pill into the curved tube. As the pill slides down the curved tube, drops onto the slide, and slides into the collection cup. There is a pause in motor movement for the laser sensor and laser (placed at the bottom of the slide) to check if the pill has been successfully dispensed, then the motor will rotate ACW ~120° to return the inner disc to its starting position.

As the pill exits the slide, the laser sensor will detect that the laser has been briefly blocked to confirm that the pill has been successfully dispensed and proceed with the rest of the code. If a pill had not been dispensed by the motor, the laser sensor will not detect any blocking of the laser, hence it will repeat the dispensing of that particular pill.

The collection cup rests on its platform which has a load cell underneath. The load cell is automatically calibrated once the code begins to run. Each dispensed pill falls into the collection cup. When all the pills for that particular timing have been dispensed, the speaker will play a recurring message to alert the users that their pills have been successfully dispensed.

When the load cell detects that the weight has dropped to 0 (collection cup has been lifted up by the user), the speaker will stop playing the recurring message. The user should return the collection cup to its platform after consuming all the pills. Upon the return of the collection cup, if the weight detected by the load cell > weight of the collection cup, this indicates that the user has yet to consume all the pills and might have missed some pills that are still remaining in the cup. The speaker will then play a recurring reminder message to remind users to consume the remaining pill(s). Only when the weight detected by the load cell = weight of collection cup, the speaker will play music, indicating that users have successfully consumed all pills dispensed.