Smart Medicine Box

Our ECE 4760 final project is to build a microcontroller based smart medicine box. Our medicine box is targeted on users who regularly take drugs or vitamin supplements, or nurses who take care of the older or patients. Our medicine box is programmable that allows nurses or users to specify the pill quantity and day to take pills, and the serve times for each day. Our smart medicine box contains seven separate sub-boxes. Therefore, nurses or users can set information for seven different pills. When the pill quantity and time have been set, the medicine box will remind users or patients to take pills using sound and light. The specific number of pills needs to be taken will be displayed by a seven segment led display placed on the corresponding sub-box. Compared with the traditional pill box that requires users or nurses to load the box every day or every week. Our smart medicine box would significantly release nurses or users’ burden on frequently preloading pills for patients or users.

Rationale and Inspiration

I am an international student, and during holidays I always bring some USA made medicines to my grandparents back in China. I found they always have trouble remember the number of pills they need to take from each of the medicine bottle because they couldn’t read English. They also complained to me that they sometimes forget to take to pills, and some medicines were expired due to this reason. Therefore, the idea to make a smart pillbox that would help people like my grandparents came to my mind. After I talked with my partner Jie, we broadened the targeted users of our pillbox from just the older to people who regularly take pills. We also thought nurses who take care of patients could also benefit from, since they also regularly prepare pills for patients. After the targeted user being defined, we then defined the specifications of our device based on the user needs. The device should be able to generate loud sound so that even people with impaired hearing were able to hear it. The device should demonstrate ease of use. Therefore, we decided to use a LCD and a keypad as the user interface. In order to help user remember the number of pills they need to take, we also used several seven segment LED displays to indicate the number of pills the user need to take. Based on theses specifications, we designed a high-level block diagram (figure below) to demonstrate the overall design of our device.

There are five major components for our device, including a pill box containing seven separate small boxes; a speaker module; a 3×4 keypad; an Atmel 1284p microcontroller; seven segment LED display (7 units); and a 2×16 characters LCD screen.
Functionality of each component:
Keypad: Keypad is used for the user or nurse to enter the information of time when the smart box would send “reminder” (displaying numbers and playing synthesized voice). It is also used for the user to enter a number to command a specific pill box to open on a specific day. (say, open No.1 pill box on Monday), and user can also enter the frequency information to take pills for each day. The keypad is also used for stopping the music and led display when the user has taken the pill.  LCD: The 2 line, 16 characters LCD screen is used to display the instruction information, the number of pills need to be taken, and the current time and date. Speaker Module: The speaker module is used to play the synthesized sound to remind the user to take pill.
Pill boxes: We used a pillbox system containing 7 separate small pillboxes. Each box has a seven segment led display placed on the box. For our pill system, the user can store up to seven different types of pills, which can be stored in those seven small separate boxes. He or she can also specify the different combinations of pill boxes to be open for each day.
Microcontroller: One Atmel 1284p is used to execute all the commands mentioned above.

Logical Structure

Our device uses the state machine and real time clock (RTC) to provide real-time functionality. This state machine determines which key has been pressed and provides keypad debounce functionality. We use the 16MHz external oscillator to build a real time clock for the device. Since the accuracy for the external crystal oscillator has a very high accuracy, and based on our calculation, our RTC should only delay about several minutes in a week. Such error is tolerable, since we not particularly used the RTC as an alarm clock.
The device’s logic structure contains three major stages: 1. User initialization stage. 2. Comparison stage. 3. Reminder stage. In the user initialization stage, the user enters the current time, date and pill information (including amount and serve time for each type of pill). After the user finishing entering all the information, the device will enter the comparison stage unless the initialization button is pressed. During the comparison stage, the system compares the pill information for each of the sub-box with the time counted by RTC. Once the information entered by the user matches the RTC time, the system will jump out of comparison stage and enter the reminder stage. In the reminder stage, the device will continuously play synthesized voice, and the seven segments LED display will show the number of pills needs to be taken on each of the sub-box.
Smart Medicine Box

Hardware Tradeoffs

Initially, we planned to use electrical magnetic solenoids to control the open and close of the lids for each of the sub- boxes. However, the size of the solenoids available is not desirable to be attached to the box, and shipping time for the solenoids is also too long. Therefore, we decided to replace the solenoids with the seven segment led displays to achieve the same functionality, which is to improve ease of use of the device.
Since we want to use one microcontroller to achieve all the functionality, tradeoffs need to be made between saving pins and complicating the circuits. The 1284p microcontroller has 4 ports, 28 pins total. The LCD module needs 8 pins and the keypad needs 7 pins. The speaker module needs a specific pin that is able to send PWM wave. Currently, we used a seven sub-boxes system. If we directly use microcontroller to control all seven segment LED displays, The rest 2 ports would just be enough. However, if we need to add more features or add more sub-boxes, this control mechanism of led displays is definitely inefficient. Therefore, we decided to use the 74LS138 3 to 8 decoder to control the switches (in this case are 2N3904 npn transistors) for those LED displays. Using 3 to 8 decoder could save us 4 additional pins for future add on features or sub-box. However, using 74LS138 would complicate the circuitry design. Current, we built the external circuitry on breadboard due to the limitation of time. In the future, customized PCB board can be used to simplify the circuitry as well as miniaturize the device size.

Software Tradeoffs

When we displayed instructions on the LCD screen during initialization process, we previously used the scheme developed in lab 2, that we showed the static texts and dynamic input at the same time. However, due to the large amount of parameters in our system, we cannot use this scheme anymore because that made the response of keypad extremely slow. Hence, we developed a new scheme for the instruction texts display that will only show the static characters once at the beginning of each status and this method achieved much better result for the response speed of keypad.

Existing Products

We found several different pillbox products available in the market. The cheapest one was the traditional pillbox, which contained seven boxes for seven different days of a week. Such pillbox normally cost below $10. However, user had to load the pills to the boxes every week. Mixing different pills in the same box would increase the risk of making mistakes. We also found another type of pillbox, which had the sound reminder, and was able to remind the user to take medicine at user specified time. However, the users still have to put different kinds of pills in the same box, and reload the boxes every week. Additionally, It could only remind the user to take pills once a day. The average costs of this type of pillbox were about $50, which was still expensive than ours. Therefore, we think it was necessary to build a cheap and functional smart pillbox that could bring more convenience for the user.

Overall Software design

We built a medicine box with an integrated software system running in the MCU. The programming platform is AVRStudio4.0, and programming language is standard C and WINAVR/GCC compiler. Generally, our software system can be divided into four parts, including real time clock, user interface, LED control and sound generation. We could get information for each medicine boxes from the user input and store the information in structure variables. The real time clock would keep running once user finishes initialization. After all the information has been entered. The system would enter comparison status. The comparison function would detect if there are medicine should be taken at that time. When it finds medicine should be taken, the audio will broadcast. After the user response to the system by pushing certain button, LEDs would indicate the amount of medicines for each box. Our system flow chart is as follow.

Read More: Smart Medicine Box

Leave a Comment

Your email address will not be published. Required fields are marked *