Intelligent Car lab stage test: Basis of Single Chip Microcomputer

Source: Internet
Author: User

Each person selects a question by drawing lots and completes the question requirements through independent programming. In principle, they do not view the previously writtenProgramBut the program must have a good programming style (including naming rules for variable functions,Code). Programming is provided in the morning. If you have time, you can try to write other questions. In the afternoon, you can check and accept the questions. During the acceptance, you must first execute the program and then explain the working principle and program logic.

I hope you can take this opportunity to test the results of this week.

Reference:

(1)Enhanced streaming lamp experiment.The following is the circuit diagram of the dial switch. PM2/PM3/pt0/pt1 is required.To initialize fourLEDThe initial status of the light, and then every other1 sFlow once. WhenPt3When a rising edge is triggered (you can obtain it through the dial switch: Off->Open), stop the flow. WhenPt2When a descent edge is triggered, the last state is continued.


For example, the initial status is PM2/PM3/pt0/pt1. Is 1 , 0 , 1 , 0 The initial state of the lamp is off, on, off, and on. When the program is executed 1 s Turn to Light, light, light, and so on. When Pt3 Slave 0 Dial 1 The flow stops. When Pt2 Slave 1 Dial 0 The flow continues.


(2) estimate the execution time of a program.The following is a latency function program,

Void delay () <br/>{< br/> uchar I, j; <br/> for (I = 0; I <0xff; I ++) <br/> {<br/> for (j = 0; j <0xff; j ++) <br/>{< br/> _ ASM <br/>{< br/> NOP <br/>}< br/ >}

Please write a program to estimate the latency of this function.

Tip: You can useTimerThe counter counting function in the module. The execution time of the function can be calculated by sending back two counting values and counting cycles of the counter. Core registerTcnt.

(3)Test the performance of the encoder.The speed encoder we bought is 100Line, that is, the EncoderTurn the gear around and send it back100Pulse. Verify the conclusion above. The hardware wiring diagram of the encoder is as follows.


Tip: Use MCU ectModuleChannel 7Pulse accumulation function. When the encoder gear is manually switched to a circle, the upper computer serial port sends a number to the lower computer, prompting the lower computer to send back the current number of pulses (core registerPacnt).


(4)Calculate the duty cycle in the center of the steering gear.Change pwm2,3Cascade, outputPWMWave to the steering gear, is to use the serial port to adjust the steering gear, and record at this timePWMDuty cycle.


Tip: Send two bytes each time through the serial port. The two bytes are used as the PWMOfDTYIn this way, you can easily debug and observe the steering gear deflection angle. Do not let the steering gear be maintained for a long time when the angle is killed. It is easy to burn out the steering gear. During the test, you can touch the wiring of the steering gear to disconnect it.

All the above four experiments require Frequency Doubling at the beginning, and the frequency doubling size is determined by yourself.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.