2/2/2020 11:52 PM | |
Joined: 8/22/2011 Last visit: 4/26/2025 Posts: 48 Rating:
|
So I have this problem with HSC in S7-1200 firmware V4.2. In the CV=PV interrupt routine there are 3 steps. In each step I set a new PV value. In the step 3 when HSC reaches 1000 I reset the counter with "EnCV". Encoder has 1000 pulses so all 3 steps happens in one encoder revolution. Code can be found on the pictures in the attachment. Problem is that HSC does not always resets. As it does not accept EnCV command and keeps counting beyond 1000. But it accepts new PV. It happens randomly In Cyclic interrupt I call CTRL_HSC and reset the EnCV and EnPV commands. Maybe not the smartest idea to call CTRL_HSC in cyclic interrupt but I have tried to put this piece of code from second picture in Main OB. The same situation is happening. I have tried playing with input filters, Cyclic OB time and so on... nothing helped. This is so strange to me because it worked so well on firmware 3.x I'm doing something wrong but I don't know what. I'm missing some basics on how PLC functions obviously. AttachmentDesktop.zip (402 Downloads) |
2/4/2020 2:00 PM | |
Joined: 8/22/2011 Last visit: 4/26/2025 Posts: 48 Rating:
|
Hi, this actually helped. I put the OB30 priority to highest possible (24) and 0B200 to default priority 18. Now I cannot get HSC to make this error again and... it works! Also I removed p_trig instructions from OB30. In the attachment parameters of OB30 and OB200. I'm not sure if Nr of events to be queued makes any difference.
Today I realized it is not always true actually. Sometimes it does accept NwPV and does not reset, sometimes NewPV is stucked at 1000 (Step 2) and does not reset. But in most cases it does accept NewPV and doesn't accept NewCV.
This machine will not run fast (60-80rpm max) and I think that maybe putting the whole code in Main OB with execution of around 2ms would not pose a problem. The whole code is not large, there are just few pushbuttons, one reversing motor, encoder and optical sensor so execution would probably be 1-2ms, 3ms the most.
AttachmentDesktop1.zip (385 Downloads) |
Last edited by: Mark_F at: 02/04/2020 14:03:24Last edited by: Mark_F at: 02/04/2020 14:03:57Last edited by: Mark_F at: 02/04/2020 14:07:21 |
|
2/4/2020 5:51 PM | |
Joined: 3/16/2015 Last visit: 10/10/2021 Posts: 1250 Rating:
|
These forums suck sometimes and it deleted my what I wrote. So, glad to know you figured it out. The attache archive will show the use of :P to immediately write to a physical output (and input if you want). You can search for it in the manual to read more. There's another tag that is SET to indicate the change of motor state and update your code so that your code doesn't continue to run the motor. The first tag is for immediacy and the second is to update the code. Cheers AttachmentHSC_Forums.zip (391 Downloads) |
Last edited by: Kal.A at: 02/04/2020 17:51:57 |
|
Follow us on