01-19-2022 09:10 AM
Hey there,
I´m trying to build a VI to implement a software-based SPI with a USB-6341.
With that programm wi want to write to a serial-in shiftregister and a serial-out shiftregister at the same time.
Therefore i want to digital-write at 3 lines and digital-read at 1 line on port 0.So at the end it can provide a clocksignal, chipselect, MOSI and MISO.
All these actions should be timed with the same clock to run read and write simultaneously.
I attatched the current VI so you can have a better idea of what i want to do.
In this example i tried to use the timing.vi twice, but I´m not sure wether the write and read actions are performed one after another or started in parallel just with the Sample Clock out of sync.
I'm rather new to LabVIEW and also to this forum, so please feel free to give me some tipps and tricks to place my questions more precisely.
I´m using the 64-Bit Version of LabVIEW 2020.
Vinc
Solved! Go to Solution.
01-20-2022 07:42 AM
unfortunately, you missed attaching the VI.
You can make a DO and DI task sync by sharing the sampling clock and using start triggers.
01-20-2022 08:32 AM
Thanks for your fast reply.
Something seems to went wrong with uploading the file.
Hopefully it's working now.
I'll try that out and give you some feedback when I´m back in lab.
Have a nice day
Vinc
01-20-2022 09:07 AM
This is the exact technique you need to implement- https://www.ni.com/en-us/support/documentation/supplemental/10/synchronization-explained.html#:~:tex...
01-20-2022 10:56 AM
That whole linked article is an excellent resource! I don't think I've read that all through before...
I've dealt pretty exclusively with systems and apps where I don't need the extraordinary fine detail available through careful config of the Sync Pulse and Reference Clock. I've been able to "get away with" merely sharing a sample clock signal and accepting the 10's of nanoseconds skew that might result.
I'll probably still often advocate sync via sample clock alone, but I'll be more likely to think twice before I do.
Note to OP: in santo_13's snippet, you would need to start Task 2 first so it's ready to receive and react to the 1st sample clock from the master task.
-Kevin P
01-25-2022 07:45 AM
Sharing the sample clock like you showed in your post is now working.
Now i got a problem with the aquisition of the output, when i shorted the write and read pins (line 2 as CLK_line and line 1 as MISO_line).
I expected the read-array to be the same as the write-array. The problem is, as you can see in the screenshot, that there is always the bit in the same position and also the bit in the following position recognized as "high". I tried to vary the sample rate and also the number of bits to write, but there was no difference.
It seems that the on-times in the output are a bit longer than it should be. That would explain, why there are always two bits "high", but i can´t measure when the aquisition exactly happens.
Does anybody know what's the reason for this issue and how to fix it?
Vinc
01-25-2022 10:47 AM
Only had a moment for a quick look and I fixed one thing -- making sure that the AO task is started *last* because it's the source of the shared sample clock.
-Kevin P
01-27-2022 06:40 AM
Many thanks for your help. Everything is working now.
Have a good day
Vinc