I am utilizing C-Script to realize a counter, I set the frequency at 10kHz, however,my result shows that my counter works at a double speed.
And my code is as follows:
static int count2=0;
if (IsMajorStep)
{
if(InputSignal(0, 0) >0.6&&InputSignal(0, 0)<=0.9)
{
count2++;
}
if(count2>=600){
OutputSignal(0, 0) =1;
}
else{
OutputSignal(0, 0) =0;
}
}
I reckon that the counter will reaches the peak value every 0.6 seconds ,but in fact,the conter reaches the peak value every 0.3 seconds, so what’s wrong?