LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

counter digital

Solved!
Go to solution

Maybe try doing it the other way - set up the LabVIEW code to generate the square wave and see how that looks on your oscilloscope?  That might show whether the LabVIEW loop is running as fast as you expect.  Other than that I don't have any ideas.  Check your time units?  If I remember correclty, the last time you posted a question that I answered, part of the problem was that you labeled a control as milliseconds even though it actually displayed seconds.

0 Kudos
Message 11 of 27
(1,187 Views)

Hi,

 

For High Frequency, you need a hardware counter.

 

Try reading this:

NI 9401 used as an 8 port digital counter?

 

Best Regards,

Luis A. Mata C.
Ing. Electrónico
Whatsapp: +58-414-1985579
BBM Pin: 2B83E99A
Thanks: Kudos
0 Kudos
Message 12 of 27
(1,179 Views)

nathand,i generated the pwm with the next code which i found in this forum:

https://decibel.ni.com/content/docs/DOC-11079

 

i can generate square wave until 500Hz, is it enough to see how fast i can work with a square wave or should i generate a square wave with a timed loop in labview as you said me and watching how fast it can run?

 

which time units should i check?i just have comparers, maybe my code in labview is so long and labview doesn´t have enough time to run it with dt=1ms?

0 Kudos
Message 13 of 27
(1,165 Views)

I don't know what else your LabVIEW code is doing because you've only uploaded images, not VIs.  (Before uploading code, clean up the wires - in your images, you have wires with lots of unnecessary bends.)  If your code is only the loop that you showed, then there should be no problem running at 1ms on a cRIO.  If there is a lot more code, try taking it out and run the counter loop on its own.  You can also look at the "Finished Late?" timed loop terminal to see if the loop can't keep up.

 

I still think it would be valuable to set up your cRIO to generate a square wave and look at it on the same oscilloscope, so you can see if the cRIO and your signal generator agree on timing (of course they won't be in phase, but that's fine).  You could connect an output from the cRIO to the counter input, then output a square wave in one loop and read it another to see they match.  At this point I'm just suggesting debugging approaches.  I suspect we're missing something simple here but I don't know what.  When you wrote earlier that at some frequencies it "doesn't work" can you be more specific?  Do you see no counts at all, or just not the right number?  What's the duty cycle of your square wave?

0 Kudos
Message 14 of 27
(1,158 Views)

the duty cicle is 50% , the frequencies which i said that the code doens´t work,is because the counter is all time in value =0

i am running only this code which i attach now

 

0 Kudos
Message 15 of 27
(1,155 Views)

i hope that you can see the code,i don´t know if i attached it well

0 Kudos
Message 16 of 27
(1,154 Views)

The logic of your code is fine (although it can be simplified, see image below).  I suspect there's an electrical problem with your setup, or you do not have the signal generator configured properly, or perhaps the voltage levels don't match what the board needs.  What steps have you taken to debug this on your own?  Did you try any of my suggestions?

contadorpulsos3.png

0 Kudos
Message 17 of 27
(1,144 Views)

i simplified the code and the same problem.

 

i generated a square wave as you said with the code ''GeneracionPWMtime loop'',and it works weel when i have dt=1ms.I attached it!

 

but there is one thing that i really don´t understand!!

 

when i generated a pwm signal with the atacched codes ''GeneracionPWM''(this code was copied of this link https://decibel.ni.com/content/docs/DOC-11079) and ''GenetacionPWM3'',i have the next results:

-with ''GeneracionPWM'' i was able to generate waves until 500Hz because i could watch it on my oscilloscope, well!

-with ''GeneracionPWM3'' i couldn´t watch the wave on my oscilloscope with frequency higher than 50Hz

 

so now I have the same problem which i had with ''GeneracionPWM3'', with frequencies higher than 50Hz the counter code 'contadorpulsos3' which i attached before,don´t work(count=0)

but when i tried frequencies lower than 50Hz it works well because the counter marks the correct number!!

 

what is wrong on my computer or my codes? why could i work with frequencies higher than 50hz when i copied that code, and when i tried to make it i can´t? all is saved in in the same folder!  i really don´t know why i have this problem!

 

thanks

 

 

 

 

 

0 Kudos
Message 18 of 27
(1,134 Views)

one important thing more:

i did a new counter but i deleted the case when the counter couldn´t increase its value 2times when dio4 reads two consecutive times that the signal is false,and the counter can work well at frequencies until 500Hz, but the problem is that i just want that counter increase its value one time when the siganl is false!!

so with this i could show that the problem is maybe that the code is so long and labview isn´t able to read it with dt=1ms, how could i find a solution for this?

 

the code is the next :

0 Kudos
Message 19 of 27
(1,124 Views)

The problem is (probably) that you can't loop as fast as 1ms (1kHz) which cause "under sampling" and bad measurements. Can't you put your logic in the FPGA instead?

 

//Ulf

0 Kudos
Message 20 of 27
(1,120 Views)