06-27-2024 10:28 PM
Hi! Currently I am trying to write multiple samples through all my 4 Analog Output channels and 4 analog input channels. In order to verify that my samples read are same as the value written, I added a section of code to write those values in a text file to allow me to compare the the values. However, I noticed that only analog input 0 read values inconsistently with it's written values. Other channels were perfectly fine. I did not touch the connections of the wiring before, and the values were quite accurate based on my old tests. So i was wondering if there is any issue with my python code. I connected my ports in a closed loop manner, where ao0 =ai0, ao1=ai1 and etc. Could anyone help me on this please? ( I was actually using Jupyter notebook)
06-28-2024 07:18 PM
I would recommend using Test Panels to check if there is any problem on the wiring or hardware.
06-29-2024 08:51 AM
This is probably a very subtle timing issue, pretty deep down in the details. One thing I noticed was that AI0 at sample i+1 would tend to match (or at least very nearly match) AI1,2,3 at sample i. This suggests that AO0 sample i is not quite "there" yet at the instant that AI0 sample i gets captured, but that it *is* still there at the time of sample i+1.
How can this be? Well here's a very recent post I made in another thread that addresses much of it. However, your situation is slightly different with multiple AI channels on a multiplexing device where only the 1st channel in the list seems to be skewed by 1 sample. So I would emphasize points 3 or 5 I made in that linked post. Point 4 may have relevance, but point 3 or point 5 would be the likely fix.
-Kevin P
07-02-2024 10:32 PM
Hi thanks for your reply!
For point 3, I have tried out your suggestion to set AI0 to sample at falling edge, but values are still mismatched.
For point 5, I do not know how to to implement a delayed counter clock AND also used it in my context.
And also, i plan to integrate this whole functionality of multi-channel-multi-sample-read/write in my other code. So to give some context about the big picture of what I am doing,
I am trying to create a GUI for the python code to allow me to manually adjust the analog output and input pins in a GUI on a separate window (python code attached). You can say that it should work like an oscilloscope. So i would like the option of manually control each individual analog output ports, as well as controlling all 4 analog output ports simultaneously like what we have discussed in this post. So i were to tamper with the timing by implementing a clock counter, I cant visualize in what ways does the rest of the program affected.
07-03-2024 03:13 AM
I tried to create a counter to replace it as my clock source, but it pops up this error. (Code attached). I even gave a 100seconds timeout yet it still failed.
Error:
07-03-2024 06:59 AM
I really don't know python, but your AI and AO config generally look pretty good. I'd probably explicitly set the AO active_edge to RISING just to be sure. There are 2 other minor problems however and then we'll get to the show-stopper.
1. With your counter task supplying the sample clock for AO and AI, you should start AO and AI tasks first so they're armed and ready and will be in sync when you start your counter task.
2. Your counter task needs to configure its timing, much like AO and AI. I don't know the exact syntax under Python, but you'll want to specify IMPLICIT timing and I probably FINITE sampling with the same # samples SAMPLES_PER_CHANNEL
All that said, I think your overall big picture goal might be doomed if you're hoping to have independent simultaneous control of individual AO and AI channels. There's only 1 timing engine available for any and all AO and similarly only 1 for any and all AI. You have to deal with all your AO and AI channels *collectively*. You can't just write new data to 1 AO channel while the others continue what they were doing, you'd have to write data to *all* of them.
While theoretically possible to manage this process in a way that mostly seems like independent control (but with unavoidable latency due to buffers being written and transferred), it'd be a pretty tall order to get it working right.
But maybe I'm misunderstanding what you want. Maybe you just need to operate discretely for bursts of finite samples, with plenty of user-involved setup time in between runs. Something like *that* would be much more readily manageable.
-Kevin P