Rorrog Posted June 10, 2023 Share Posted June 10, 2023 I am started in this, I usually schedule with PLCs, and I need to make a pulse counter block, but I fail to define the variable with a rise or decrease flank. example: Var.count_1 = 0 Var.count_2 = 0 Var.Habilitacion = 0 while(1) If (Var.habilitacion >= 1) Var.count_2 = Var.count_2 + Var.count_1 Endif Endwhile When var.counter_1 is 1, the application does not count from 1 in one if not in several numbers with respect to the PC scan. The difference in the application that will use an input as an accountant instead of a variable. Var.count_1 = CO_0 for exaple. Thanks for the attencion. Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted June 12, 2023 Share Posted June 12, 2023 A couple things: 1) I recommend against using var. notation. This is left over from very old ( > 15 years) releases of DAQFactory. Instead use variable declaration. So: global count_1 = 0 global count_2 = 0 global habilitacion = 0 while(1) if (habilitacion >= 1) count_2 = count_2 + count_1 endif endwhile 2) you have an infinite while() loop without any delay. This script will use a lot of CPU power, most of which will be wasted. I suggest adding at least a delay(0.01) before the endwhile. As for the rest, the script looks fine. It will loop forever and whenever habilitacion >=0, it will increment count_2 by count_1. Quote Link to comment Share on other sites More sharing options...
Rorrog Posted June 13, 2023 Author Share Posted June 13, 2023 Thnaks, I try It... BR Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.