首页 > > 详细

辅导41081程序、C++编程调试、program编程讲解 辅导Web开发|调试Matlab程序

项目预算:   开发周期:  发布时间:   要求地区:
41081 Sensing, Actuation and Control
Outline of Lab 1
In this lab, you will learn
1. how to install and configure RIMS;
2. how to use RIMS, including how to debug and run a program at different speeds, and
how to call functions;
3. How to develop C programs with different functionalities.
PART 1: Installing RIMS and practices
Download RI Tools from: http://www.cs.ucr.edu/~vahid/pes/RITools/ . After you download the
Windows version v2.8, run the RIMS.EXE file to install it.
Go to the RI Tool help page and get familiar with the basic functions.
First Try:
• Double-click RIMS desktop icon
• Click "Save" button to save the preloaded sample C program
• Click "Compile" button to convert C code to machine instructions (not seen by user) for
the RI microcontroller
• Click "Run" button to run the program
• Click "A0" switch to change A0's value from 0 to 1, note the "B0" value changes to 1
and its LED turns green per the sample program, which sets B0 to 1 when A0 is 1 and
A1 is 0.
• Click the "A1" switch, note that B0 changes back to 0, according to the sample program.
Debugging
• While running, move speed slider left to execute slower, right to execute faster.
• Press "Break" to stop execution; The arrow indicates the current C instruction to run
• Press "Step" to execute one machine instruction (note: one C instruction may consist of
several machine instructions).
• Press "Continue" to resume the execution
RIMS basic practices
RIMS (Riverside-Irvine Microcontroller Simulator) is a graphical tool that supports C
programming and simulated execution of RIM.
Click “Open sample” to load any file. Press "Compile", then press "Run". Press A0 to A7 to
change to 1, then press A0 to A7 to change to 0; note B changes in led. Press "Terminate".
Click “File” then “New” to start a new project.
41081 Sensing, Actuation and Control
3
Modify the program by assigning B0 = (A0 && A1) || (!A0 && !A1); Change the simulation speed
to "Slowest". Press "Compile", then press "Run". Change the values of A0 and A1. Note that the
simulator highlights the next statement to execute. Press Stop.
Modify the program by setting B0 to 1 when A0 is 0 and A1 is 0, or when A0 is 0 and A2 is 0.
(for example: B0 = (A0 && A1) || (A0 && A2));
Modify the program by setting B0 to 1 when the number of 1s on A2, A1, and A0 is two or
more (i.e., when A2A1A0 are 011, 110, 101, or 111). Click "Compile" then "Run" to test your
program
41081 Sensing, Actuation and Control
4
Change the simulation speed to "Slowest" while the program is running; note the highlighted
statement is the next statement to execute
RIMS debugger
Set A1A0 to 00, run the program, then press "Break". Press "Step" 5 times; note that the
current statement is highlighted and move forward with each press of "Step".
Change A1A0 to 01, then press "Step" until B0 changes. Press "Continue" to resume running.
Press "Terminate" to end the simulation
41081 Sensing, Actuation and Control
5
Using printf
Add to the while(1) loop: printf("B = %d\r\n", B);. Press Compile then Run.
Set A0 and A1 to 1, so B0 is 1. Press “Break”. Note that the value of B is output in the terminal
window. Note that you can also set it as Slowest. What’s the result in terminal window? Save
your code.
41081 Sensing, Actuation and Control
6
PART 2: TASKS
Task 2.1: Seat belt warning system (4 points).
A car has a sensor connected to A0 (1 means the car is on), another sensor connected to A1 (1
means a person is in the driver's seat), and a sensor connected to A2 (1 means the seat belt is
fastened). Write RIM C code for a "fasten seat belt" system that illuminates a warning light (by
setting B0=1) when the car is on, a driver is seated, and the seat belt is not fastened. Test the
written code with RIMS for all possible input combinations of A2, A1, A0.
Send us your results in a file (Word or PDF) for marking using UTS canavs:
(1) Copy of your source code; (2 points)
(2) Screenshot of the case where: the car on, the driver is not seated (1 point)
(3) Screenshot of the case where: the car on, the driver is seated and the seat belt is not
fastened (1 point)
Task 2.2: RIMS 7-segment display (6 Points)
Design and implement a C program using RIMS, that will continuously display the value of A3
A2 A1 A0, i.e. 0x0 to 0xF in a 7-segment display connected to B. Using optimal code for
efficiency. See below as an example: A3 A2 A1 A0 = 0110, i.e., 6 in decimal. Refer to
https://en.wikipedia.org/wiki/Seven-segment_display for more on 7-segment display.
Send us your results for marking:
41081 Sensing, Actuation and Control
7
(1) Copy of your source code; (2’)
(2) Screenshot when A3 A2 A1 A0 = 0101; (1’)
(3) Screenshot when A3 A2 A1 A0 = 1100; (1’)
(4) What is your idea if we need to display A7 A6 A5 A4 A3 A2 A1 A0 using two 7-
segment display? Explain your idea, a short description and diagram as above will be
good. (2’)
Task 2.3: Parking lot sensors (5 Points)
A parking lot has eight spaces, each with a sensor connected to RIM input A7, A6, ..., A0. A RIM
input being 1 means a car is detected in the corresponding space. Spaces A7 and A6 are
reserved handicapped parking. Write a RIM C program that: (1) Sets B7 to 1 if both handicapped
spaces are full, and (2) Sets B2 B1 B0 equal to the number of available non-handicapped spaces.
For example, if the number of available non-handicapped spaces is 3, B2 B1 B0 are 011. Test
in RIMS. Refer to below function on how to get a bit given a char variable.
Send us your results for marking:
(1) Copy of your source code; (3’)
(2) Screenshot the result when test A = 0011 0000; (1’)
(3) Screenshot the result when test A = 1100 1101; (1’)

软件开发、广告设计客服
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 9951568
© 2021 www.rj363.com
软件定制开发网!