LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Urgent Help!!

Solved!
Go to solution

Hi! I'm desperately trying to find some way to read a PWM value from an Arduino pin. I have heard that it can't be done in LIFA, but is there any way to do it in LabVIEW at all?? I'm on a super tight schedule so if anyone can help me, that would be amazing!

0 Kudos
Message 1 of 12
(6,098 Views)

Or maybe can I add a pulsein() line in the LIFA code...is that possible? And if so, how would I read the pulsein() value in LabVIEW?

0 Kudos
Message 2 of 12
(3,916 Views)

You can certainly add the pulse in fuction to the toolkit.  You will need to make a new case in the LIFA firmware with a new command byte that calls the pulse in command and uses Serial.Write to send the appropriate number of bytes.  Then make a VI that uses the Send Receive VI to send the command byte and read the correct number of bytes as a response.

You may want to start with something simple like adding your own digital read VI.  It already exists in the toolkit so you will have 'the correct answer' to check your work against.

Good luck.

-Sam K

0 Kudos
Message 3 of 12
(3,916 Views)
Solution
Accepted by aks.cristion.filwr

I wrote this up based on the little experience I gained adding encoders to LIFA.  My only real experience is with v1.3.0.29 but this one is for 2.1.1.69.  Let me know if it works or not.

Download All
0 Kudos
Message 4 of 12
(3,916 Views)

Hey Nathan,

I think that should work - I don't have the hardware to test it set up but it looks ok.

Kevin Fort
Principal Software Engineer
NI
0 Kudos
Message 5 of 12
(3,916 Views)

Thanks a ton! I tested the code and I'm getting a number, but it's bouncing around without me moving my motor

0 Kudos
Message 6 of 12
(3,916 Views)

If you run the code just on the arduino -taking LIFA out of the picture and just print the results to the serial port do you see the same behavior? In other words is it something with the pulsein function or is it something with how the toolkit is handling the data and passing it back.

Kevin Fort
Principal Software Engineer
NI
0 Kudos
Message 7 of 12
(3,916 Views)

I have 4 encoders. I tested each of them with a basic pulseIn() code and they all still bounced around a bit. Below are snips of the code I used along with a sample output from each of the 4 encoders I used:

Enc1.JPG

Enc2.JPG

Enc3.JPG

Enc4.JPG

0 Kudos
Message 8 of 12
(3,916 Views)

These numbers seems consistent with what was showing up in LabVIEW, so I would think the code is working perfectly (thanks, Nathan!!)

0 Kudos
Message 9 of 12
(3,916 Views)

Hey, so I'm getting a 5003 error with the pulsein vi. I get it every once in a while and I'm not sure why. Not it's hurting my code tho...the pulsein vi updates so fast that it slows everything down, so I have it in a case structure and it only updates when I press a button. With the 5003 error popping up again, once I press the button, the code won't leave the case structure. I'm assuming it's because the pulsein vi isn't closing, but I'm not sure.

Can you help?

0 Kudos
Message 10 of 12
(3,916 Views)