代写EENG6670: Microcomputer Applications, Architectures and Performance代写C/C++程序

EENG6670 Embedded Computer Systems

Engine Control Lab – Lab Group 13

EENG6670: Microcomputer Applications, Architectures and Performance (MAAP)

Introduction

This experiment supports some of the material in the MAAP lectures. You will look at a real-time system problem, generating the spark in an internal combustion engine.

Safety

This  experiment  has  been  reviewed  under  the  Control  of Substances  Hazardous  to  Health  (COSHH) regulations with a conclusion that there are no hazards covered by this act. The equipment has a revolving disc which may cause minor abrasions if touched while in operation. As with any electrically operated equipment, you should take care not to short out power supplies so metallic objects such as pens and watches should be kept clear.

Assessment

This experiment will be assessed by means of a formal report (as a guideline of about 10-12 sides, including diagrams and code listings) (note: do not list the whole code in your report as part of your answer to each task. Instead, only sections of code that relate to the task and where code modifications have been made). As a guide, you should spend about 6 hours on this and you can return to the lab to finish off or check results if you wish. You should each separately prepare your formal report. The emphasis should be on what you did and discovered with a discussion of these discoveries rather than a restatement of this script. For this reason, you should keep detailed records of your activities in an open Word document or note book including screenshots of the oscilloscope trace and the MBED LCD display which you must include  in your final  report with your  answer to each  part/question.  Make  sure you caption each screenshot properly and refer to it when you are providing your answer to each part/question.

Background theory for this lab is provided through the MAAP lecture 10 slideset/recording on Moodle.     Throughout this script. you will find questions/topics which I would like you to answer and discuss in the report.

The Experiment

Rather than writing an exhaustive script. for this experiment, I have outlined the aims and method of each section. Generally, text in italics is used for aspects you will observe or carry out in the lab. Text in bold is used for questions you have to answer. Text in red is used for additional hints on each topic.

Note: Avoid the use floating point variables and math in any of the calculations you implement within the code – it’s too slow.

Please feel free to ask questions of the demonstrator and  lecturer during or after the demonstrated sessions (please include both in your email):

Demonstrators: George Frangulea ([email protected]), Hazim Abdulsada ([email protected])

Lecturer: Philippos Assimakopoulos ([email protected])

Preamble

Before starting the lab, go through the background theory (MAAP lecture 10 slideset and recording on Moodle). If you haven’t used the MBED for some time, remember to check your MBED login prior to the lab and make sure it works (you will need it for the lab).

Note: Make sure that you stay within your allocated lab group and work on the correct lab script. version as the lab script changes every week. Submissions that are not for the correct lab group script will receive zero marks.

PART 1 [1 Mark]

In the lab we do not have a real petrol engine. Instead, we use a circuit board with a rotating disc/ flywheel (rotating counter-clockwise) to simulate some aspects of a petrol engine. The rotating disc can be made to spin at different rotational speeds (rpm). It has a TDC sensor and small hole in the disc to view LEDs. It also has some LEDs in the board that light up when the disc is at TDC and when you get a spark (the demonstrator will answer any questions you may have regarding the setup).

Log on to the MBED Keil Studio Cloud and create a new design called “measure”. Copy and paste the file measure.cpp from Moodle into your new design. The program uses the LCD12832 display to print out results, so you will need to import the LCD12832_lcd library into your design.

Connect the black flying lead from the flywheel to the GNDpin of the MBED, and the TDC output (red lead) to pin 30. Compile, download and run the project ‘measure’. Observe the program’s output on the LCD Display and/or the PC using Tera Term (a terminal emulator) (example LCD output is shown in Fig.1).

Fig. 1. Example of information displayed on the LCD display

The measure.cpp program uses the MBED’s CAP2.0 capture pin (pin 30) and Timer 2 to measure the rotational period of the disc. Go through the code (use the course lecture slides as reference if needed) and ensure that you understand how the program works.

Use the oscilloscope to look at the TDC pulse. It would look similar to Fig. 2 (note: if you are unfamiliar with the operation of an oscilloscope, ask the demonstrator).

Fig. 2. Oscilloscope view of TDC pulses. Note that measurement markers have been placed such that the period (Δt) between two consecutive TDC pulses can be measured.

Using the scope, determine and explain the relationship between the rotational period displayed by the program (in the LCD) and the timings measured using the oscilloscope i.e, work out and state what a change of ‘1’ in the displayed LCD value corresponds to in actual time. Explain and note this in your report. Relate your answer to how the code in measure.cpp is implemented.

[Hint: Check the code, especially for the Timer2_init() function, try to work out the period of Timer- Counter 2 which is based on the pre-scaler value and the main frequency of the MBED core chip (the LPC1768 microcontroller). Once you have done this, you should be able to explain the relationship between the period displayed in LCD and the measured Δt from oscilloscope.]

