Design of intercom encryption system based on STCl2C2052 single chip microcomputer

Publisher:LIGANG888Latest update time:2011-11-09 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

CTCSS (Continuous Tone Controlled Squelch Systern) is a technology that adds frequencies (67.0-250.3 Hz) lower than the audio frequency to the audio signal for transmission. The international standard CTCSS code has a total of 38 frequency groups. Because the frequencies of these squelch signals are 67.0-250.3 Hz, which are lower than the lower limit of the voice communication bandwidth, they are called "sub-audio". CTCSS technology has been widely used in radio communications and is a common means of limiting transmission and reception in traditional radio station communications. In radio station relay stations and walkie-talkies, the use of CTCSS technology can avoid receiving irrelevant calls.

The sub-audio technology is used in the design of walkie-talkies to avoid mutual interference between different users and to avoid listening to irrelevant calls and interference signals. Because it can prevent voice and signaling interference from other users in the common channel, it is also called tone lock. When the transmitter of the walkie-talkie sends a voice signal, it continuously sends out a sub-audio continuous signal, which is modulated and transmitted on the same channel. When the receiver receives the carrier signal and the sub-audio signal, it performs modulation. After the sub-audio signal is shaped by the filter and input into the CPU for decoding, it is compared with the CTC-SS code preset in the machine to determine whether to turn on the squelch circuit. Only when the sub-audio code is the same, the squelch circuit audio output can be turned on and sound can be emitted through the speaker. If no CTCSS signal is detected, or the signal does not match the current setting, the squelch is turned off and no sound can be heard from the speaker. This paper proposes a design scheme for a walkie-talkie encryption system based on the STC12C2052 microcontroller.

1 Introduction to STCl2C2052 MCU

STC12C2052 is an enhanced 8051 microcontroller of STC12 series launched by Hongjing Technology. It is 12 times faster than ordinary 8051 and has a wider operating voltage range. It integrates: 256 bytes of RAM; 15 general-purpose programmable I/O ports, which can be set to quasi-bidirectional port/weak pull-up, push-pull/strong pull-up, input only/high impedance, open drain (quasi-bidirectional port/weak pull-up mode after reset); EEPROM function; 2 16-bit timers/counters; RC oscillator, external crystal oscillator can be omitted when accuracy is not required; independent on-chip watchdog timer.

1.1 PCA/PWM working principle of STC12C2052

The PCA programmable counter array in the STC12C2052 microcontroller contains a special 16-bit timer that can be connected to two 16-bit capture/compare modules. Each module can be programmed to work in four modes, namely rising/falling edge capture, software timer, high-speed output and modulated pulse output. When designing, module 0 can be connected to P3.7 (CEX0/PCA0/PWM0) and module 1 can be connected to P3.5 (CEX1/PCA1/PWM1). Since the contents of registers CH and CL are the values ​​of the 16-bit PCA timer that is freely counting up, the PCA timer can be used as a common time base for the two modules and can be programmed to work at 1/12 oscillation frequency, 1/2 oscillation frequency, timer 0 overflow or ECI pin input (P3.4). The counting source of the timer is determined by the CPS1 and CPS0 bits of the CMOD SFR.

1.2 PCA pulse width adjustment mode of STC12C2052

All PCA modules can be used as PWM outputs. The output frequency depends on the clock source of the PCA timer. Since all modules share the only PCA timer, their output frequencies are the same. The output duty cycle of each module varies independently and is related to the capture register pair EPCnL and CCAPnL used. When the value of CL SFR is less than EPCnL and CCAPhL, the output is low; when the value of PCA CLSFR is equal to or greater than EPCnL and CCAPnL, the output is high. When the value of CL overflows from FF to 00, the contents of EPCnH and CCAPnH will be loaded into EPCnL and CCAPnL, so that PWM can be updated without interference. When enabling PWM mode, the PWMn and ECOMn bits of the module CCAPMn register must be set. Since PWM is 8-bit, the signal frequency of PWM can be calculated by the following formula:

[page]

2 PWM modulation principle

Pulse Width Modulation (PWM) is a very effective technology that uses the digital output of a microprocessor to control analog circuits. It is widely used in many fields from measurement, communication to power control and conversion. The principle of pulse width modulation is shown in Figure 1.

Pulse Width Modulation Principle

Figure 1 Pulse width modulation principle

In short, PWM is a method of digitally encoding the level of an analog signal. Through the use of high-resolution counters, the duty cycle of a square wave is modulated to encode the level of a specific analog signal. The PWM signal is still digital because at any given moment, the full-scale DC power supply is either fully present (ON) or fully absent (OFF). The voltage or current source is applied to the analog load in a repetitive sequence of pulses that are either on (ON) or off (OFF). On means when the DC power supply is applied to the load; off means when the power supply is disconnected. As long as the bandwidth is sufficient, any analog value can be encoded using PWM.

One advantage of PWM is that the signal from the processor to the controlled system is in digital form, without the need for digital/analog conversion. Keeping the signal in digital form minimizes the impact of noise. Noise can only affect a digital signal if it is strong enough to change a logic 1 to a logic 0, or a logic 0 to a logic 1.

Another advantage of PWM over analog control is its strong noise immunity, which is the main reason why PWM is sometimes used for communication. Switching from analog signals to PWM can greatly extend the communication distance. At the receiving end, the modulated high-frequency square wave can be filtered out through appropriate RC or LC networks and the signal can be restored to analog form.

Many microcontrollers have built-in PWM controllers. For example, the STC12C2052 has two PWM controllers, each with selectable on-time and period. The duty cycle is the ratio of the on-time to the period; the modulation frequency is the inverse of the period. Before performing PWM operations, this microprocessor requires the following to be done in software:

① Set the period of the on-chip timer/counter that provides the modulated square wave;

②Set the on-time in the PWM control register;

③Set the direction of PWM output, here is the general I/O pin;

④Start the timer;

⑤ Enable the PWM controller (although the specific PWM controllers may differ in programming details, their basic ideas are the same).

[page]

3 Hardware Design

The design of the CTCSS system is based on a set of low-frequency audio signals (67.0-250.3 Hz) (32 or 38, depending on the standard). These sub-audio signals are completely sinusoidal, and the frequency difference is very strict. In most designs, the method of finding the fixed-point sine function value is adopted: Taking the generation of sine waves as an example, the fixed-point method is used to generate the waveform, that is, a cycle of sine waves is divided into several points according to 360°, the sine function value of each point is calculated, and the corresponding D/A converter input value is converted to obtain a sine function table. The table is stored in the program memory of the microcontroller through the program, and the timer of the microcontroller is used to generate the timing. Whenever the timing time is reached, the table is looked up to obtain the output value corresponding to the point, and then the voltage value corresponding to the point is obtained through D/A conversion. In this way, the desired sine wave can be obtained by repeatedly looking up the table output. Since the number of points of a cycle of sine waves is fixed, changing the timing value of the timer changes the interval time between two adjacent points, thereby changing the frequency of the sine wave.

Here, another simpler method is used to generate multiple waveforms. The PWM modulation signal of the microcontroller is used to generate multiple waveforms, but the defect of this method is that the frequency of the generated waveform is limited.

3.1 Method of generating sub-audio signals

Calculation formula: y=256/2+80*sin(2PI*x/512).

Generate a sine table using the following code:

[page]

Assuming the PWM frequency is 32 768 000/256 Hz, the PWM duty cycle is changed once every PWM interrupt (the change pattern is shown in the sine table). The final output waveform becomes a sine signal after being filtered by a low-pass filter, as shown in Figure 2.

Generation of sinusoidal signals

Figure 2 Generation of sinusoidal signal

3.2 Hardware circuit of sub-audio signal

The encryption system is mainly composed of keyboard circuit, online program download circuit and power supply circuit. Its hardware circuit is shown in Figure 3. Among them, XW-5-LOW is a voltage-stabilized output chip.

Hardware Circuit Diagram

Figure 3 Hardware circuit diagram

(1) Keyboard circuit. Since the number of keys required for this system is relatively small, independent keys can be used to meet the requirements. Connect 6 independent keys to 6 wires of the microcontroller P1 port. These 6 keys can form up to 64 combinations, which can complete the setting of sub-audio signals of any frequency.

(2) Online programming circuit. The six signal lines GND, P3.1, P3.O, VCC, P1.1, and P1.0 are brought out in the circuit so that users can program directly in their own system.

(3) Power supply circuit and low-pass filter circuit. The power supply required by the circuit is generated after voltage stabilization by the voltage regulator chip and filtering by the capacitor. The filtering circuit is realized by the RC filtering circuit.

4 Software Design

The software design includes the main program and the watchdog subroutine, the key reading subroutine, the timer 0 interrupt service subroutine, and the timer 1 interrupt service subroutine. The main program first completes the initialization settings of the watchdog, various special function registers related to PWM, and timer 0 and timer 1. Then it determines the current key and generates the corresponding sub-audio signal according to the key pressed.

The timer 0 interrupt subroutine mainly completes the update of the PWM timer and capture register values, and outputs the corresponding pulse signal (i.e. sine wave signal) at the P3.5 and P3.7 pins. The timer 1 interrupt subroutine mainly completes the timing work of the cycle of each sub-audio signal.

5 Conclusion

The previous implementation methods all used audio phase-locked loops to detect and generate sub-audio frequencies, which was difficult to design and troublesome to debug. However, the digital solution in this article can achieve high-precision and high-stability sub-audio frequencies without any debugging, and greatly reduce production costs.

CTCSS can prevent useless voice and other signaling interference from other users in the shared channel. It is a signaling identification system that improves the communication network's ability to resist external interference through sub-audio (digital sub-audio) signaling encoding/decoding, and solves the problem of non-network users joining the network. At the same time, CTCSS has a selective calling function, which can use continuous single-audio coding (digital coding) for selective calling, and always transmits voice signals at the same time, which is also the most effective selective calling method at present. The main caller can make a group call or a full call by pressing PTT. When the intercom call is over, there is no need to press a button to hang up. It is more convenient and faster than manual coding selective calling (DTMF) by telephone interconnection.

Reference address:Design of intercom encryption system based on STCl2C2052 single chip microcomputer

Previous article:Design of Ultrasonic Therapeutic Instrument Based on 51 Single Chip Microcomputer
Next article:Design of Calendar Clock Module Based on AT89C52 Single Chip Microcomputer

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号