7/23/2023 9:57 AM | |
Joined: 9/9/2016 Last visit: 8/17/2024 Posts: 23 Rating:
|
I have written a small SCL program to create a ramp function. I use the 1Hz signal (M0.5, SecPulse in my program) and do a rising edge detection by checking if the 1Hz signal is high, AND during the previous cycle the signal was low. At the end of the program ClockBuffer (the "previous cycle signal) is set to the 1Hz signal. The relevant part of the code is attached. When I put this block in OB35 (100ms cycle time), it works, although for one or the other reason it runs 5 times faster than it should. I fixed that quick and dirty by simply making the time increment and PV increment 5 times smaller. When I put it in OB34 (200ms) or OB33 (500ms) it doesn't run at all, the sequence isn't executed even once. At least in OB34 it should still work, as the 1Hz signal is high for 500ms so at least for two cycles. I don't see any explanation why it doesn't work at all in OB34, does anyone spot an obvious mistake? AttachmentRampfunction.txt (353 Downloads) |
Last edited by: kellydekoninck at: 07/23/2023 12:45:26 |
|
7/24/2023 3:53 AM | |
Joined: 1/11/2019 Last visit: 8/6/2024 Posts: 747 Rating:
|
Hello Kelly, In CFC, you need to be sure the Cycle interrupt that your program is executed in it is more faster than the signal to sample.In case of M0.5 that is a positive edge in each 1 second, OB35 with 100ms sample time is ideal. In your case. I think you are missing the positive trigger! Hence, Kindly use R_TRIG as a positive edge detector from CFC library. R_Trig Location: CGC Library > ELEM_300 > All Blocks > R_Trig [FB8: Recognition of Positive Edge] And, The below thread might helpo you to some extent. |
Follow us on