From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW RT programming

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.

0 Kudos
Message 1 of 4
(2,727 Views)

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?

0 Kudos
Message 2 of 4
(2,708 Views)

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?

 

0 Kudos
Message 3 of 4
(2,695 Views)

Hi mmehrabin,

 

- 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?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 4
(2,664 Views)