Assignment : 2014 - 2015
Introduction
Microcontrollers are extensively used in household and industrial appliances. Drink dispensing machines are a typical application where a microcontroller interacts with the customer and prepares a drink according to the order placed. Other additional functions such as automatic price updates and a telephone link with the supplier etc can also be implemented to enhance the operation of these machines. A simplified drink-dispensing machine can be simulated in the laboratory. The PIC16F877A provided on the E-Block development system in the Embedded Systems laboratory is interfaced to a LCD via its PORTB and to 8 pushbutton switches and LEDs via its PORTD. These switches provide a means of entering data into the PIC and the LCD can be used as output device for displaying appropriate messages.
Aims
To develop a ‘C' program to simulate a drink-dispensing machine and to evaluate its operation using the development system boards in Embedded Systems laboratory. The inputs to the drink-dispensing machine are simulated by 5 pushbutton switches on PORTD. The LCD is used to display text messages and to provide visual indication of the process.
Objectives
1- To write a structured and annotated ‘C' program using the MikroC cross compiler.
2- To provide evidence of the development of each stage of the program. This will consist of producing a report and a logbook.
3- To demonstrate a functional (fully or partially) program to your tutor at a scheduled laboratory session.
Tasks
1- Display a menu of the type of drinks available on the LCD.
2- Use switches connected to RD0 and RD1 to move up and down the menu.
3- Use the switch connected to RD2 to make a selection.
4- Insert coins by means of RD0 - RD4.
5- Use LED connected to RD7 is simulate the number of coins returned.
6- Display suitable messages to inform the customer as the drink is made.
Evidence
1- Logbook containing your laboratory exercises and a formal report.
2- Demonstration of the project.
3- A disc containing your code files saved as embed1.* and an electronic copy of your formal report.
Operation
A simplified block diagram of the proposed drink-dispensing machine is shown below.
![191_Drink-dispensing machine.png](https://secure.tutorsglobe.com/CMSImages/191_Drink-dispensing%20machine.png)
Your program should:
1- Display the following choices on the LCD
- Cold drinks
- Hot drinks
2- If the Cold drink is selected then a second menu should provide the following choices.
- Orange juice
- Fizzy drink
- Water
To show the Water option, the display has to scroll down as RD0 is pressed.
3- If the Hot drink is selected then a second menu should provide the following choices.
- Tea
- Coffee
- Chocolate
- Soup
4- In all the cases, RD0 and RD1 are used to move the cursor up/down to highlight one of the choices. Where necessary the menu must scroll up/down to reveal other options.
RD2 is used to select the highlighted choice.
5- Once a drink has been selected, a message asking the customer to insert coins should be displayed. Coins are inserted by pressing RD0-RD4 so that the total value is equal to or exceeds the price of the drink. If no money or an insufficient amount is inserted then the machine should return to its original mode (first screen) after 5 seconds. All inserted coins should be returned by turning RD7 LED on for 5 seconds.
6- Any excess money (change) should be returned by displaying what change has been given. The LED connected to RD7 should flash once for each 5 pence coin returned. (e.g. flash 4 times for 20 pence).
7- A final message of "Drink dispensed" should be displayed for 3 seconds before returning to the first screen.
The following prices should be used to test your program.
Drink
|
Price
|
Orange juice
|
50 P
|
Fizzy drink
|
50 P
|
Water
|
75 P
|
Tea
|
80 P
|
Coffee
|
90 P
|
Chocolate
|
65 P
|
Soup
|
70 P
|