For C500-AD101: its settings are more flexible, but require an external signal source. The user needs to enter the "setting mode" by turning on the DIP switch of the corresponding channel on SW1, then sequentially entering the lower limit value (Offset) and upper limit value (Gain) of the analog quantity, and confirming through the onboard SW2 dip switch. This method allows users to customize the zero and full range of input signals, for example, mapping a non-standard sensor signal of 2-8V to the full range of 0-4095.
2. Output range setting
Taking C500-DA501 as an example, setting the output range is more intuitive. Each output corresponds to a set of DIP switches. For example, to configure channel 1 as a 4-20mA output, pin 1 of the DIP switch on the back board needs to be set to OFF, pin 2 to ON, pin 3 to OFF, and pin 4 to OFF. At the same time, it is necessary to ensure that all DIP switches corresponding to the voltage output range on the front panel are set to OFF to avoid mutual interference. Please note: If current output is configured, it should be confirmed that the load resistance does not exceed 750 Ω; If it is a voltage output, the load resistance should not be less than 10k Ω, otherwise it may cause a decrease in output accuracy or even module damage.
The soul of data exchange: IR/CIO bit allocation and READ/WRIT instructions
The data exchange method between C-series analog units and CPU units is the core difficulty in programming and the key to achieving efficient control.
1. Two working modes
Double word operation mode: This is the recommended mode for most large PLCs such as C500 and C1000H. In this mode, the CPU directly accesses the internal RAM of the analog unit by executing two dedicated instructions, READ and WRIT. This method is highly efficient, as a single instruction can transfer up to 127 words of data in bulk.
Four character operation mode: Used when the module is installed on the SYSMAC BUS slave rack or when the CPU does not support the READ/WRIT instructions. In this mode, the CPU interacts with four I/O words (such as n, n+1, n+2, n+3) assigned to the module through general-purpose instructions such as MOV. Although the programming is slightly more complex, it has better compatibility.
2. Analysis of IR/CIO bit allocation
Each analog unit will be assigned specific input and output words. Taking C500-AD501 as an example, it uses one word (such as n) as the output word from CPU to module, and another word (such as n+1) as the input word from module to CPU.
Key bits of output word (n):
Bit 03 (EEPROM write bit): When this bit changes from OFF to ON, the module will write all configuration parameters in the current RAM to the EEPROM, achieving power-off saving.
Bit 05 (high/low alarm reset bit): Used to reset the high/low alarm flag.
Bits 08-15 (Peak Hold Reset Bit): Used to reset the peak hold register of the corresponding input channel. Among them, Bit 07 serves as the "library selection bit", which can control whether these reset bits are for channels 1-8 or channels 9-16.
Key positions for input word (n+1):
Bit 00 (A/D busy flag): When this bit is ON, it indicates that the module is performing A/D conversion and should not initiate a new data exchange at this time.
Bit 07 (Unit Normal Flag): This is a square wave pulse signal that is 0.5 seconds ON and 0.5 seconds OFF. The CPU program can determine whether the analog unit is working properly by monitoring this pulse. If this signal disappears or the frequency is abnormal, it usually means that there is a serious fault inside the module.
Bits 08-15 (Peak Hold Confirmation Flag): As a response to the peak reset command issued by the CPU.
3. Practice of READ/WRIT Instruction Programming
These two instructions serve as a bridge to access the internal memory maps of intelligent units such as C500-AD501.
WRIT instruction: used to write configuration parameters or conversion data to the RAM of the module.
When writing a word: the data of this word will be written to the module's "pointer word" (usually address 12). This pointer word will determine from which address the subsequent READ instruction starts reading data.
When writing multiple words: the first word is interpreted as a temporary pointer, specifying the starting address for subsequent data writing to the module RAM. For example, to configure scaling parameters, the first word can be set to # 0047, followed by scaling upper and lower limit data for several words, thus completing the update of multiple parameters at once.
Read instruction: used to read data from a module.
The READ instruction always reads data from the address specified by the pointer word. Therefore, before reading, it is usually necessary to set the pointer through a 1-word WRIT operation.
A standard reading process is: ① Execute the WRIT instruction and write # 0000 to module address 12 (pointing the pointer to the starting point of memory). ② Execute the READ instruction to read, for example, 46 words, to obtain all key operational information such as conversion data, peak values, alarm flags, etc. for channels 1-16.