Course record

This project is designed based on 51 cores of stc89c52.
Divided into the following parts:
1. Sensor module
2.MCU
3. Action module The

sensor is to use an off-the-shelf module, that is, the pressure sensor. The details of its principles are not discussed in depth. In general, it is the
pressure that deforms the sensor. In fact, the sensor is a stress resistance. Each pressure corresponds to a resistance, and each resistance
corresponds to a voltage, that is, the voltage passed to the AD module. As for how to design more Reasonable, the precision is greater, then
this is not what I am studying. We only need to know that each pressure corresponds to a voltage, then AD can collect the analog value of
voltage , collect it, and finally read the voltage value, and then the voltage value and the pressure have a constant
relationship, which is based on the circuit and All known conditions can be calculated. OK, that's it.
Of course, the driver function of this AD module is also ready-made, you don't need to write it yourself, otherwise it is impossible to be OK in one day.
Of course, basically, you can read the manual of this chip and write it according to the timing. Simple can also be written, but It takes a long
time a bit cumbersome.
Well, with the driving function, that is to say, we can read the D value of this through a certain protocol (rule), that is,
there is a constant relationship between the digital value D value and the measured A value, and there must be errors.
The error mainly exists in several aspects:
1. Inevitably, the AD conversion error, the chip used is HX711, which is 24bit, and the development board is 8bit A/DD/A. The higher the
  number of chips, the higher the precision. This is a errors.

2. The error in the calculation, when calculating the constant, will be approximately equal, for simplicity.

3. The theoretically calculated value of the constant is an ideal value. Sometimes the sensor is not necessarily ideal. For example, if
the , the obtained constant is meaningless.

We can get the D value, then we can "communicate" with the MCU.
We can display it, but the development board sent by our school feels a bit low. Its timers T0 and T1 are actually shared with the lcd
pins . That is to say, if I use a timer, then the pins are counting , that is, the clock pulse responds
to count its register, then it will have an impact on the lcd.
Then it is enough to generate garbled characters. Then the current solutions are:
1. Connect a peripheral LCD yourself, without using the interface on the
board 2. Change the board
3. Change a display mode

Then the most immediate thought is to change a display, of course, it will process It's pretty complete. LCD, digital tube, serial port
are available . However, the nixie tube will conflict with a motor-driven pin that I will use later, so give it up first.
The serial port feels okay, so good, then use it.

Then add the action module. The lesson requirement is to adjust the speed of the motor by reading the pressure value to simulate the action of the elevator.
Then we need to use pwm to achieve the purpose of speed regulation. Of course, I can't write the driver code now, because I'm
a little lazy. . . . So let's see if there is a process, yes, there is, it's very skinny. Transplanted, it uses
two timers to achieve the change of the square wave pulse, okay, then use it. When tested alone, it really can adjust the speed.
Continue, transplant it, and then gg and crash. Well, transplant, this is normal, then find the reason.
Finally, it was found that the serial port uses working mode 0 and uses timer 1 to generate the baud rate, then this conflicts.
OK, found the problem, how to solve it?
1. Change the way to implement pwm
2. Increase the clock

When I looked at the schematic diagram, I found that the at89c52 has T2, so just add a timer for convenience. The method of changing pwm has not been studied.
In fact, it is a bit troublesome to use T2. I feel that there is a pit in that the flag bit of its timer is not reset by hardware, but
needs to be software, that is, in the interrupt service function: TF2=0; a little pit.
It is designed to be divided into five weight classes, one for each speed.
The above does it, however, it's just done for completion.
I think it:
1. If lcd does not conflict, it is better to use LCD.
2. Is it a bit too much to use three clocks, is there a better pwm implementation solution? It seems that stc12c5a can have output pins directly
used for pwm, is this more convenient?

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325742547&siteId=291194637