Useful notes (based on the Lecture 10 slideset):

.    The disc represents the crankshaft of the engine.

.     Pistons are normally attached to the crankshaft and they slide up and down within cylinders.

.     When the piston is at the top of its travel within the cylinder, it is said to be at Top Dead Centre

(TDC) . It is from here that the angles are measured i.e. it is 0° .

.    The TDC sensor gives a positive pulse of about 4 milliseconds when the piston is at TDC. The rising edge (seen for example in Fig.2) represents TDC.

PART 2 [2 Marks]

Add a digital output called something like spark’ on pin 12 to the measure.cpp code, to generate a "spark" at TDC with a duration of 0.5 ms.

Attach the white lead (spark wire) to your spark output and use the scope to observe the TDC sensor output and the spark. Sketch/Capture the result.

Useful notes (based on the Lecture 10 slideset):

.     In this context a "spark" is a short positive pulse of 0.5 millisecond duration. It should be generated on the specified MBED pin which needs to be connected to the engine simulator. There, the spark pulse causes the LEDs to flash briefly.

.    There is a small hole in the disc to view the LEDs. Since the LEDs are at a point just before TDC, in this instance you will not see them by looking from above. [The disc rotates anti clockwise]. They will be visible from the side.

.    The simplest way to generate the spark is to set the spark output high at TDC, then wait for 0.5 millisecond before setting it low again. Note – You will need to configure the Spark output pin as a DigitalOut.

[Hint: The rising edge of spark signal should be generated at the rising edge of TDC. To implement this, figure out where the TDC signal is generated in measure.cpp file. Once you figure out this part, you should  be  able to find out where to make the addition to the code to generate the spark signal. Moreover, when you use the built-in  wait(), wait_ms() or wait_us() functions from MBED library, for some reason, sometimes the wait_ms() function does not work properly. To tackle this issue, try to use the wait() function instead, but remember that the parameter passed into the wait() function is in unit of seconds. Lastly, DO NOT use any aforementioned wait() function inside the Timer2_isr() - as we discussed in the lectures it is not good practice to add delays in an ISR.]

Part 3 [5 Marks]

Create a new design called ‘timing’, copy and paste the file  timing.cpp from Moodle into your new design. Compile and run  timing.cpp. It produces a spark pulse, on pin 10, at 180 degrees before TDC.

Modify the programme so that it produces the spark at 15 degrees before TDC. Useful notes (based on the Lecture 10 slideset):

.    A spark has to occur some time  before TDC to allow the  petrol/air mixture to be burning when the  piston  reaches  TDC. This  is  known  as  the Advance Angle  (AA)  since the  spark  occurs  "in advance of" TDC.

.    You  should  be  able to  see the  LEDs flash through the  hole in the disc. The green LED is at 15 degrees before TDC.

[Hint: The disk rotates counter-clockwise (NOT clockwise).]

Observe the variation in the timing while the disc speed is being increased and decreased. You will see this as a change in the colour of the LED illuminated through the hole at the time of the  "spark". That is, the spark pulse does not occur at the correct angle when accelerating or decelerating.

Why does this occur (provide an explanation in your report)?

[Hint: Check how is the period calculated in the code.]

Explain in your report how you could reduce this effect by modifying:

(i) the software and

(ii) the hardware

Save the code you have generated in Part 3, you will need to return to it later…

Now modify your code such that it displays not the period of rotation of the flywheel, instead it displays the rotational speed in revolutions per minute (rpm).

[Hint: You will  need  to  inspect  the  Timer  initialisation  code  to  determine  the  significance  of  the displayed value of period. In addition, as you should not use floating point calculations, all variables should be declared as volatile INTEGER type, pay close attention when performing division arithmetic operations during the conversion from period of rotation to the rotational speed in revolutions per minute as any small value divided by a big value will end up with a zero result. For example, if you have three integer variables, int a = 2; int b = 10; and int c = 5, then a/b * c = 2/10 * 5 will give you 0 in this case, NOT 1 as 2/10 = 0 and 0 * 5 = 0. To solve this, rearrange the expression to (2 * 5) / 10 which will give you the desired output 1.]

Part 4 [4 Marks]

For best engine efficiency, the advance angle is small for low revolution rates and much larger at high revolution rates.

Alter your program so that it calculates the Advance Angle (AA), which should be 20 degrees up to 600 rpm and constant at 80 degrees beyond 1500 rpm. Between these two rotation speeds, there should be a linear change in the AA.

Test your AA calculation code by displaying the AA (along with the RPM) on the LCD display, line 2.

[Hint: Background information useful for solving this is available in the Lecture 10 slideset. You will need to derive the mathematical formula of the linear part of the AA graph.]

Once you have an AA varying between the two limits, modify the programme so that the spark occurs at the calculated time. Do not use floating point in your calculations since it is slow. Use your program to work out the angle before TDC of the right-hand red LED.

