1 Overall structure of the system
Figure 1 is a schematic diagram of the structure of the distributed power supply control system.
This system uses a C51 single-chip microcomputer and an external CAN controller SJA1000. It transmits control constants to multiple lower computers below, and analyzes and calculates the data sent by the lower computers after collecting them to change the constants. Nodes CAN1~CAN31 (up to 31 nodes) are the control parts of each single power supply. We use TI's TMS320LF2407 chip as the main control, which integrates the CAN controller module.
Among them: CAN0 node is the host computer.
2 Introduction to LF2407 and its integrated CAN control module
LF2407 is a fixed-point DSP processor launched by TI. It adopts high-performance static CMOS technology, with a power supply voltage of 3.3 V and an instruction cycle of up to 25 ns. It integrates multiple peripheral modules and memories including CAN controller, which is suitable for the control of motors and inverter circuits.
The CAN controller module is a 16-bit peripheral module integrated in LF2407. The module has the following features:
(1) Supports CAN2.0B protocol, standard identifier (11 bits) and extended identifier (29 bits), and supports data frames and remote frames.
(2) It is equipped with 6 mailboxes, 2 receiving (0, 1), 2 sending (4, 5), and 2 configurable (3, 4); the data length of each mailbox is 8 B. The receiving mailbox can perform identifier masking. When the identifier bit is masked, there is no need to check the identifier bit when receiving the data frame.
(3) It has programmable bit timer, interrupt service and CAN bus wake-up function.
(4) It can automatically reply to remote requests and has an automatic resend function when a transmission error or data loss occurs. Each mailbox register contains 7 words of information, similar to the control registers of each functional module. LF2407 assigns a fixed data memory address to it. For example, mailbox 0 has the following register assignment:
MBX0A~D (4-word storage space) Address: 7204~7207 Where: The identifier (set as 29 bits) is in the
last 13 bits of MSGIDnH and MSGIDnL.
3 Hardware circuit design and debugging
When designing the CAN communication circuit of LF2407, one problem should be noted, that is, the power supply voltage of 2407 is 3.3 V, and the high level output of its CAN control module is only 3.3 V, which is incompatible with the CAN driver PCA80C250 level (5 V). When designing the circuit, pay attention to it when adding isolation optocouplers. Figure 2 shows the CAN communication schematic diagram on the lower computer side.
Since the output optocoupler of TX adopts the emitter output mode, our output optocoupler should use 6N136 (137 cannot meet the requirements due to its structure). Figure 3 is the voltage waveform across R42 obtained when we test data transmission (output 10101010...)
From the settings of the bit configuration register BCR1 of the CAN communication controller, we know that in the time period occupied by each bit of data, our sampling point is at the 70% time point, and the output voltage at this point must be within the set value range of the rated high and low levels. We selected R42 = 5 kΩ to obtain the above waveform, which satisfies the high level ≥ 3.5 V and the low level ≤ 1.5 V at the sampling point.
4 Communication protocol and software implementation
In the system, the upper computer sends operating settings and start and stop signals to the lower computer, and will periodically query the operating status of each single machine to adjust its status accordingly.
The specific communication process is divided into two categories:
(1) The upper computer transmits operation commands and settings to the lower computer. The upper computer sends a data frame.
After the upper computer sends the data frame, if the lower computer receives the data frame, it sends a confirmation frame to the upper computer, and the data frame transmission ends. If the transmission fails, the upper computer does not receive the confirmation frame after waiting for a period of time, and then automatically resends the data frame.
(2) The upper computer queries the operating status and various record settings of the lower computer. The upper computer sends a remote frame.
The remote frame only contains the data type but no data content. After receiving the remote frame, the lower computer transmits data to the upper computer according to the data type required by the upper computer. At the same time, it waits for the confirmation frame of the upper computer. If the confirmation frame is not received, it will be resent regularly.
In this system, standard frames are used for communication, that is, 11-bit identifiers are used. The definitions of each bit are as follows:
ID0~ID4: node identifier, 5-bit node identifier can enable the network to accommodate 32 nodes.
ID5~ID7: data type, there are many types of data to be transmitted, and the uploaded data frame stipulates 7 types (including confirmation frames). Correspondingly, there are 6 types of remote frames for downstream transmission, and 6 types of data frames for downstream transmission. At least 3 bits of identifiers are required to determine the data type.
ID8~ID10: frame count, the data type with the largest amount of data contains 17 words of data, and each frame can transmit a maximum of 4 words, so this type of data requires at least 5 frames to transmit. The data frame needs to be counted to determine the specific type of the transmitted data, so at least 3 bits of identifiers are required to determine the frame count.
Since LF2407 has a dedicated CAN module interrupt, and a dedicated CAN interrupt flag and mask register are designed in the CAN control module, it is very convenient to use the interrupt method to start the CAN controller to receive and send data.
When setting the CAN controller, you need to enable the change data request bit CCR first, and restore it after the change. It is worth noting that many register bits in TMS320LF2407 need to be cleared to "0" by writing "1", and some bits can only be read and cannot be directly rewritten by the program. For example: the flag bit MIFn (0~5) for the mailbox interrupt (including receiving and sending) should be cleared after entering the interrupt response, but this bit is a read-only bit. The user program can only clear it by writing 1 to the TAn bit of the TCR register (for the sending mailbox) and writing 1 to the RMPn bit of the RCR register (for the receiving mailbox).
5 Functions implemented
by this communication system include: fixed value transmission (data frame transmitted from the upper computer to the lower computer):
(1) Time synchronization: data specific to hours, minutes and seconds.
(2) Transmission of operation settings: including flashover parameters (flashover coefficient KSP, given spark rate SPARK_NUM), charging parameters (given peak value Up, rise rate RISE-NUM, charging time limit Ton-max), discharge parameters (average voltage Vg, average current Ig, discharge time limit Toff-max).
(3) Protection settings: including open circuit parameters (voltage, current, delay), short circuit parameters (voltage, current, delay), undervoltage voltage, delay, overload current, bias excitation, IGBT temperature, oil temperature, etc.
(4) Channel parameters: including primary current, output voltage and current, IGBT temperature, oil temperature, input current (three-phase), DC voltage.
Operation setting query (host computer sends remote frame): including system status, fault record, operation setting, protection setting, channel coefficient, etc.
6 Conclusion
This system has been debugged. In our initial one-to-one system (host computer with 1 control system), it can resist strong interference and work normally under large transmission data volume.