Using a High-Speed Counter’s Hardware Interrupt to Peripherally Write to lớn an output đầu ra on a Siemens 1200 PLC
Zachary Gracia
0 Comments
The built-in high-speed counters on Siemens PLCs are very useful for applications in which a machine needs to lớn move material a specified distance. In these instances, the scan time of the program can showroom inconsistency khổng lồ this distance.
Bạn đang xem: Operation of the high
Reduce this inconsistency by using a built-in hardware interrupt associated with high-speed counters. Reduce the variance due lớn a program's scan time by passing a reference point lớn the high-speed counterand peripherally writing to lớn the desired đầu ra bit.
This tutorial demonstrates how lớn set up a high-speed counter interrupt, peripherally write to the desired output, và set its reference point in the PLC.
Setting up the High-Speed Counter Interrupt
khổng lồ set up a reference interrupt for a high-speed counter, go khổng lồ the device configuration of the PLC. From there, navigate khổng lồ the high-speed counters tab and select the desired counter. From here, select event configuration and kiểm tra the box for Generate interrupt for counter value equals reference value event. Checking this box will autogeneratean sự kiện name and priority. khổng lồ specify the OB that this interrupt will call, press the button that contains the …on the far right of the configuration window. Pressing this button will open a dropdown that allows the programmer lớn either select a preprogrammed interrupt or tocreate a new one specifically for this event by using the add new button located on the bottom right of the drop-down.Peripherally Writing to an đầu ra in the Interrupt
The code used in the interrupt is not all that complicated in this specific instance, but there are a few things that you should keep in mind when implementing it.
The main functionality is in network one, and all it does is writethe đầu ra bit low if it is already high. The important thing to lưu ý with this section of code is how the bit is written low. To lớn peripherally write to that output, the tag needs to lớn be followed by :P.
Following the tag with :P will immediately write the output bit low instead of waiting until the creation of the process image. This is how the variability due lớn the scan time is eliminated. The output is immediately written low when the condition is met, instead of waiting the variable amount of time from when the condition is met in the program, và the scan reaches the point in which it writes lớn the outputs.
The second thing to chú ý in this interrupt is contained within the second network. Cảnh báo that in this network, a global bit is mix high. The reason that this is necessary is that depending on when this interrupt is triggered, lô ghích in the main code may overwrite the peripheral write.
To avoid this, the output đầu ra is buffered by this global bit. Whenever the output đầu ra would be written, it is preceded by a normally closed gate tied khổng lồ this global variable. This ensures that if this interrupt is triggered, there is no way the output đầu ra can be written high unless the status bit is written low again.
Xem thêm: Phim Cấp 3 Mới Nhất, Hay Nhất Năm 2020, Thể Loại Phim 18+ Âu
One last important thing to cảnh báo is that this status bit is only written high during this interrupt. The main program writes it low again when it has been high for a quarter of a second.
This is more time than is needed but it ensures that the main logic reaches the point where it would have written this output low by itself.
Setting the Reference Point for the High-Speed Counter
Now that the interrupt has been configured, the reference point for the interrupt must be phối in the main program. This is done by using the CTRL_HSC function block.
For this implementation, there are three crucial inputs.
The first is the HSC input. Pass the hardware ID to this input toconnect this block lớn the desired counter. The IDs for the high-speed counters can be found in PLC Tags > System Constants. The next input of importance is the NEW_RV input. This is the value the counter will use as a reference to lớn trigger the interrupt. It is important to cảnh báo that this input is a Dint data type, so some conversions may be necessary. In this situation, the stop position was being tracked in milimet as a real. Khổng lồ convert it the desired position it was first divided by a pre-calculated milimet per count, & the result of that was converted into a Dint. This Dint value can then be passed to the NEW_RV input of the CTRL_HSC block. The last đầu vào of importance for this application is the RV input. This is a Boolean input that sets the counter’s reference value whenever it is set lớn high. The program can constantly be updating the reference value passed khổng lồ this block, but that value will only be set if this RV đầu vào is high.Conclusion
This tutorial is not an overly complicated example of how to use a high-speed counter’s reference interrupt, but it shows some key details và methods needed lớn write lớn PLC outputs peripherally. I hope that the information presented here will be helpful in your future endeavors.
Learn more about DMC'sSiemens S7 PLC Programming services. Or,contact usto get started on a project today.