select a suitable microcontroller from the pic18


Select a suitable microcontroller from the PIC18 family, design simple interface hardware, write and test some C programs (subroutines) to operate the hardware interface and then document the hardware and software as a proposed design. Software is to be written in C using the MPLAB X IDE.

You are required to prepare

1. A report in PDF format which includes: 

a brief introduction (100 – 150 words) outlining the design requirements based on the specification. 

the hardware design (250 – 300 words) explaining the key elements of the design and how they meet the specification, plus include a single page circuit diagram of the proposed hardware. You must specify all part numbers and the values of any discrete components used (ie. resistors, capacitors, crystals). Show any calculations you make to check the scaling and resolution of analog input values. 

The software interface subroutines (250 – 300 words) briefly explaining each of the subroutines and how they meet the specification, plus include a copy of the C source code showing all the subroutines. 

A brief analysis of the testing of the software (250 – 300 words) explaining what is working and isn’t working, plus include a few screen captures of the Oshonsoft or MPLAB X simulator showing the software under-going testing. 

2. A copy of the program source file(s) as:  

a ZIP file containing all the files in an MPLAB X project (directory) you created for the assignment 

Part 1. Write a C subroutine called initports to initialise the I/O ports you have chosen in your hardware design for the button inputs, alarm and LED outputs and the seven segment display.

Part 2. Write a C subroutine called initadc to initialise the ADC ready to read any sensor input.

Part 3. Write a C function called sensor which accepts a parameter ‘s', starts a conversion on the analog channel specified by ‘s', scales that converted value to the range 0 to 1000ppm and returns the scaled sensor value as an integer. This function is to return -1 if a sensor error is detected.

Part 4. Write a C function called buttons to read the status of all buttons and return an integer whose value is 0 if no button is pressed, 1 for the Exit button, 2 for the Up button, 3 for the Down button and 4 for the Enter button. Assume only one button is active at any instant.

Part 5. Write a C subroutine called leds that accepts a parameter ‘n', where the value ‘n' (between 0 and 7) is used to control the 3 LED indicators Run, Enter and Fault. A value of n=4 will turn on the Run LED, n=2 will turn on the Enter LED, n=1 will turn on the Fault LED, n=0
will turn all LEDs off. Assume only one LED is on at any instant.

Part 6. Write a C subroutine called alarm that accepts a parameter ‘a', to control the alarm relay, where a=1 turns the relay off (triggering the alarm) and a=0 turns the relay on (no alarm)

Part 7. Write a C subroutine called display that accepts a parameter ‘c', to display the gas concentration ‘c' onto the 4 digit seven segment display. The display is not multiplexed.

Part 8. Write a main C program calls all the subroutines in some logical sequence so that their functions can be tested on a simulator. The main program should include multiple loops to test each possible sensor input, each button press, each LED output, the control of the relay output and show a range of values on the seven segment display.

Request for Solution File

Ask an Expert for Answer!!
Applications of MATLAB: select a suitable microcontroller from the pic18
Reference No:- TGS0482722

Expected delivery within 24 Hours