[Hint: In PART 3, the spark occurs at a fixed advance angle which is 15 degrees. Now you will need to utilise the calculated advance angle from above and replace the hard-coded one you did in PART 3]

Part 5 [2 Marks]

A realtime system can be defined as a system in which an action or calculation must occur within a limited period of time. As such, the system you have devised above can be considered as a real time one.

How much time is available for the calculation of the advance angle given a speed of 2100 revolutions per minute?

[Hint: This is a calculation problem. Background information useful for solving this is available in the lecture 10 slideset on Moodle.]

Part 6 [2 Marks]

Implement your software modification suggested in Part 3 to maintain the correct advance angle during acceleration and deceleration. Test your solution and see if it works.

Part 7 [2 Marks]

The code provided for Parts 3-5 uses a general purpose I/O Pin configured as an output and named ‘spark’ plus two  Match  Registers  MR0  and  MR1.  An  interrupt  from  MR0  sets  the  spark  output  high  and  an  interrupt from MR1 resets spark low. The use of two match registers for a single output is not efficient,  neither  is  the  use  of  an  extra  output  pin  and  DigitialOut  API,  when  the  processor  can  drive  a  pin automatically from the Match Register.

Copy the original timing.cpp code to a new design name and modify the code such that it uses just Match Register 1 to set the spark pin high, and then to return it low. Set the AA at a constant 15 degrees, to keep things simple and make testing easier.

Note: It is not safe just to toggle the Spark output, you need to set it high on the first Match Register Interrupt following TDC then set it low on the next interrupt. If you just toggle Spark, there is always the chance that the spark signal could become inverted following a glitch, so set it explicitly high and then low.

Part 8 [2 Marks]

The code is still using an extra output pin and DigitalOut API.

Modify your program such that the spark is generated directly from the MAT2.2 signal. To do this you will need to configure pin 6 such that it is driven by MAT2.2, and the pin should be set high and then set low using the Timer 2 Match Register 2.

Note: Pin 6 is used by the application board to drive the LCD Display, so this change will mess up the display. But give it a try anyway and checked the results on the oscilloscope. (It’s likely that you will have to remove the lcd library from your project for this). Once again, you should avoid toggling the spark output on a match.



热门主题

课程名

mktg2509 csci 2600 38170 lng302 csse3010 phas3226 77938 arch1162 engn4536/engn6536 acx5903 comp151101 phl245 cse12 comp9312 stat3016/6016 phas0038 comp2140 6qqmb312 xjco3011 rest0005 ematm0051 5qqmn219 lubs5062m eee8155 cege0100 eap033 artd1109 mat246 etc3430 ecmm462 mis102 inft6800 ddes9903 comp6521 comp9517 comp3331/9331 comp4337 comp6008 comp9414 bu.231.790.81 man00150m csb352h math1041 eengm4100 isys1002 08 6057cem mktg3504 mthm036 mtrx1701 mth3241 eeee3086 cmp-7038b cmp-7000a ints4010 econ2151 infs5710 fins5516 fin3309 fins5510 gsoe9340 math2007 math2036 soee5010 mark3088 infs3605 elec9714 comp2271 ma214 comp2211 infs3604 600426 sit254 acct3091 bbt405 msin0116 com107/com113 mark5826 sit120 comp9021 eco2101 eeen40700 cs253 ece3114 ecmm447 chns3000 math377 itd102 comp9444 comp(2041|9044) econ0060 econ7230 mgt001371 ecs-323 cs6250 mgdi60012 mdia2012 comm221001 comm5000 ma1008 engl642 econ241 com333 math367 mis201 nbs-7041x meek16104 econ2003 comm1190 mbas902 comp-1027 dpst1091 comp7315 eppd1033 m06 ee3025 msci231 bb113/bbs1063 fc709 comp3425 comp9417 econ42915 cb9101 math1102e chme0017 fc307 mkt60104 5522usst litr1-uc6201.200 ee1102 cosc2803 math39512 omp9727 int2067/int5051 bsb151 mgt253 fc021 babs2202 mis2002s phya21 18-213 cege0012 mdia1002 math38032 mech5125 07 cisc102 mgx3110 cs240 11175 fin3020s eco3420 ictten622 comp9727 cpt111 de114102d mgm320h5s bafi1019 math21112 efim20036 mn-3503 fins5568 110.807 bcpm000028 info6030 bma0092 bcpm0054 math20212 ce335 cs365 cenv6141 ftec5580 math2010 ec3450 comm1170 ecmt1010 csci-ua.0480-003 econ12-200 ib3960 ectb60h3f cs247—assignment tk3163 ics3u ib3j80 comp20008 comp9334 eppd1063 acct2343 cct109 isys1055/3412 math350-real math2014 eec180 stat141b econ2101 msinm014/msing014/msing014b fit2004 comp643 bu1002 cm2030
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图