Skip to content

Train ticket vending machine application designed for execution on an FPGA system. The application allows users to purchase tickets for various destinations and includes maintenance functionalities.

Notifications You must be signed in to change notification settings

franciscoengenheiro/ticket-machine-fpga

Repository files navigation

TickeMachine

Ticket Machine Init Ticket Machine Menu Ticket Machine Ticket

Table of Contents

Introduction

The goal is to implement a ticket machine that allows you to buy train tickets. The route is defined by the station of origin, the place where the ticket is purchased and by selecting the destination by typing in the station identifier or using the ⬆️⬇️ keys, and in addition to the destination station identifier, the price and type of ticket (one-way ⬆️ or two-way ⬆️⬇️) are displayed on the screen. The purchase order is given by pressing the confirmation key, and a unit of the ticket displayed on the screen. The machine does not make any change and only accepts coins of: €0.05, €0.10, €0.20, €0.50, €1.00 and €2.00.

In addition to the Sales mode, the system has another operating mode called Maintenance, which is activated by a maintenance key. This mode allows the ticket-vending machine to be tested, and the ticket and coin counters to be started and checked.

The ticket-vending machine consists of the management system (referred to as Control) and the following peripherals:

  • a 12-key keyboard;
  • a coin acceptor;
  • a two-line, 16-character Liquid Crystal Display (LCD) screen;
  • a ticket printing mechanism (Ticket Dispenser);
  • a maintenance key (M) that switches between the Sales and Maintenance modes.
Ticket Machine
Ticket Machine Architecture

The following actions can be carried out on the system in Sales mode:

  • Consultation and sale - A ticket can be consulted by typing in the identifier of the destination station or by listing it using the ⬆️⬇️ keys. The ticket purchase process begins by pressing the # key. While entering the coins, the type of ticket (one-way or return) can be changed by pressing the 0 key, which will change the price of the journey displayed on the LCD, doubling the value in the case of one-way. During the purchase, the information relating to the desired ticket is displayed on the LCD until the ticket printing mechanism confirms that the printout has been made and the ticket has been collected by the client. The ⬆️ and ⬇️ selection mode alternates with numeric selection by pressing the key *. The purchase can be canceled by pressing the # key, returning the coins entered.

The following actions can be carried out on the system in Maintenance mode:

  • Test - This menu option allows you to carry out a procedure to consult and sell a ticket, without entering any coins and without this operation being counted as a purchase;
  • Query - To view the coin and ticket counters, select the query operation in the menu and allow the coin and ticket counters to be listed using the ⬆️⬇️ keys;
  • Start - This menu option starts the coin and ticket counters at zero, initiating a new counting cycle;
  • Shutdown - The system shuts down when this menu option is selected, i.e. the management software stops storing the data structures persistently in text files. The information on the number of coins and the number of tickets sold is stored in the CoinDeposit.txt and Stations.txt. respectively. These files are read and loaded at the start of the program and rewritten at the end of the program.

Important

Entering information via the keyboard has the following criteria:

  • if no key is pressed within five seconds, the command in progress is aborted;
  • when the data to be entered is made up of more than one digit, the last digit is taken into account
  • insertion takes place from the digit with the greatest weight to the one with the least weight.

Note

For more information about the project, consult the handout which is available here in portuguese.

Application Modules

Modules Overview
Modules Overview

Software

Divided into several key modules:

And other auxiliary modules and functions:

Entry point: Main

Hardware

To develop the hardware modules, the VHDL language was used, which is a hardware description language used in electronic design automation to describe digital and mixed-signal systems such as field-programmable gate arrays (fpga's) and integrated circuits. Since the IDE chosen was Quartus Prime, several templates were created to better visualize the modules different signals and their interconnections when running module testbenches.

Integrated Output System

Implementation | TestBench

This module implements the interface with the Ticket Dispensing and LCD modules, serially receiving the information sent by the control module and then delivering it to the recipient, as seen in the diagram below.

Integrated Output System
Integrated Output System

Divided into several key modules:

Note

This component report is available here in portuguese.

Keyboard Reader

Responsible for decoding the 12-key matrix keyboard and determining which key was pressed, as well as providing its code to the Control module. If the latter is not available to receive it immediately, the key code is stored up to a limit of two codes.

For physical reasons, and in order to minimize the number of interconnection signals, communication between the Control module and the Keyboard Reader module is carried out using a synchronous serial protocol.

Implementation | TestBench

Keyboard Reader
Keyboard Reader

Divided into several key modules:

Note

This component report is available here in portuguese.

LCD

Implementation

LCD Display
LCD Display mounted on another board

Ticket Dispenser

Implementation | TestBench

Fpga Assignments

The fpga used was the Terasic De10 Lite. The assignment configuration can be found in this file.

FPGA Assignments
FPGA Switch and Leds Assignments

Simulator

The simulator was used to primarily test the software and hardware modules without the need for physical hardware and to verify the correct operation of software modules when compared with another hardware implementation or vice versa.

It contains the following files:

  • USB_PORT.properties - UsbPort settings file, allows you to define how it is used;
  • TicketMachine.simul - contains the definition of the modules and interconnections for Kotlin. The modules needed to implement the Ticket Machine have been defined, with only the UsbPort interface still to be adapted. Only the UsbPort interface needs to be adapted to the software already developed, defining the UsbPort.O# and UsbPort.I# connections;
  • Simul.properties - contains the definitions of the Kotlin windows;
  • TicketMachine.jar - jar file with the implementations of the hardware modules for simulation, included as a project library.

Final Report

The final report can be found here in portuguese.


Instituto Superior de Engenharia de Lisboa
BSc in Computer Science and Engineering
Computer and Informatics Laboratory
Summer Semester of 2021/2022

About

Train ticket vending machine application designed for execution on an FPGA system. The application allows users to purchase tickets for various destinations and includes maintenance functionalities.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published