07-12-2024 09:02 AM
Hello,
I'm currently using the NI USB-6259 DAQ to provide voltage I/O to another device. Most of this is done with a LabVIEW program just setting and reading voltages, while I have a Python script generating a sin wave as an output on pin AO3. The problem is, whenever the LabVIEW I/O stuff is running, the wave appears flattened.
This happens ONLY when the LabVIEW program is running, no matter what calls the Python script. But I don't mention AO3 at all in my program, so I don't see how any of the I/O stuff could possibly interfere.
Correct Wave:
Wrong Wave (while my VI is running):
Any advice would be greatly appreciated.
Solved! Go to Solution.
07-12-2024 09:30 AM
Just to confirm, you share a hardware resource between two programming languages?
How many AO tasks can your device handle ?
07-12-2024 09:42 AM
Yes, I'm using the same DAQ device with both LabVIEW and Python, just not the same pins. There are 4 separate channels for AO, all of which I'm trying to use. AO0-AO2 are just setting basic DC voltages.
07-12-2024 11:16 AM
Most of these USB DAQs can only handle 1 task. That is, you can make an Analog Input task in LabVIEW and run it, but you are then precluded from making another AI task either in LabVIEW or any other programming language while it is running. This is due to the number of timing engines in the device. If you are already using the AO in LabVIEW, you cannot make another AO task in Python, even if it is a different channel. You only have so many resources and they cannot be shared.
07-13-2024 05:29 PM
Finally looked at your code. Since on the LabVIEW side it looks like you are doing software timed output, you should be able to handle multiple tasks. Looking at your scope traces, it looks like the frequency is shifted to lower frequencies, rather than being "flattened".
Your LabVIEW code leaves a lot to be desired:
07-15-2024 09:07 AM
This is my first LabVIEW project, so I'm not very familiar with the software. Sorry if I'm a little slow.
1. I'm assuming this can be fixed with the JKI state machine.
2. I suppose they don't - I'll take them out of the loop.
3. Why 100ms?
4. I thought Python would be better since I'm more familiar with it and I need the wave to be configurable. Specifically, I need the user to input the DC vertical shift, while the amplitude is a function of that shift. I couldn't figure out how to do that with a DAQ Assist.
5. I'm not very familiar with state machines. It looks like JKI provides more control over the loop, but I can't tell if it allows configuration of the wave itself.
Thanks.
07-15-2024 10:41 AM
@scout3682 wrote:
1. I'm assuming this can be fixed with the JKI state machine.
You can download it form VIPM, I'll see if I can whip something together quickly.
@scout3682 wrote:
2. I suppose they don't - I'll take them out of the loop.
If you have a State Machine, you can respond to an Event, like the value changing, then initiate a change, They can still be in a loop.
@scout3682 wrote:
3. Why 100ms?
There is overhead with each DAQmx call, 100 ms is a good compromise.
@scout3682 wrote:
4. I thought Python would be better since I'm more familiar with it and I need the wave to be configurable. Specifically, I need the user to input the DC vertical shift, while the amplitude is a function of that shift. I couldn't figure out how to do that with a DAQ Assist.
Look in the example finder. Unless you need to use Python, I suggest staying with one Programming language, either all Python or all LabVIEW.
@scout3682 wrote:
5. I'm not very familiar with state machines. It looks like JKI provides more control over the loop, but I can't tell if it allows configuration of the wave itself.
You make a state that configures the wave.
07-15-2024 12:21 PM
Attached is a quick example of your original program in a JKI State Machine. Download JKI State Machine from VPIM in order to run modification.
07-16-2024 08:51 AM
The program works great. Even while running the Python script, the wave looks exactly the same. Thanks!
07-16-2024 10:43 AM
Glad it's working. It is trivial to add some states so you can do the output in LabVIEW also. You should give it a try.