Write a c function called resistance which reads adc channel

Assignment Help C/C++ Programming
Reference no: EM13996955

Assignment Requirements

This assessment requires students to meet the requirements the specification below. 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 either the MikroC PRO for PIC or MPLABX IDE. You must create a project for your program which may include one or more C source files. The testing is to be completed using either: the Oshonsoft PIC18 simulator, the MikroC PRO for PIC or MPLABX built-in simulators.

There is NO requirement to assemble any hardware, or layout a PCB for this assignment. The circuit design for the hardware may be drawn using electronics CAD software, OR hand-drawn and scanned, for inclusion in the documentation. The interface to the MCU can be successfully configured and simulated on the Oshonsoft PIC18 simulator, or the MikroC or MPLABX simulators can be used to simulate port/register level operation. A series of screen captures of the software under-going testing must to be included in the documentation.

Each student is required to submit:

1. A report in Microsoft WORD format (with tracked changes enabled) which includes:

- a brief introduction (150 - 200 words) outlining the design requirements based on the specification.

- the hardware design (300 - 400 words) briefly explaining the circuit design and how it meets the specification. Include a figure showing the proposed operator interface panel layout. Show any calculations you make to check the scaling and resolution of analog input values, resistor values, crystal frequencies etc.

- a single page circuit diagram of the proposed hardware. This may be A4 or A3 in size. This diagram may be provided in a separate file (possibly an image file) if it is more convenient.

