Examination Duration:150 minutes
Examination Duration:150 minutes
Instructions:
Note All written response questions will be submitted to associated drop-boxes on Avenue to Learn with Turnitin plagiarism software enabled. Any collaboration between students or other sources on exam material submissions will be enforced to the full extent (ZERO TOLERANCE) of McMaster's Academic Integrity Policy.
For unofficial grading: Pass = 1, Fail = 0
Question Marks Available Marks Obtained
1 S/U 2 S/U 3 S/U 4 S/U 5 S/U Total P/F Explain the significance of analog-to-digital conversion in the context of real-time systems. Discuss the key considerations and challenges involved in the design and implementation of analog-to-digital conversion processes for real-time applications.
Hint: In your answer, explain how choosing the wrong ADC parameters may affect the result of your real-time system. In choosing an appropriate ADC for a real-time system application, what ADC characteristics are the most important ones? You may support your answer with an example.
-Answer:
NyquistShannon sampling theorem
Length of buffer
Sampling frequency
Resolution of ADC device
Accuracy of the Device
If the ADC conversion speed is too low, it is possible to get the samples after the deadlines, and it can destroy the real-time system.
The ADC device must be fast enough to provide the minimum sampling rate for the real-time system.
The power consumption, voltage rating, noise cancellation, and internal filters are other important factors.
Passing criteria: Does the student know the importance and limitations on ADC in the contents of real-time systems?
A Global Positioning System (GPS) uses satellites to measure its longitude, latitude, and altitude. A GPS works by measuring the time it takes for a signal to travel to a satellite and be back to the GPS. The GPS can calculate its position based on the time it takes to send and receive the signals to at least four satellites. In order to calculate the position accurately, these clocks must be synchronized often.
The maximum allowable drift of the GPS clock is 1 millisecond.
The drift rate of the GPS clock compared to the satellite clock is 0.2XYZ microseconds/s. Replace XYZ with the last 3 digits of your student number. For example, if your student number was 400456789, the drift rate would be 0.2789 microseconds/s.
How often must the GPS clock be synchronized with the satellite clock in order to stay under the maximum allowable drift?
Explain what drift is and what is the cause of drift in real-time systems.
Jordan has recently been hired at ABC Corporation as an embedded systems programmer. One of their first projects is to program the start/stop sequence of a stuffed bear manufacturing line. Specifically, they are working on creating a delay for the bear stuffing process, which takes 2 seconds per bear. Due to unforeseen environmental issues, the hardware clock didnt work for this application. Therefore, a software solution needed to be developed. Jordan has developed the following assembly code:
__asm(" ldr r1, = x);__asm("loop: ");__asm(" subs r1,r1,#1 ");__asm(" bne loop ");
Note: x needs to be replaced with an integer value representing the number of clock cycles needed to implement the delay.
The microcontroller used in this application has the following specs:
8MHz processing speed
32-bit register length
3-stage processor
RISC Architecture
Instruction Process time (Machine Cycles)
ldr2
subs 3
bne2
Calculate the value of x to achieve the required delay.
Because of RISC Architecture, we can do pipelining. So subs and bne instructions can be done in parallel in total 3 machine cycles.
Each machine cycle is 1/8MHz = 125 ns
x = 2s/(125ns*3)=5,333,333
x = b010100010110000101010101 (23 bits), which fits with 32 bits.
Calculate the accuracy of your timer.
X value stored in the register = 5,333,333
Total delay = 2 (for ldr instruction) + 5,333,333 = 5,333,335 MC = 5,333,335 * 125 ns * 3 = 2.000000625 s
Error = 3.3125 e-5 %
Explain how interrupts may affect the accuracy of your busy-wait timer.
If the CPU attend to an interrupt the delay will become longer and not possible to calculate exact delay.
Keeping the register value you calculated in part a, how long would the delay be if the processor architecture was changed to CISC? Explain your answer.
For a CISC architecture, pipelining is not possible, so all the loop takes 2+3 MC = 5 MC = 5*125ns = 625ns
Total delay = 625ns* 5,333,333 = 3.33 s.
A CPU is responsible for processing five tasks. Use the following table to answer the questions below:
Task Frequency Max Execution time
Task 1 5Hz 10 + last digit of student number (ms)
Task 2 Every 30ms 2ms
Task 3 10Hz 18ms
Task 4 Every 100ms 12ms
Task 5 Every 45ms 8ms
For this question, the maximum execution time of task 1 is 10 + the last digit of your student number. For example, if your student number was 400456789, the maximum execution time for Task 1 would be 10 + 9 = 19ms.
What is the maximum execution time of Task 1 using your student number? (in ms)
Calculate the CPU utilization factor. What CPU utilization zone is it in?
The customer would like the system to be very safe. Describe whether the system is already in this zone, and if not, change the frequency of one or more tasks to achieve it.
Very safe refers to the Utilization factor between 26% to 50%.
Explain if a feasible schedule can be found for this set of tasks (after your modifications in the previous part). No need to show the schedule.
Harper owns a restaurant in Hamilton, Ontario. They are interested in using robots to replace their server. They want to create a Petri-net to show the interaction between customers and their servers. They have started their Petri-net but need your help fixing and completing it. Their first draft is below:
Create a matrix to capture the initial state of this Petri-net (M0).
M0 = [1 0 0 0 1 0 1 0 0 ] The vector must have 3 1s and 6 0s. The order is not important as it depends on how each student assumed the order of the places.
When Harper runs a simulation, they realize customers wait for food forever. How would you recommend fixing this problem? Modify the Petri-net accordingly.
When the server takes the order, the server should go back to the place. An arrow is missing.
Complete the Petri-net to model the complete process. Your Petri-net should include the customer finishing their food, paying for the food with the servers help, and their table being returned to an open table. Consider only one server in your model.
END OF EXAMINATION
Anti-swing System
An anti-sway" system in heavy lifting applications, particularly in crane operations, is designed to minimize or eliminate the swinging motion (also known as sway) of the load being lifted. This swinging can occur due to various factors such as wind, operator input, or external disturbances, and it can be hazardous to both the load and surrounding structures or personnel.
The anti-sway system typically employs sensors, control algorithms, and actuators to actively stabilize the load and reduce swinging. An anti-swing system generally includes the following parts:
Sensor: Sensors such as accelerometers, gyroscopes, load cells, and cameras are used to measure the position, velocity, and orientation of the load, as well as environmental conditions such as wind speed and direction.
Controller: Control algorithms analyze the sensor data in real-time to determine the current state of the load and predict its future motion. Based on this information, the control system generates corrective commands to counteract the sway and stabilize the load.
Actuator: The corrective commands are sent to actuators such as motor drives or hydraulic systems, which adjust the motion of the crane's hoist or trolley to minimize the sway of the load. These adjustments may involve varying the speed, acceleration, or position of the crane's movements.
The goal of the anti-sway system is to improve safety, increase efficiency, and reduce the risk of accidents during lifting operations. By actively stabilizing the load and minimizing sway, the system helps operators maintain precise control over heavy objects, ensuring accurate placement and preventing damage or injury due to swinging motions.
Swing Model
Assume we model a swing system with a simple pendulum length of l, as shown below.
If the pendulum starts its swing from some initial angle0, thenassuming that the angle is much less than 1 radian, we can estimate the angle at time t by t by solving the following PDE: 1,
d2dt2+gl=0,In this equation, g is the gravity and l is the length of the pendulum.
The solution to this equation is:
t= 0cosgl tThe approximate period of the motion is:
T0= 2lg
Real-Time Systems Knowledge Check
Based on your knowledge about real-time systems, what type of real-time system is an anti-swing system? Explain your answer.
Draw a block diagram that models a closed-loop anti-swing system. Clearly show the inputs and outputs of each block and explain the data type (Analog or digital) at the input and output of each block.
Which factors affect the total response time of your anti-swing system? How can one estimate each block's response time and your anti-swing system's total response time?
LTI System Modelling and Simulation
In an anti-swing system design by XYZ company, a camera is used to capture a picture of the pendulum and send it to a DSP. The DSP implements an image processing algorithm to estimate the swing angle (t).
Assume l is the last three least significant digits of your student ID is mm plus 100.
For example, if your student ID is 4001248264, consider l=264+100=364 mm and 0=0.1 Rad.
Plot t as a function of time for the swing system explained earlier (Pendulum). Your plot must show 2-3 periods of the signal. In your plot, indicate the signal's max, min, and period. Do not forget the axes titles and units!
Period 1.210308
Max 0.1
Min -0.09996
Discuss weather the swing system is an LTI system and conditions which may change your answer.
The swing system described by the simple pendulum model is not an LTI (Linear Time-Invariant) system. It exhibits non-linear behavior due to the cosine function in its solution. Conditions that could change this answer include significant deviations from small angles (where the approximation holds) or introducing non-linearities in the system (e.g., non-linear damping).
Is it possible to design a real-time controller for a non LTI system?
Yes, it's possible to design a real-time controller for a non-LTI system. However, the controller design becomes more complex compared to LTI systems due to the system's non-linearities. Techniques like adaptive control, nonlinear control, or model predictive control may be employed for such systems.
Sampling and ADC conversion
How often should the camera take a snapshot of the pendulum? Suggest an appropriate sampling rate for your system. Explain the criteria you used to determine the sampling rate.
The sampling rate should be chosen based on the Nyquist-Shannon sampling theorem, which states that the sampling frequency should be at least twice the maximum frequency component of the signal. In this case, the maximum frequency component is related to the frequency of the pendulum's motion, which is determined by its period T0. Thus, a suitable sampling rate would be higher than twice the frequency 1//T0.
Note from Professor on the above solution:
Sampling rate for systems with feedback control must be at least 10*fn.
Considering an 8-bit digital value for variable in your DSP, plot [n] using a sample and hold system with the sampling rate you suggested earlier.
Explain the potential effects of changing the sampling rate to a faster or slower rate. How does the sampling rate affect the overall performance of your anti-swing system?
Faster Sampling Rate: Provides more data points and potentially better resolution but can lead to increased computational load and higher power consumption.
Slower Sampling Rate: Reduces computational load and power consumption but may result in loss of information, particularly for fast-changing signals, leading to reduced control performance.
Drift Problem
Explain the source of drift in the anti-swing system and how it may affect its performance.
Explain a situation where the software drift can endanger the life of people working around a crane.
Suggest a solution to mitigate the risk explained in the previous part.
Processor Architecture.
Assume the image processing algorithm used in your anti-swing system has 6780 lines of assembly code. This algorithm estimates the swing angle given the image of the pendulum. The code runs on a CISC architecture microcontroller with an average processing speed of 13 microseconds per instruction.
Calculate the software delay in this application.
The software delay can be calculated using the number of assembly lines and the microcontroller's average processing speed. It is simply the product of the number of assembly lines and the average processing time per instruction.
Given:
Number of assembly lines: 6780
Average processing speed per instruction: 13 microseconds
The software delay (Dsw) can be calculated as:
Dsw=NumberofassemblylinesAverageprocessingtimeperinstruction
Dsw=NumberofassemblylinesAverageprocessingtimeperinstruction
Dsw=678013s=88140s
Explain whether this software delay is acceptable in your ant-swing application.
Whether the software delay is acceptable depends on the specific requirements and constraints of the anti-swing application. A delay of 88.14 milliseconds may or may not be acceptable depending on factors such as the desired control frequency, the dynamics of the pendulum swing, and the overall performance requirements of the system.
In crane operations or similar heavy lifting applications, milliseconds can be crucial for ensuring precise control and safety. Thus, an 88.14 milliseconds delay may not be acceptable for real-time control, especially if rapid adjustments are necessary to counteract swinging motions effectively.
The software team wants to try a convolutional neural network and implement a more advanced image processing algorithm. Determine the maximum number of assembly lines they may run on this microcontroller safely without missing any image samples.
To determine the maximum number of assembly lines that can be run on the microcontroller without missing any image samples, we need to consider the timing constraints imposed by the image sampling rate and the processing time of the convolutional neural network (CNN) algorithm.
Without knowing the image sampling rate, it's challenging to provide a precise answer. However, assuming a typical image processing pipeline where the image processing time should be shorter than the time between successive image samples, we can calculate a rough estimate.
For example, if the image sampling rate is 30 frames per second (FPS), then the time available for processing each image is approximately 130301 seconds (33.33 milliseconds). Subtracting the software delay (88.14s) from this time, we get approximately.
33.33milliseconds0.08814milliseconds=33.24186milliseconds available for CNN processing/image.
Given this time constraint, the software team can determine the maximum number of assembly lines the CNN algorithm can have while still meeting the timing requirements. To make this determination accurately, they would need to profile the CNN algorithm's execution time on the microcontroller.
This calculation demonstrates the importance of considering both the algorithm's processing time and the system's timing requirements when designing real-time applications.