Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

/ * * * RFID.c * COMP 5 5 1 LAB 1 1 RFID Module * PIC 1 8 F 4 5 8 Microchip MPLAB

/*** RFID.c
* COMP 551 LAB 11 RFID Module
* PIC18F458 Microchip MPLAB C18
* Lakshya Kapoor (10323795) & Sharath Varma Nallapuraju (10317230)
* December 8,2023
* This program is about running the RFID Module
* This program is strictly in my own work. Any material
* beyond course learning materials that is taken from
* the Web or other sources is properly cited, giving
* credit to the original author(s).
***/
#include
#include "millis_551.h"
#pragma config OSC = HS, OSCS = OFF
#pragma config PWRT = OFF, BOR = ON, BORV =45
#pragma config WDT = OFF
#pragma config DEBUG = OFF, LVP = OFF, STVR = OFF
// Boolean values
#define FALSE (0)
#define TRUE (!FALSE)
// LCD CMD and DATA pins
#define CMD_PIN PORTBbits.RB0
#define RW_PIN PORTBbits.RB1
#define EN_PIN PORTBbits.RB2
#define CMD_PORT PORTB
#define CMD_PORT_TRIS TRISB
#define CMD_PORT_TRIS_VALUE ((unsigned char)~0x07)
// Data
#define DATA_PORT PORTD
#define DATA_PORT_TRIS TRISD
// Important constants
#define NCHARS 12// number of digits in RFID code
#define BAUD_DIVISOR 129// value for baud rate generator (BRGH =1)
const unsigned char data[]="";
enum State
{
WAIT,
RECEIVING,
DISPLAY
};
enum State state = WAIT;
unsigned int deadline =0;
// Function prototypes
void lcd_ini(void); // initialize LCD module
void delay_ms(unsigned int milliseconds); // YOU FILL IN OTHER LCD FUNCTIONS FROM LAB 10
const unsigned char BANNER[]= "LAKSHYA 3795"; // Define message array
unsigned char card_id[NCHARS]; // Define "card_ID" array
unsigned int char_counter =0;
void delay_ms(unsigned int milliseconds)
{
unsigned int deadline = millis()+ milliseconds;
while(millis()< deadline) ;
}
void lcdcmd(unsigned char command)
{
CMD_PIN =0;
delay_ms(2);
RW_PIN =0;
delay_ms(2);
EN_PIN =1;
delay_ms(2);
PORTD = command;
delay_ms(2);
EN_PIN =0;
delay_ms(2);
}
void lcddata(unsigned char data)
{
CMD_PIN =1;
delay_ms(2);
RW_PIN =0;
delay_ms(2);
EN_PIN =1;
delay_ms(2);
PORTD = data;
delay_ms(2);
EN_PIN =0;
delay_ms(2);
}
void printer(const char * const text, unsigned char startPos)
{
int i;
lcdcmd(startPos);
delay_ms(2);
for (i =0; text[i]; i++)
{
lcddata(text[i]);
delay_ms(2);
}
} You will combine part of lab 11 and part of lab 10 for this bonus assignment. It will require use
of RFID and a state machine to receive and display the card ID on the second line as in lab 10,
but the OK or BAD display will be delayed unGl aHer a Gmer counts down on the 1st line
(similar to Lab 10).
To accomplish this you will have to modify the state machine as follows:
In the DISPLAY state, you should only display the ID (DO NOT PRINT OK or BAD), and set a 2
second Gmer deadline.
If another character is received within 2 seconds, go back to RECEIVING state as in Lab 11.
If the deadline elapses, instead of moving to WAIT state, move to a new COUNTDOWN state.
In the COUNTDOWN state, display a count down of 5 to 0((1)/(2) second delay between counts) on
the top line in the first two character locaGons. Leave one space, then display the same number
in binary, one bit per character space as 1 or 0.
As you are displaying the countdown on the top line, on the bo\om line, draw a progress bar
with a single character. At 5, the line is blank, at 0 the line is filled (all 16 characters). In
between, the line is proporGonal to the number. Hint: try with the filled rectangle character 0xff
Once the countdown has completed, display OK or BAD as appropriate on the first line, then
move to the WAIT state. Implement this question in the above given code provided by me. Please provide code as asked in question properly.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Heikki Topi, Jeffrey A Hoffer, Ramesh Venkataraman

13th Edition

0134773659, 978-0134773650

More Books

Students also viewed these Databases questions