You must specify the electronic components (eg. IC's) and the values of any discrete components used (ie. resistors, capacitors, crystals). Manufacturer part numbers are not required.

- the software interface subroutines (500 - 600 words) briefly explaining the subroutines and how they operate and meet the requirements.

- a brief analysis of the testing of the software (300 - 400 words) explaining what is working and isn't working, plus include a series of screen captures of the Oshonsoft, MikroC or MPLABX simulator showing the software under-going testing.

- copy of the C source code showing all the subroutines. (as an appendix to the report) The document should be formatted as a report and must include:

- a title page showing the student name and number

- numbered sections with appropriate sub-headings

- grammatically correct English

- clearly drawn diagrams including figure numbers and captions

- the assignment name and page number in the header of the document 

- the student's name and student number in the footer of the document

2. A copy of the working directory including the program source file(s) as a ZIP file. Include all the files in the directory you use for the assignment.

The Specification

Outline of the task

You have been requested by your Senior Engineer to design a controller for a new client, for their manufacturing line to assemble and test armatures for small DC electric motors. You are to prepare a hardware design (including a panel layout), write hardware interface routines, test those routines (simulate them) and prepare a report detailing your proposed solution for the Assembly Line Controller (ALC).

The sequence of steps involved in winding the armature include: releasing an armature ‘core' onto the conveyor, moving the core along the conveyor to the winding mechanism, loading the core in the winding mechanism, winding the required number of turns of wire onto the core, unloading the core from the winding mechanism, moving the now wound armature along the conveyor to the electrical test point, measuring the electrical resistance of the winding (to check for faulty construction) which then dictates the acceptance or rejection of that armature prior to the next stage of assembly. Infrared sensor beams are used to detect the position/presence of the core placed on the conveyor, at the winder and at the test point.

The client has specified a PIC18-based controller is required, as they are familiar with that family of MCUs. The controller is to accept input from a human operator and be able to control the operation of the equipment which forms the assembly line. The operator interface is expected to include a set of buttons and indicators to select and monitor various modes of operation; a keypad for entering numeric values and a numeric display. The interface to the assembly line equipment is described in Hardware Requirements.

Stage 1 of the project (this assignment) requires you to (a) design the hardware for a PIC18 microcontroller and the input/output circuitry required to interface the buttons, indicators, keypad, display and any other devices specified in the Hardware Requirements and (b) write and test a set of input/output routines (in C) to operate all interfaces except the keypad and display according to Software Requirements.

[ Stage 2 (assignment 2) will require you to write a state-based control program to operate the manufacturing line. Some additional hardware and/or interface routines may also be required. ]

Hardware Requirements

Microprocessor support circuitry

- The circuit diagram for the MLC must include the minimum components necessary to operate a PIC18 processor at a clock speed of 20MHz.

- A push button reset circuit is required for the microcontroller.

- Show the power supply connectionsrequired to power the PIC processor using a 5Volt power supply.

(Note that the 5V power supply itself is not part of this design problem.)

Operator interface panel

- The ALC operator interface must continually indicate the status of the assembly line on a set of suitably coloured LEDs - indicating status of STOPPED, DATA ENTRY, RUNNING, WINDING, PAUSED and FAULT.

- The ALC operator interface must provide a set of active-low momentary push button switch inputs

- which enable the operator to control the line. Buttons are to be labelled STOP/GO, PAUSE and ENTER. No debounce hardware is required on button inputs.

- The ALC operator interface must provide a numeric keypad and a numeric display to facilitate data entry during the DATA ENTRY mode. (Note NO routines are required for these devices in this assignment.)

Assembly Line Interface

- The Assembly Line Controller (ALC) must be able to switch the conveyor on and off. The conveyor is driven by a 240 Volt 50 Hz AC motor requiring a continuous 1 Amp supply. The conveyor has single direction operation. The MCU must be electrically isolated from the 240V supply.

- Three (3) infrared beam sensors are used to detect the presence of a core at three positions along the assembly line: where the core placed on the conveyor, at the winder and at the test point. Each provides an active high signal when an object interrupts its beam. The ALC must be able to detect the state of each sensor.

- The ALC must be able to trigger the release of a ‘blank' core onto the conveyor. A single active high pulse (5V) of 400mS in duration triggers the release mechanism.

- The ALC must be able to load/unload the winder mechanism. A single digital input to the winder mechanism is used to load/unload the core. A logic 1 loads the winder and a logic 0 unloads the winder. This signal must remain high (1) for the duration of the winding process.

- The ALC must be able to provide the winder with the number of turns needed for armature winding. The winder accepts a 6 bit number on its parallel inputs labelled D0 to D5. The number of windings to be wound onto the core is equal to the numeric values on the input times 100.

That is - an input value of 15 specifies the number of turns to wind is 1500.

A single active low pulse of 0.2s in duration applied to its START input is required to start the winding machine.

The winder operates at an approximate speed of 50 turns per second, however as more wire is wound onto a core each wind takes longer. Hence time cannot be used to determine when the winder is finished. A single bit output labelled BUSY is output from the winder, indicating the status of the winding task. (0 while busy, 1 when finished)

- The electrical resistance testing unit provides an analog signal between 0 and 5Volts. This voltage is actually proportional to the current flowing in the armature during the test, call it C. The resistance of the winding (in milli-ohms) can be determined using the equation R = 1000 / (5*C), where the units of C is volts. The current C must be measured to a 10 bit resolution to be accurate enough.

If the current C = 0 then winding is open circuit. If the resistance R is less than 60 milli-ohms then there must be short in the winding. In either of these cases the armature is rejected as faulty. The resistance testing unit is automatically triggered by the sensor used to detect the armature at that position on the conveyor. No control from the ALC is required.

- The last step in the armature winding and testing process is rejecting any faulty units to the re-work bin. This is achieved by the ALC sending a logic 1 signal to the input of the deflector arm while the conveyor is moving to bring the next armature to the test position. A logic 0 allows the unit to pass.

- All signals to the user interface panel and the assembly line equipment must connect to the ALC circuit board via a connector. You are required to logically group signals using one connector for the user interface; a second connector the winder signals; a third connector for the conveyor motor control and infrared sensors and a separate connector for the analog signal. Each connector must provide a 0 Volt (GND) reference signal. (Note that the type or model of connector is not significant to the assignment; just show a connector as a rectangle with a single row of numbered pins.)

Software Requirements

The following routines must be written. (Note the keypad and display routines are NOT required for this assignment)

(Note - with the exception of the timing delay routines (Eg. delay_ms() ) you are NOT allowed to use any library functions provided with MPLABX XC8 or MikroC. Your routines must write/read directly to/from the special function registers controlling the ports and the ADC.)

Part 1. Write a C subroutine called init_ports to initialise all the I/O ports you have chosen for your hardware design, to prepare ALL inputs and outputs ready for operation. Excludes keypad and display.

Part 2. Write a C subroutine called init_adc to initialise the ADC ready to read the test current C (as in part 3).

Part 3. Write a C function called resistance which reads the ADC channel you have chosen (to 10 bit resolution) calculates and returns the resistance in milli-ohms as signed integer value. If the current is zero this function is to return the value -1.

Part 4. Write a C function called button to read the status of all buttons and returns a single byte (short int) whose value is 0 if no button is pressed, 1 for the STOP/GO button, 2 for the PAUSE button, or 3 for the ENTER button. Assume only one button is active at any instant.

Part 5. Write a C function called sensor to read the status of all sensors and return a single byte (short int) whose value is 0 if no sensor is active, 1 if the ‘core placed' sensor is active, 2 if the ‘winder' sensor is active, or 3 if the ‘test point' sensor is active. Assume only one sensor is active at any instant.

Part 6. Write a C subroutine called led that accepts parameters called n and b, where n identifies the LED indicator to control and b is the new state (0 or 1) to control the chosen LED. Assume any combination of LEDs can be on or off at any time. You will have to match n to the number of LED indicators you have included in your design.

Part 7. Write a C subroutine called blank that triggers a 400mS pulse to release a ‘blank' core onto the conveyor.

Part 8. Write a C subroutine called conveyor that accepts a parameter called m, where m = 0 turns off the conveyor and m = 1 turns on the conveyor.

Part 9. Write a C subroutine called load that accepts a parameter called go, where go = 1 loads the winder and go = 0 unloads the winder.

Part 10. Write a C subroutine called wind that accepts a parameter called n (the full number of windings required - Eg. 1500), provides the appropriate scaled value to the winders 6 bit input, starts the winder with the required pulse and waits for the winder to finish.

Part 11.Write a C subroutine called reject that accepts a parameter called f, where f = 1 triggers the deflector arm to direct the faulty part to the rework bin, f = 0 allows the part to pass.

Part 12. Write a main C program which initialises all ports and the ADC, calls all the subroutines and functions in some logical sequence so that their functions can be tested on a simulator. The main program should include an endless loop containing multiple loops and tests to verify each possible sensor input, button press, LED output, and test the controls for the motor, winder, core release and read the current value from the resistance tester.

Reference no: EM13996955

Questions Cloud

Determine the force constant k of the spring : A 5.50 x 105 kg subway train is brought to a stop from a speed of 0.600 m/s in 0.900 m by a large spring bumper at the end of its track. What is the force constant k of the spring?
Marketing of industrial psychology : What differences existed between the two that resulted in their having different experiences - What was it about the zeitgeist of the times that resulted in these outcomes?
What is net power received at the town : If the power is now sent to a town through a transmission line of net resistance 4 Ohms, what is net power received at the town?
Assume world consists of only two countries : Assume a world consists of only two countries: Latvia and Bulgaria, which can produce only two goods: lemons and beef. Latvia can produce 1000 tons of lemons or 500 tons of beef or any linear combination of lemons and beef that satisfies lemons+2×bee..
Write a c function called resistance which reads adc channel : Write a C function called sensor to read the status of all sensors and return a single byte (short int) whose value is 0 if no sensor is active, 1 if the ‘core placed' sensor is active, 2 if the ‘winder' sensor is active, or 3 if the ‘test point' ..
Hotel management system database project : Hotel Management System Database Project - A hotel is a hive of numerous operations such as front office, booking and reservation, banquet, finance, HR, inventory, material management, quality management, security, energy management, housekeeping,..
What is the volume flow rate through the hole : What is the volume flow rate through the hole in L/min. What is the rate in mm/min at which the water level in the tank will drop if the water is not replenished?
What market form has a small number of firms : What market form has a small number of firms but a big market share? what form of market will do well only under inelastic demands.
Create fiscal redistributive initiatives : Most people perceive international public administration to be a set of state structures, institutions, and processes. Opponents of globalization argue that it weakens states, making it difficult for them to sustain social welfare and environmental p..

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Programming questions

Write a program (including timing measurements) for the following scenario. Generate 20 million random numbers, one at a time, and insert them into an array that doubles every time it runs out of space (starting size of 2), into an array that can..

  Algorithm and create a flowchart

Write an algorithm and create a flowchart which simulate the testing for cell phone PIN. If the user entered the correct pin code, display "Welcome to DLM Telecom".

  Programming with control structures

Develop a Python program which will calculate the sum of an integer series, as described below. The program wil repeatedly prompt he user to enter a command (a character string).

  To use a sentinel loop so once the value of -99 i

modify this program to use a sentinal loop so once the value of -99 is entered after getting the pay and hours the program should end.

  Write a pseudocode function in terms of adt appointment

Write speci?cations for a method within Date that advances any given date by one day. Include a statement of purpose, the preconditions and postconditions, a description of the arguments, and a description of any return value.

  Dynamicword.h contains a class definition

Consider the following main function.  Assume that DynamicWord.h contains a class definition for a class called DynamicWord that holds a pointer to a dynamic array as a private data member, but the assignment operator (=) has not been overloaded for ..

  Create a global array of structures

Create a global array of structures with the following data. Each structure should store the data (Employee Table - Name, age, salary information) . Array size must be at least 10

  One the same set of axes

One the same set of axes, plot the monopolist's demand and marginal revenue curves. Indicate where theprice elasticity of demand is elastic, inelastic and unit elastic.

  Create a bitoutputstream

Implement a class named BitOutputStream, as shown in Figure for writing bits to an output stream. The writeBit(charbit) method stores the bit in a byte variable. When you create a BitOutputStream, the byte is empty

  Prepare a new int[] variable and inititialize it

Prepare a new int[] variable and inititialize it to be a new int array with the given size to create random values use the random class import javautil.random inside the method create a new instance with: Random rand = new Random();

  Statement that best describes bayesian reasoning

what is the equation of that separates the two classes - Select the statement that best describes BAYESIAN reasoning

  Computes a students grade for an assignment

Write a C++ program that computes a student's grade for an assignment as a percentage given the student's score and total points.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd