For ship power stations, as they are independent small capacity power grids with complex environments that increasingly use power electronic converters, the impact of deteriorating power quality is particularly significant. Accurate measurement and display of power quality parameters, as well as effective methods to solve problems caused by power quality, are extremely important.
DSP (Digital Signal Processor) is a real-time, high-speed microprocessor for various digital signal processing operations, widely used in many fields such as speech, image, communication systems, power systems, and automation instruments. On the other hand, LCDs have advantages such as low power consumption, low cost, long lifespan, and convenient interfaces, making them widely used in various portable systems and industrial control systems, providing excellent human-machine interaction.
By employing a novel software algorithm, the signals collected by the DSP chip TMS320F2812 are correctly displayed on the LCD, and the related hardware circuit design is introduced, explaining how to control the LCD display through the digital I/O port of the DSP to simulate timing, along with corresponding C language implementation programs. The designed ship power grid parameters based on the DSP LCD display system are shown in Figure 1.
1 Hardware Design
1.1 Characteristics of TMS320F2812: TMS320F2812 is the latest DSP chip launched by TI, currently the most advanced and powerful 32-bit fixed-point DSP chip in the international market, achieving a perfect combination of high-performance digital signal processor (DSP) with high-precision analog and flash memory. The main performance of the chip includes:
1) An execution speed of 150MIPS shortens the instruction cycle to 6.67ns, thus enhancing the real-time control capability of the controller.
2) A high-performance 32-bit CPU, single-cycle 32 × 32 MAC operations, which is a fundamental transformation of microprocessor essence.
3) Based on the efficient 32-bit TMS320C28x DSP core, compatible with TMS320F24x/LE240x program code, and supports DSP/BIOS real-time operation.
4) The on-chip memory space is 36k × 8bit, containing 128K FLASH for simple reprogramming during development and field software upgrades. There is a 128-bit encryption bit.
5) Combining 32-bit digital processing capabilities with unique ‘IQ-math program library support, this library significantly simplifies multi-application development, enabling designers to connect floating-point algorithms to fixed-point processors in seconds, much faster than traditional 16-bit devices.
6) 12-bit ADC, 16 channels, with a maximum conversion speed of 80ns, and its dual-sampling device provides critical support in tight control loops.
7) Includes two EV modules, each consisting of a general-purpose timer, full comparator unit, CAP, and GEQ circuits.
1.2 Introduction to SED1335 and LCD Module: SED1335 is an LCD controller from Japan’s SEIKO EPSON, featuring I/O buffers, rich instruction functions, the ability to mix graphics and text, 4-bit data can be sent in parallel, and can drive a 640 × 256 dot matrix, etc. As shown in Figure 2: The maximum dot matrix of MSP-G320240 is 320 × 240 with backlight functionality, capable of operating over a wide temperature range, with the SED1335 LCD controller built-in. The hardware structure of SED1335 can be divided into the MPIJ interface part, internal control part, and LCD driving part.
The interface part of SED1335 consists of instruction input buffers, data input buffers, data output buffers, and flag registers. The operation timing circuit can be selected to adapt to the 8080 series and M6800 series MPU through pin level settings. The control part of SED1335 consists of an oscillator, functional logic circuit, display RAM management circuit, character library and management circuit, and a timing generator that produces driving timing. The oscillator frequency can be selected within 1~10MHz, and SED1335 can quickly interpret various codes sent by the MPU at high working frequencies. SED1335 can manage 64KB display RAM while also managing built-in character generators, external character generator CGRAM, or external CGRAM.
64kB display RAM can be divided into three display characteristic areas: text display area, graphic display area, and character display area. The text display area is dedicated to text display, where each byte of data is regarded as a character code. SED1335 uses this character code to determine the character’s starting address, then transmits the corresponding dot pattern data to display the character’s 8 × 8 dot matrix block on the LCD; the graphic display area is used for graphic display, where each byte of data is sent directly, and the level state of each bit determines the display state of a point on the screen, “1” means display, “0” means not display; the character generator CGRAM inside SED1335 solidifies 160 types of 5×7 dot matrix character patterns; moreover, SED1335 can also expand character generators, with code ranges from 80H~9FH and E0H~FFH totaling 64 types.
Since the LCD already has driver hardware circuits, the module provides a bus interface for easy interfacing with the processor’s bus. The driver module has an 8-bit data bus, plus power supply, interface, and control signals. It also has its own display cache, allowing content to be displayed just by sending the content to the display cache. This system uses the graphic dot matrix LCD display module MSP-G320240 produced by TRULY, with Figure 2 showing its specific circuit structure.
2 Hardware Interface Circuit: The TMS320F2812 accesses the SED1335 interface control board in two ways: direct access and indirect access. Direct access connects the read/write signal lines of F2812 directly to the read/write signal lines of the SED1335 interface control board, with timing controlled by the internal read/write logic of F2812. However, since the LCD module is a slow peripheral of the F2812 DSP, to match the speeds of both, certain wait states must be added to meet the requirements. Considering that the internal wait state generator of E2812 DSP can only insert a very limited number of wait cycles (only one wait state can be inserted for specified storage space, and it is challenging to meet the device’s requirements without adding extra hardware), this access method was not adopted in the design. Instead, an indirect access method was used, where the digital I/O port of F2812 DSP controls the SED1335, simulating the interface timing of SED1335 through software programming. The timing for the LCD module interface control in this design adopts the 8080 timing, with independent read/write signals. The interface circuit between F2812 and SED1335 is shown in Figure 3.
In this, GPIOA0~GPIOA7 of F28120 is used as the data interface, connected to the data lines DBO~DB7 of the LCD module to complete data transmission with SED1335; GPIOB1 is connected to /WR, setting GPIOB1 low when writing to SED1335; GPIOB2 is connected to /RD, setting GPIOB2 low when reading from SED1335; GPIOB3 is connected to /CS as chip select, setting GPI low when accessing SED1335; GHOBO is connected to AO, controlling access to the instruction input buffer, data input buffer, data output buffer, and flag register of SED1335 by writing 0 or 1 to GPIOBO, in coordination with GPIOB1 and GHOB2. VOUT is the output voltage of the DC-DC module on the LCD control board (+26V), and VO is the voltage for adjusting the LCD display contrast, which can be adjusted by a variable potentiometer.
3 Software Control Implementation: The key to the software design for controlling the LCD by F2812 DSP is the initialization of the LCD display and the matching of the interface timing between DSP and SED1335.
3.1 Initialization of the LCD: The initialization of the LCD is achieved by sending a series of instruction codes and corresponding instruction parameters to the LCD controller SED1335, with the specific program as follows:
const unsigned char
systab[ ]={0x32,0x87,0x07,0x27,0x42,0xef,0x28, 0x00};
const unsigned char scrtab []={0x00,0x00,Oxef};
#define SYSTEM_SET 0x40
#define SCROLL 0x44
#define SLEEP_IN 0x53
#define DISP_OFF 0x58
#define DISP-ON 0x59
#define OVLAY 0x5b
#define HDOT_SCR 0x5a
#define CSRFORM 0x5d
#define CGRAM_ADR 0x5c
#define CSRDIR_RG 0x4c
#define CSRDIR-LF 0x4d
#define CSRDIR-UP 0x4e
#define CSRDIR-DW 0x4f
#define CSRW 0x46
#define CSRR 0x47
#define MWRITE 0x42
#define MREAD 0x43
void LCD_Init_Controler()
{
int i;
EALLOW;
GpioMuxRegs.GPAMUX.all =Oxf0ff;// Enable GPIO[13,12,11,10]
GpioMuxRgs.GPADIR.all =Oxffff;// Configure GPIO as output
GpioDataRegs.GPADAT.all =0x0f00;//AO=1,CS=1,RD=1,WR=1
Write _Command (SYSTEM-SET);// System setting command
for(i=0;i<=7;i++)Write_Data(systab[i]);
Write_Command(SCROLL);// Set SCROLL command
for(i=0;i<=9;i++)Write_Data(scrtab[i]);
Write_Command(HDOT-SCR);// Set dot unit scrolling position
Write_Data(0x00);// No scrolling parameters
Write_Command(OVLAY); // Set dual-layer composite display mode
Write_Data(0x04);// Set the first display area to graphic mode
delay(2);
LCD_Clear(0,0,40,240,0×00);// Clear the first display area
Write_Command(CSRW);// Set cursor address command
Write_Data(0x40);// First display area starting address
Write_Data(0x01);
Write_Command(CSRFORM);// Set cursor shape
Write_Data(0x07);// Cursor length 5
Write_Data(0x88);// Cursor width 6
Write_Command(CSRDIR_RG);// Set cursor auto right shift
LCD_On();
}
Thus, the LCD initialization is complete, and data can now be written to the display area of SED1335 as needed, which will automatically complete the display of data on the LCD.
3.2 Matching of Interface Timing: To write the correct operation timing subroutine, one must first understand the interface timing characteristics of the SED1335 interface and the 8080 series MPU, as shown in Figure 4. Based on the hardware interface circuit description in Figure 3 and the timing characteristics in Figure 4, the following write command and write data operation subroutines can be written. In actual work, since SED1335 is a relatively slow device, wait cycles must be inserted during the read/write cycle.
void Write_Command(int c)
{idelay(1);//keep1340ns
GpioMuxRegs.GPADIR.all=0xffff
GpioDataRegs.GPADAT.all =0xlb00;//CS=0,A0=1
NOP;//keep more than 10ns
NOP;
GpioDataRegs.GPADAT.all=0x1a00;//WR=0
GpioDataRegs.GPADAT.all =(c︱0xla00);//Starting transfer data WR=0
GpioMuxRegs.GPAMIJX.all = 0xf000;//Enable GPIO delay(2);
GpioDataRegs.GPADAT.all =(c|0x1bOO);//WR=1
delay(1);
GpioDataRegs.GPADAT.all =0x1f00;//CS=1 transfering data is finished
GpioMuxRegs.GPAMUX.all = 0xf0ff
}
void Write_Data(int c)
{delay(1);//keep1340ns
GpioMuxRegs.GPADIR.all =0xfffh
GpioDataRegs.GPADAT.al1=0x1300;//CS=0,A0=0
NOP;//keep more than 10ns
NOP;
GpioDataRegs.GPADAT.all=0x1200;//WR=0
GpioDataRegs.GPADAT.all =(clOx1200);//Starting transfer data WR=0
GpioMuxRegs.GPAMUX.all =0xf000;//Enable GPIO delay(1);
GpioDataRegs.GPADAT.all =(c|0x1300);//WR=1 delay(1);
GpioDataRegs.GPADAT.all =0x1700;//CS=1 transfering data is finished
GpioMuxRegs.GPAMUX.all =0xf0ff;
}
After the LCD initialization is completed, displaying Chinese characters or images at the corresponding positions on the LCD screen becomes very easy. For example, to display Chinese characters: First, extract the dot matrix data of the Chinese characters to be displayed using dot pattern software, store it in the specific data space of the DSP; then calculate the corresponding address of the SED1335 display area for the position where the Chinese characters are to be displayed, write the address into the cursor address register using the CSRW command; finally, write the dot matrix data of the Chinese characters into the SED1335 display memory RAM using Write_Data(), and the corresponding position on the LCD screen will display the desired Chinese characters. This display process can be compiled into a subroutine for convenient calling and easy operation.
4 Experimental Results: Based on the designed system (Figure 1), experiments were conducted, with results shown in Figure 5. The results in Figure 5(a) show the system voltage and current parameters measured in the power meter and the waveforms measured in the oscilloscope, while the results in Figure 5(b) show the system voltage and current parameters and current waveforms measured on the LCD screen.
The voltage and current values measured by the method of this design and the load current waveforms were compared with the actual values and waveforms measured using the power meter, with results indicating that this measurement system has speed and accuracy in measuring the parameters of the ship power distribution board.
5 Conclusion: Focusing on the measurement and display of ship power grid parameters, this design employs the TMS320F2812 with high-speed processing characteristics and application simplification features as the processing chip to design a measurement system. The voltage and current values measured by this design method and the load current waveforms were compared with the actual values and waveforms measured using the power meter, with results indicating that this measurement system has speed and accuracy in measuring the parameters of the ship power distribution board. The research results reflect the advantages of this design method in the application of measuring and displaying ship power grid parameters. Additionally, the experimental results show that the method of controlling LCD display based on DSP is simple in hardware structure, easy to implement, and more efficient and practical in LCD display control.
Source: Internet
To facilitate better learning for everyone, Changxue Electronics has specially added a public account for microcontroller and EDA, pushing related knowledge daily, hoping to assist your learning!