Thursday, June 2, 2011

Electronics Convergence and Communications Technology ? Blog ...

Summary: Have recommended a to adopt the PC of Linux operating system to carry on the communication design method through a bunch of mouths and MCS-51 series one-chip computers, 2 kinds of methods that provide the basic hardware principle and the communication designs program. The experiment proves, this kind of scheme is simple and reliable, cheap, have offered a solution for Linux application in fields such as industrial control,etc..

Keyword: Linux; One-chip computer; Serial communication; Industrial control

The one-chip computer performance is steady, cheap, powerful, equipping in intellectual instrument, industry and increasingly extensive application in the electronic consumer goods of daily expenses. In the input in the one-chip computer is exported and controlled, except connecting methods such as upper keypads and LCD display screens,etc. directly, generally through bunches of mouth and at last communication location machine PC,and then be able to last controls long-range because a method, and can utilize PC strong data processing function and friendly control interface, seem particularly important. In going on occasioning that controlling with PC to one-chip computer general, adopt Windows as go the intersection of location and platform of plane, its advantage is that an interface is friendly, programming is both easier with operating, the shortcoming is that stability is too bad, this device that several days or several months run continuously to need, especially improper. Requiring more harsh occasion, generally all adopt UNIX work station as the top management platform, it is Solaris work station system of SUN as the top management platform of the synchronous radiation accelerator of Hefei is adopted, but UNIX work station expensive price has limited its range used greatly. In recent years, with the swift and violent development of Linux, make it turn from a few people?s toy into operating systems of the mainstream gradually. Linux is it last GPL that the agreements free for source code opening software,no one is be free obtain by their source programs from Internet, can also revise its source code under the agreement of GPL in order to adapt to particular application, it runs on ordinary PC, performance is steady, are especially suitable for doing industrial control, so the serial communication which realizes Linux and one-chip computer is very meaningful, he can be an available substituting method of the expensive UNIX work station.

A hardware principle

China uses the one-chip computer that more one is series MCS-51 at present, so the one-chip computer experimental subjects that select for use are a slice of AT89C51, Fig. 1 is a principle picture of the hardware, accord with the serial communication of RS232C because of realizing, should use a slice of ICL232CPEMAX232 Change the circuit as the level of serial communication. In experiment, for looking over by communication successful,it except let on one-chip computer to at location machine loopback data, having also expanded several slices of latches on the periphery of the one-chip computer, several LED LED and several keypads. Serial communication adopts the simplest TxD, RxD, GND the strategic hinterland of China made and connected, notices that should be wired alternately on TxD and RxD both sides.

Go location plane one ordinary PC, have 2 serial mouthfuls of COM1 in all, COM2, it run RedHat8. 0,In fact, if does not demand to operate figure interfaces such as Gnome or KDE,etc., Linux requirements for hardware of the system are quite low.

The experiment proves, this circuit is simple and reliable, very suitable for testing serial communication.

2 serial communication designs program

It is serial communication procedure include whether it is the next machine one-chip computer and at location machine the procedures of PC. It receive one-chip computer it go that the machines come data in location,showing to slice inside RAM, and then until there more last outside is data at RAM and at location machine, therefore can judge whether communication succeeds. This procedure is written by the assembler language, the Potter rate is set up as 4 800 b/s at the time of initialisation, communication way is 8 ? N- 1.

It is a key part that the ones that get on location machine procedure are written, because should operate the apparatus of one bunch of hardwares, there are 2 kinds of methods, first, utilize the bunch of drivers attached of Linux kernel, another method is to read and write one bunch of hardware ports directly, introduce separately as follows.

2. A programming method which utilizes one bunch of drivers

