Professional Documents
Culture Documents
Neural Network Perception Model On Matlab
Neural Network Perception Model On Matlab
Jean Mouawad
Elie Yaacoub
Faculty of Engineering
University of Balamand
April 2019
______________________________________________________________________________
Copyright 2019
All Right Reserved, Jean Mouawad, Elie Yaacoub
Introduction:
We were asked to write a program to implement the programmable timer with only 3 keyboard
buttons: “u” and” d” to set the time as up and down and “s" to start and initiate the countdown process.
• First it memorizes the set time in EEPROM.
• Then it turns on the device and displays a down counter running at a rate of 1 Hz.
• When the time elapses, the device is turned off and the program starts all over again. A flashing
display and intermittent beeps of a buzzer indicate timeout.
This system may be used in many applications such as timer applications in industrial
automation like machines. Also, it can be used in universities and classes as end of time alarm. It
can be used in games such as Basketball games to set the timers. It can be used in many other
applications.
For This Project I liked to make it as a Time Clock Violation in a Basketball Game. For this
purpose the timer is set to 24 seconds in each attack.
The Project consists of a timer that is set manually using the computer keyboard and connecting
the pic18f45k22 microchip to the computer using RS-232 communication protocol. The
keyboard layout for the counter is provide in Fig 2. When the timer is set and when start is
pressed the timer value is saved to the EEPROM. The timer counts down until it reaches 0
seconds. A buzzer and LEDS are set on for 5 secs. The timer value can vary between 0 seconds
and 255 seconds.
Whenever the timer is interrupted by any other external cause or resetting the timer it is saved in
the EEPROM. So, after reset or ending the timer will be as last value set.
Special Case:
As mentioned in the introduction I assumed that this project Is a 24 seconds time clock violation
in a basketball game. The timer must be set manually for 24 seconds each time. Whenever a
team violates the rule and the 24 seconds ends the buzzer is set on for 5 seconds and the led are
on for 5 seconds also. Whenever the team scores a basket in less than 24 seconds the controller
must reset the timer and press start again.
Code:
#include <p18cxxx.h>
#include <LCD4PICDEM2.h>
#include <Hyperterm.h>
#include <delays.h>
#include <EEPROM.h>
void Setup(void);
void GetTime(void);
void TurnOn(void);
void Buzzer(unsigned char);
// Convert 8-bit N to ASCII characters and store in array a (starting with MSD)
N = N / 10;
char Digits[3];
void main(void) {
Setup();
GetTime();
void Setup(void)
{
OSCCON = 0b01010000;
InitUART ();
TRISBbits.RB0 = ANSELBbits.ANSB0 = 0;
PORTBbits.RB0 = 0;
TRISBbits.RB1 = ANSELBbits.ANSB1 = 0;
PORTBbits.RB1 = 0;
TRISBbits.RB2 = ANSELBbits.ANSB2 = 0;
PORTBbits.RB2 = 0;
TRISBbits.RB3 = ANSELBbits.ANSB3 = 0;
PORTBbits.RB3 = 0;
TRISCbits.RC2 = ANSELCbits.ANSC2 = 0;
PR2 = 255;
T2CON = 0b00000110;
CCP1CON = 0x0C;
CCPR1L = 0;
T0CON = 0b01001111;
TMR0L = 256 - 256;
INTCONbits.TMR0IE = 1;
PIE1bits.RCIE = 1;
INTCONbits.PEIE = 1;
INTCONbits.GIE = 1;
void GetTime(void)
while (1) {
if (start) {
start = false;
up = false;
void TurnOn(void)
Device1= 0;
Device2 =0;
Device3 =0;
do {
if (Seconds == 0)
break;
Seconds--;
start = false;
T0CONbits.TMR0ON = 1;
Device = 1;
Device1= 1;
Device2 =1;
Device3 =1;
Buzzer (10);
Delay10KTCYx (100);
T0CONbits.TMR0ON = 0;
Reset();
CCPR1L = i;
if (PIR1bits.RCIF) {
receive = RCREG;
else if (INTCONbits.TMR0IF) {
INTCONbits.TMR0IF = 0;
E = 0;