I am coding an RT program on cRIO. I have a DC motor that contains a disk on its shaft. This disk has a hole to detect its rotation speed. The rotation speed is obtained by an optic sensor. If we store the time of two consecutive hole detection by the sensor, their difference is the period and we can calculate the angular velocity. The sensor is connected to NI 9401 digital module on the cRIO and for the calculation, we should detect the rising edge of the sensor output. I wrote code that works but at very very low speeds. This algorithm works properly on FPGA. I think I have a mistake in RT and scan mode approach.
A single VI for a cRIO project isn't entirely helpful.
I did notice you brought up the scan engine. How slow is "very very low"? Numbers are key here rather than vague terms that have different meanings to different people. Keep in mind the scan engine runs at 1kHz. Are you hoping to go faster?
Thank you so much for your reply. You are right. I should give the numbers. When its rotation period is 600 ms, it can not detect the rising edge. With 1kHz, could not it detect the rising edge at this speed? As the motor specification, its period is 16ms in its max speed. Which kind of programming do you suggest on cRio? Just FPGA? Is there any solution to coding in RT?
- use a counter instead of checking for rising edges on your own: some DIO modules can be configured to provide several functions like DI/DO/PWM/CTR…
- why do you need to compare a boolean value with TRUE? Rube-Goldberg alarm… 😄
- why do you set your loop with a 1MHz clock and 1000µs instead of 1kHz clock and 1ms?