Carry on programming with one bunch of drivers of Linux, in fact it is a series of function of transferring driver, finish the arrangement of one bunch of communication parameters, sending and receiving of the data. In this kind of method, Linux strings the mouth together and distributes a file call number for each one, there are corresponding file names, actually regard the apparatus of the hardware as a kind of special file, COM1, file on it is corresponding in COM2 is respectively /dev/ttyS0,/dev/ttyS1,operate if you can?t string by mouth together, operate just by these 2 files in fact to these 2 pieceses, to the intersection of hardware and the intersection of apparatus and operation and have nothing to ordinary operation of file different of file, can all use the same file I/O to transfer the function open, write, read, close ,The difference lies in transferring open with the system ? After the file opening one bunch of mouths and getting the corresponding apparatus describes that agrees with, should carry on initialisation to it first, set up some particular parameters, such as the Potter rate, data location, inputting and outputting the way etc., these parameters leave structtermios, function tcsetattr in ? Can set up bunches of structtermios of mouth, tcgetattr ? Can get struct termios of one bunch of mouths. Can read and write one bunch of files with read and write after after setting up the communication parameter. Should notice whether users have to the power that one bunch of files reads and writes to want operation while operating the procedure, can order to revise the file authority with chmod.

The initialized function is as follows:

Initialisation begins to send and receive the data, send a string to the one-chip computer first, after the one-chip computer receives the data, recycle the data back to to the location going machine. But need to pay attention to, because of getting on the location machine speed much faster than the one-chip computer, one can?t send too much data, make it overflow and lose data not to send person who buffer most probably, send, need, wait for some time, make one-chip computer send totally data to, go location behind the plane, read again.

2. 2 methods to read and write one bunch of hardware ports directly

When using this method, there must be some to understand. One bunch of mouths of the PC is by common asynchronous transceiver 8250UART or 16550 Form for the core, the base address of the register is 0x3f8COM1 respectively With 0x2f8COM2 ,There are some other registers used for controlling. A lot of registers are correlated to Modem, and use while using the the strategic hinterland of China to make communication and is less than, only use and care about the register correlated to communication, compared with using one bunch of apparatus drivers written for the common function to come, read and write the relevant register efficiency higher directly.

After initialisation, can carry on the receiving and dispatching of the data, it is ready to accept and must guarantee to receive the data before the data, this can judge, send, must guarantee, send register as empty before the data by D0 of 0x2fd, this can judge by D5 of 0x2fd, the code is as follows:

3 concludes the speech

The experiment shows, 2 kinds of methods that this system adopted have all totally realized the point-to-point communication between LinuxPC machine and one-chip computer, the method is simple and reliable, are basically needing the occasion which uses the PC and serial communication of one-chip computer and can adopt this kind of method. Grow stronger day by day at Chinese that range of application with Linux in recent years,at industrial control, data gathering field too will adoption Linuxes increasingly much, this text can be regarded as a beneficial attempt. Certainly also need to consider some questions, for example the problem making mistakes and dealing with in practical application, can in check-up of sending another after being that one will take, send stringing and, act as and receive the check-up returning and send again with the check-up that is sent and when being inconsistent, and then for example RS232C adopted transmits the distance very short, and the ability to resist interference is very bad, need to convert the bus to difference at this moment and divide RS485/RS422 transmitted. In addition, improve a little, can realize the serial communication of the PC and one-chip computer of many films 51, because of sharing a bus at this moment, must distribute an address for each one-chip computer, then it last arbitration about bus from PC,it could last bus one-chip computer of the usufructs only and at last communication location machine, no longer go into details here.

In a word, this text has just offered a typical example for Linux PC and one-chip computer serial communication, apply to the real project, need considering specifically according to the real situation, flexible application, could form a reliable system based on Linux platform finally.

This entry was posted on Tuesday, May 31st, 2011 at 8:52 am and is filed under Uncategorized. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Source: http://hujk.org/close-goods-source-pdf-chip-materials-offered-linux-pc-and-51-serial-one-chip-computers-serial-communication/

madhuri dixit achilles psn up cloverfield nigeria swing moldova

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.