单片机接口
微机接口实现两种信息形式的交换。在计算机之外,由电子系统所处理的信息以一种物理信号形式存在,但在程序中,它是用数字表示的。任一接口的功能都可分为以某种形式进行数据库变换的一些操作,所以外部和内部形式的转换是由许多步骤完成的。
用图18.1所示的情况为例加以说明,图中展示了微计算机和产生连续变化模拟信号的传感器之间的接口。传感器产生的信号常很小,需要放大,或者产生的信号和形式被系统的其他部分处理之前需要再次转换。举例来说,许多传感器具有电阻变化,这必须由一专门电路转换成电压。这种将传感器输出转换成电压信号,并与系统的其他电路相连接的过程,称为信号调理。如图18.1所示例子中,信号调理部分将源自传感器的电压或电流信号范围转换成可用模拟-数字转换器变成数字形式的信号范围。
模拟-数字转换器(ADC)用来将连续变化信号变成相应的数字量,这数字量可是可能性的二进制数值中的一固定值。如果传感器输出不是连续变化的,就不需模拟-数字转换。这种情况下,信号调理单元必须将输入信号变换成为另一信号,也可直接与接口的下一部分,即微计算机本身的输入输出单元相连接。
输入/输出单元将数字“开/关”电压信号转换成能通过系统总线传送到计算机的信号形式。这里每一根线的状态,无论是“开”或是“关”,用相应的“1”或“0”表示。对于已经转换成数字形式的模拟输入量,内部表示中用1和0组成的排列形式与被转换量相对应的二进制数。
从接口得到的愿数值会受到接口电路设计的限制,而且常需要线性化和量程调整才能形成适合于在主程序中使用的数值。举例来说,接口可用于转换范围为0至255之间。显然,从程序员的观点,对温度进行直接的处理要比使用由ADC所产生的与一给定温度相一致的值要容易
Monolithic integrated circuit connection the microcomputer connection realizes two kind of information form exchange. Outside the computer, the information which processes by the electronic system by one physical signal form existence, but in the procedure, it is with the digital presentation. Any connection's function may divide into by some form carries on the database transformation some operations, therefore exterior and internal form's transformation is completes by many steps. the situation which 18.1 with shown in Figure explained for the example, in the chart had demonstrated the micro computer and produces changes the simulated signal continuously between sensor's connection. The sensor produces the signal is very often small, needs to enlarge, or produces before signal and form by system's other parts of processing, needs to transform once more. For example, many sensors have the resistance change, this must by a special circuit switching voltage. This kind transforms the sensor output the voltage signal, and process which connects with system's other electric circuits, is called the signal recuperation. As shown in Figure 18.1 in the example, the signal recuperation part will come from sensor's voltage or the electric current signal scope transforms the available analog-to-digital converter to turn the digital form the signal scope. the analog-to-digital converter (ADC) will use for to change the signal to turn the corresponding digital quantity continuously, but this digital quantity in a possible binary value fixture. If the sensor outputs is not changes continuously, cannot simulate - the digital conversion. In this kind of situation, the signal recuperation unit must input inversion into another signal, may also with the connection next part, namely the micro computer's input output unit connect directly. the input/output unit “opens the digit/the pass” the voltage signal conversion to be able to transmit through the system bus to computer's signal form. Here each line condition, regardless of being “opens” perhaps “the pass”, with corresponding “1” or “0” expressed. Regarding already transformed the digital form the simulation input value, the interior expressed that with is transformed with 1 and 0 composition's arrangement form the binary number which the quantity corresponds. will obtain from the connection is willing the value to receive the interface circuit design the limit, moreover often needs to linearize with the range adjustment can form suits in the value which will use in the master routine. For example, the connection may use in transforming the scope is 0 to 255 between. Obviously, as soon as from programmer's viewpoint, carries on direct processing to the temperature to with assign the temperature consistent value which compared to the use produces by ADC to want easy