The design of a remote control signal source based on SPI bus
- 格式:pdf
- 大小:311.79 KB
- 文档页数:4
The Design of a Remote Control Signal Source Based On SPI BusZenggang Wang, Shujing SuNational Key Laboratory for Electronic Measurement TechnologyNorth University of ChinaTaiyuan, ChinaE-mail:wangzenggang1216@, sushujing@Abstract —This paper presents a design which use single-chip microcomputer as the core of the signal source remote control circuit, The signal source can generate four basic waveforms, there are square, triangle wave, sawtooth and sine wave. It can also realize the remote signal circuit switching output signal type and ad usting frequency by means of the host computer digital command, this design of control circuit has the characteristics of high precision, high reliability and long communication distance.Keywords-Single – chip; Remote Control; Signal Source; SPI BusI.PREFACESource named the signal generator is widely used in automatic control ǃcommunication shook incentive and instrument due to its high stability, repeatability and operability etc, In practical application, we often need many kinds of parameters, the signal source which should have the following characteristics: (1) the stable adjustable frequency, amplitude and duty cycle, (2) functional diversity of the waveform generator, (3) convenient control system. Based on the above features, we design remote control circuit with C8051F060 MCU as its core. The terminal control circuit is a signal source generating circuit, through the PC interface, enter a number value and issued by the command to transmitting circuit, transmission line, the command receiving circuit realize the remote control signal source to output signal. The signal source can generate triangle wave, square wave, sawtooth and sine wave the 4 low frequency signal, and the types and frequency of the output signal can be adjusted by software control, the analog signal generation use 12-bit D/A converter to improve the voltage output accuracy of simulation signal.II.D ESIGN PRINCIPLESFigure1.The diagram of remote signal source control circuitThe remote control circuit block diagram isshowed in Fig 1, we use the most widely used means of communication RS-232 bus for communication between local devices, using long transmission line the serial SPI transmission can improve anti-interference ability of the remote transmission lines and data transmission distance. Microcontroller circuit is the master terminal, the main function is: 1, it can receive and judge datas or orders sent from long distance; 2, it can control D/A converter to produces the corresponding analog signals.III.H ARDWARE D ESIGNFigure2. The diagram of command to send the circuitFigure3. The diagram of order to receive and waveformgeneration circuit___________________________________ 978-1-4244-6943-7/10/$26.00 ©2010 IEEERS-232 serial communication is used in local devices, the difference of the RS-232 level between the transmitting circuit and receiver circuit is only about 2V to 3V, common mode rejection ability, coupled with the distributed capacitance twisted pair which sent the biggestof about 15 meters away, so RS-232 is special for communication between local devices. As the RS-232 is used to communicate the form of negative logic, so the level between the host computer and the transmitting circuit must be converted, the conversion is mainly accomplished by the MAX232 IC. remote control circuit is used long transmission serial communication named SPI, SPI serial interfaceis different from RS-232 bus, it has strong anti-interference ability of the data signal signals, far transmission lines. the command to transmitting circuit is shown in Fig 2.Fig 3 is the command receiver and waveform generator schematic. it realize that part of the main host computer issued commands to receive, identify and produce the final analog signals. command receiving circuit receive long-term major transmission lines on the TTL level conversion, then evacuate to then SPI port. We use C8051F060 as the MCU, it has been integrated within the 12-bit D/A converter and SPI serial port receiver, microcontroller control its internal D/A converters according to the received command to realize digital content to analog signals’ conversion, and also PC software can control and regulate the output waveform, we use the C8051F060 microcontroller as the transmitting circuitǃreceiver circuit and controller circuit’s master, it can greatly enhance the control circuit of the hardware design integration. control commands achieve the output type of analog’s cutover, and regulation orders is used to change the frequency of the output waveform, the final analog signal is exported by a dual op amp circuits: operational amplifier circuit and voltage follower circuit, in which computing amplifier achieve the amplitude of the output analog signal conditioning, voltage follower circuit is designedto improve the signal source circuit output and enhance the drive capability. PC software can use Microsoft's operating system win98, win2000, win XP comes with a "super terminal"or a number of serial line debugging assistant software can also send the host computer commands.IV.MCU P ROGRAMMINGIt is mainly composed by main program and the interrupt service program.A Main programThe main program first initializes the main processes: register initial value, flag bits, setting the communication baud rate and so on. when MCU receive the first data by UART1 to determine whether it is a decimal between 0 ~ 3 to microcontroller achieve the type of selection based on the number of output analog signals, the second received data can be decimal any value from 0 to 255, microcontroller adjust the output waveform’s frequency based on the second number.B Interrupt service programSerial interrupt service program primary receive microcontroller serial data and the datas’ storage, and then clear the flag bits to wait thenext serial reception interrupt.Figure4.Main program flowchartFigure5. Interrupt service program flowchartAttachment: Microcontroller C Programming Language……void UART1_Init (void){ char old_SFRPAGE= SFRPAGE;SFRPAGE = UART1_PAGE;SCON1 = 0x10;SCON1 &= 0xFC;SFRPAGE = 0;TMOD = 0x20;TCON = 0X40;CKCON = 0x10;PCON |= 0x80;TL1 = TH1;SFRPAGE = old_SFRPAGE; }void DAC0_Init(void) {char data SFRPAGE_SA VE = SFRPAGE; SFRPAGE = 0x02; RE F2CN = 0x03; SFRPAGE = 0x00; DAC0CN = 0x84;SFRPAGE = SFRPAGE_SA VE; }……case 0x00: { for (r=0; r<10;r++) q++;g=q;DAC0_Cover() ; break;}case 0x01: { n=255; for (g=0; g<256;g++) { DAC0_Cover() ;for (i=0; i<10;i++) ; }for (l=0; l<256;l++) { g=n;DAC0_Cover() ; for (i=0; i<10;i++) ;n--;}break;}V.T EST R ESULTSFigure6. The test results graph of analog signal output andthe frequencyNote: The system clock is 24M externalcrystal oscillator, frequency unit is HZ.VI.T YPICAL APPLICATIONSSignal generator and data acquisition system is the most widely used electronic devices; almost all of the electrical parameters of the measurement will be used in signal generator and data acquisition. this signal source can be provided for the analog signal acquisition system in some multi-channel remote signal acquisition system. because the design of the signal source can be remote controlled, one PC can achieve the analog signal acquisition system of input controls, acquisition system which can display the dates’ collection or storage, it overcome the analog signal switching and conditioning which must be adjusted in the shortcomings of the terminal device, it reduce the acquisition system debugging on the tedious work, and increase work efficiency.VII.C ONCLUSIONThe paper designed a remote control signal source, serial differential mode is used in long-term transmission to communicate, it greatly improve the long transmission distance lines, the normal anti-jamming capability and data communication distance. it use 12 bit D/A converter to achieve high stability, high accuracy output. through testing, the controllable signal source has the feature of high precision, long communication distance, simple and lower cost, it fully meet the needs of general applications.R EFERENCES[1]YANG Xiu-zeng. ĀDesign of Equal Precision DigitalFrequency Meter Based on NiosIIā. Automation˂Instrumentation 2009(7). (IN CHINESE)[2]LI Ying,LUO Yi. ĀDesign of ultra high frequencydigital cymometer ā. Journal of Chongqing Universityof Posts and Telecommunications(Natural Science.V ol.19 No.6, Dec.2004(IN CHINESE)[3]LIAO Yan,CHE N Li Xue,LAI Chun Hong. ĀThe IPcore design of frequency meter for equal precision based on FPGAā. E mbedded Technology,2007. (IN CHINESE)[4]LIAO Yan,CHE N Li Xue,LAI Chun Hong. ĀThe IPcore design of frequency meter for equal precision based on FPGA”. E mbedded Technology,2007. (IN CHINESE)。