Category: Medications

DIY Automatic Medication Dispenser

AbleData does not produce, distribute or sell any of the products listed on this website, but we provide you with information on how to contact manufacturers or distributors of these products. If you are interested in purchasing a product, you can find companies who sell it below.

The Automatic Medication Dispenser is designed for use by individuals who need reminders to take their prescription medicine as a result of cognitive impairments, dementia and stroke.  The 'machine' has seven drums (one for each day of the week) with 4 compartments that can be filled with medicine. When filled, the drums are put back in the machine.  On the front of the machine is a LCD-screen and 2 buttons. There the time and date and program can be set when the user needs the medication. When it is time for your medication, the machine drops the correct pills and sounds an alarm until you take the pills and push a button. After that it goes back to "sleep" until the next alarm.

The drum that has 5 compartments with a stepper motor that turns the right compartment to a hole, so the pills can drop out. There are 7 drums with 5 compartments so that the user can use a drum for each day and every drum contains a maximum of 4 doses (5th compartment always has to be empty). A clock is added to the electronics circuit. I've used the very popular DS1307 Clock IC. Main reason is that is a very easy clock to use and that is only uses 2 wires (I2C) for communication with the microcontroller. It also has its own battery backup system so it can run up to 10 years without main power.  A 9 Volt backup battery was added and all data is stored on an EEPROM IC so that it won't be lost. The EEPROM IC is a 24LC16B that uses the same two wires as the clock to communicate with the microcontroller. The medication dispenser has only 2 buttons and an LCD screen to access the needed information.

It also has a buzzer so that it can give a sound alarm when the pills are delivered. The author used 3 millimeter Acrylate and used CNC-milled into all the different bits and pieces. A clear acrylic tube makes for the housing.  In the back panel a hole of 5.5 millimeters was drilled, in which the motor can be fitted. In the inside disk a hole of 1 millimeter was drilled so that it could be stuck on the 1.5 millimeter shaft of the motor.  Removed a section from the tube to create an opening through which the pills can drop out.  After that everything was glued together with Cyano-Acrylic glue.  it is a standard 5 Volt supply used on many projects. 'power-on led' and a connection for a 9 Volt battery is added. The 2 diodes should prevent the 9 Volt battery to 'charge' when the 12 Volt is on and vice versa. Port D on the microcontroller is entirely used for the LCD and the 2 buttons (INT0 and INT1). Port B is used for ISP programming (PB3 to PB5 + PC6 for reset) and to sent the pulses for the stepper-motors to the drivers (PB0 to PB2). The communication with the clock and EEPROM goes via an I2C protocol and uses PC4 and PC5. PC0 is used for the buzzer and PC1 to PC3 go to the 74HCT238. The 74HCT238 is a 3 to 8 decoder/converter and decodes a 3 pin binary input to a decimal output. I use it to save pins on my microcontroller.

The output of this IC turns the logic voltage of the drivers on and sets the enable pins to 1. One driver is used for each day of the week. As said before the clock and the EEPROM use the same 2 wires to communicate with the microcontroller via an I2C protocol. It is a pretty easy and straightforward way to communicate (especially if you use bascom AVR like I do) and it allows you to communicate with 127slave devices via 2 wires. Just don't forget to add the 2 pull-up resistors (in this case 4,7K). Interface board: Port D on the main board, is connected to a 10 pin female header so that it can be connected directly to the interface board by a flat cable. The power for the interface board also comes via the cable from the main board.  The 10K resistor and the 10K potentiometer are used to set the brightness of the LCD. The power and data lines are directly connected from the header. 

The two buttons connect to ground. Note that the pull-up resistors (1.5K) are on the main board. Keep in mind that other LCD's can have a different pinning so check your datasheet for the correct pinning. A 47Ohm is added to the resistor to the back ground light just to make it a bit less bright. It is however not a necessary component to make the machine work. Start up: When power is switched on the microcontroller reads the clock and makes sure that the clock is running by setting bit 7 of register 0 (oscilloscope enable bit) to 0. As the datasheet suggests, this is needed because the initial power-on state of the registers is not defined. Then the first needed alarm time is read from the memory and stored into the appropriate variables. Main loop and alarm sub: After this the program goes into its main loop. Every second the microcontroller reads the clock and compares it with the data from the memory.

When there is a match the program goes to the alarm subroutine. In the alarm subroutine the program decides what drum should rotate depending on the day of the week and after that it makes it move 3 steps.  When the movement is done a alarm sounds and it only stops when there is an interrupt by one of the 2 buttons. After the alarm is stopped, the system reads the next alarm time from the memory and returns to its main loop. Setup: In setup mode, 2 buttons are used to set the entire machine. Both buttons are interrupts and each time they are pressed the value of their variable increases by 1. The variable of one of the buttons tells the system what data should be set and the other variable gives the value. This way we can setup everything with just 2 buttons. After all the variables are set, the microcontroller writes everything to the clock and/or memory and goes back to the main loop.


Price Check
as of: 
DIY Automatic Medication Dispenser