LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

counter of pulses from an incremental rotary encoder on Arduino digital I/O

Hi, I too am facing a similar problem,I tested my encoder using simple Arduino code and its working fine,In Labview its kind of lagging or say labview arduino interface is quite unable to keep up with the pace.Still i managed to run the basic version of the code successfully.The bigger problem arises when i try to run the code in a complex program.It just doesn't work .Can somebody please review my code and help me out.I have attached codes for the simpler as well as the complex programs

Download All
0 Kudos
Message 11 of 14
(874 Views)

Hi Vijay,

 

your smaller VI runs the LIFA part as fast as possible, but the MajorProject puts a 100ms wait function in the loop and runs IMAQ code in the very same loop. No wonder the LIFA part executes slower…

 

Use parallel running loops to process LIFA and IMAQ independently!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 12 of 14
(871 Views)

The problem occurs even when i assign 1ms wait on both files.Sorry that i didnt mention this earlier in my post.But yeah,let me try with parallel loops.Thank you for your help.BTW the process is not slow in case of majorproject.vi it is actually faulty i.e the encoder doesn't increment the counter in a proper manner when rotated(it doesn't go beyond 2 and sometimes decreases when it is supposed to increase)

0 Kudos
Message 13 of 14
(865 Views)

Hi Vijay,

 

are you sure your "encoder decoding" code is working the way you expect it to work?

You read pin6 and sometime later you read pin7. For a "good" AB(Z) encoder you need to read both pins at the same time!

(By the time you read pin7 the encoder might have moved further so the comparison of pin7 with pin6 may fail.)

 

I don't use LIFA but is there no encoder reading function? Can you implement the encoder counting part using the Arduino IDE and transfer just the encoder counter using serial communication?

 

Btw. clean up your code (even AutoCleanup will do) and NEVER hide the labels of control/indicator terminals in the block diagram…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 14 of 14
(861 Views)