Introduction: Drugs Dispenser
As part of our 2nd Master in Industrial Engineering studies in electromechanics, we have to choose a subject of project for the course of applied electronics and electrotechnics.
To do this, our team have decided to automate the action of filling cups with medicines in retirement home. Indeed, this prototype aims to simplify the work of the nurses in charge of this type of operation. The prototype in question must allow, by a simple interface, the filling of the cups according to the patient for whom a recipe is defined. The use of an arduino or a raspberry is essential and we have decided to use both. So, the raspberry will support the interface and the arduino will act as API for the management of the motors.
How it works
Step 1: The Material
The price to build our model is about 103,65 €. We tried to use as much as possible components coming from the recycling.
Here is a non-exhaustive list with links corresponding to a website to order each articles:
- Arduino MEGA (35,98€) : link
- Power supply for the arduino (1,88 € recycling) : link
- Raspberry Pi (40,41€ recycling) : link
- Power supply of 5V for the raspberry (7€ recycling) : link
- USB cable to connect the Arduino to the Raspberry (6,99€ recycling) : link
- Jumpercables for arduino (1,39€ recycling) : link
- 3 Stepper motors 5V (3 * 1,76€) : link
- A keyboard and a mouse (recycling)
- A computer screen (recycling)
- HDMI/VGA adaptor (7,99€ recycling) : link
- 2 MDF boards of 4 mm (122 x 61 cm) (9,78€) : link
- 1 MDF board of 12 mm (122x61 cm) (9,5€) : link
- Wood for the frame 2 x 2,4 m (19x32mm) (2 x 1,35€) : link
- Wood screws + wood staples (recycling)
- A drill
- A hole saw
- Wood stapler
Step 2: Cabling the Stepper Motors With the Arduino Mega
The 3 stepper motors used are 28YBJ-48 and powered with 5 volts. In order to make them work with an Arduino, a driver board ZC-A0591 (ULN2003A on the sketch below) is required. This is delivered and partially pre-wired with its stepper motor.
To power the stepper motor, you will need to connect the 5 V of the driver board to the 0 V of the Arduino board; 12 V of the driver board to 5 V of the Arduino board.
/!\ You have to power the Arduino board with an external alimentation. Indeed, the serial port cannot supply the current drained by the stepper motors. If you do not follow this step, your Arduino might not support the current flow.
Four pins must be connected to the driver motor (in1,in2,in3,in4). About the arduino software, the pins will be entered in a specific sequence in the function Stepper according to the cabling. So, with our cabling for the 3 stepper motors, it is going to be:
“nombreDePas” are the number of steps of the 28YBJ-48 stepper motor.
It is stated as an integer. The assigned value to that variable is 48*64. 64 steps per revolution (Step angle 5.625°) and gear ratio reduction is 1/48. It takes 3072 steps per output shaft revolution.
Step 3: Cabling Arduino-Raspberry-Auxiliaries
The serial cable provided with the Arduino mega must be connected to serial port of the raspberry pi 3.
The mouse and the keyboard must be connected the same way to the raspberry. If you have a HDMI input on your screen, you can connect it straight with a HDMI cable to the HDMI port of the raspberry. Otherwise, you will need a HDMI adaptor if you own a screen with a simple VGA input. To power the raspberry, you can use a transformer 230V AC/5V DC of at least 2 A. To power the Arduino, a tension adaptor is needed. The ideal tension range is between 7 and 12 volts. You can’t adjust the current of the adapter. Personally, we used two different ones (One adapter broke down halfway project…): 500 and 1000 mA. It went perfectly well.
Step 4: Coding
In our project, the code is not really hard to understand. Nevertheless, if you want to understand it, you will have to learn how to use the tkinter library and the serial library for the raspberry part. In what concerns the arduino, the library you should know are stepper.h and string.h and for an easier comprehension of the program it is advised to be acquainted with serial communication between raspberry and arduino.
First, you might have to install the serial library. To do that, use the command "sudo apt-get install Serial" in a terminal. Also, be sur to be using python 2 otherwise you might encounter some problems with the tkinter library because some tkinter lines might be different in python 3.
The software in the raspberry is coded in python. It contains the main informations about the graphic interface the nurse would interract with. If you want to modify the interface, you can change the information in the "INIT" method of the class medManager. If you want to change the password interface, you can do the same with the mdpWindow class. you can find interesting information about interface design with tkinter on this website : https://docs.python.org/2/library/tkinter.html
The python software use a file to store the information about the patient. So be sure to download the file Patients.txt.
The other function in the medManager class are used to add, delete, display,... patients. The function send is really important. This function sends the number of steps the stepper motors have to do according with the patients and the time of the day. That's when we use the serial communication between the arduino and raspberry.
The arduino receive different informations about the number of steps the stepper motors have to do and then drive the motors according to this information. Once again, to understand this code, it's better if you know how the serial communication works. You can find interesting information about serial communication on this website : http://forum.arduino.cc/index.php?topic=396450 .
So here are the files you have to download :
Step 5: Enjoy
Now that your pills dispatching system is done, you can try out, here is a video explaining how the drugs dispenser work.
We found this
project of electronics and electrotechnics very interesting and rewarding. It allowed us to carry out a team project as we will have to do in our future professional life.
At the end of this project, we succeeded in implementing the initial idea we had set ourselves to build a machine to distribute pills automatically in order to facilitate the work of the nursing staff of a retirement home.
Through these different objectives and throughout the duration of the project, the different members of the group were able to highlight their skills. It went from programming to construction and from management to deadlines.
This project allowed us to see and realize that despite a common educational background, each of us had different skills and fields of different predilections. Teamwork allow us to complete the skills of each other by a common reflection of the group.
During the implementation of the project, we observed that different improvements to our project could be made. We made a non-exhaustive list:
- Insert a photoresistance to detect the presence of the cup
- Program an application for smartphones in order to modify the treatment of a patient
- Build a database containing a large amount of information about patients, their treatment and medicines.
We have a be nice policy.
Please be positive and constructive.