LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

NI SPDIF Input Module

Has anyone tried to use the NI SPDIF Input Module? I already checked the document, but still, I am having troubles making it work. It doesn't read a 48 KHz signal with a 7831R board.
 
Thanks for any suggestions.
 
0 Kudos
Message 1 of 14
(4,984 Views)
Hi Falcon,
 
How does it not work?  What happens?  Are you sure that you have the signal connected to the right pin?  Your signal should be connected to Connector0/DIO7.
 
-Justin D

Message Edited by Justin D on 12-06-2006 06:22 PM

0 Kudos
Message 2 of 14
(4,968 Views)

Hi Justin,

The NI SPDIF module does retrieve the pulses lengths of the SPDIF signal, it does not take into account that the first pulses retreived are usually wrong, and bases all of the pulse lenght manipulation based on this. Unless, there is some extra hardware out there manipulating the signal, besides just being conditioned.

And of course, I am sure that the signal is properly connected to the right pin. Finally, one chooses which DIO pin to be the input by selecting it in the FPGA I/O menu.

Regards.

0 Kudos
Message 3 of 14
(4,952 Views)

Hello Falcon,

Are you compiling your FPGA code for a FPGA clock frequency of 80 MHz instead of the default 40 MHz? The timing values used in the pulse length decoding are based on a 80 MHz clock tick. At 80 MHz the pulse lengths in 48 kHz S/PDIF should be around 13, 26, and 39 clock cycles. Therefore the code uses cutoffs of 20 and 33 clock ticks to differentiate between the three different pulse lengths.

What are you using for your S/PDIF signal source? What is the purpose of your application?

Since the original code that was developed a couple of years ago, we have moved the example to use the LabVIEW FPGA Single Cycle Loop which simplifies and reduces the code a bit. I have attached a LabVIEW 8.0 project with the updated files.

 

authored by
Christian L, CLA
Systems Engineering Manager - Automotive and Transportation
NI - Austin, TX


  
0 Kudos
Message 4 of 14
(4,933 Views)
Christian,
 
Thanks for your feedback, and the new code. I already tried it, and unfortunately, it didn't work. I does the same as the previous version of the code. It does output noise. Of course, I compiled the software with a 80 MHz clock, and I know that the SPDIF signal comes in a 48 MHz sample rate. I attach a picture of what I get after retrieving the information. Also, I know that there is audio in the signal which I am using, because I already checked it with a SPDIF reader (stereo) and could listen to the audio. Moreover, I already checked the signal that is being hooked to the SCB68 and I can see the frames with their proper headers (in the proper format) with an oscilloscope.
 
The SPDIF signal comes from a DCT box (used for demodulating cable at home) and it comes in a -0.5 V to 0.5 V range. I amplified and then conditioned the signal to hook it to the SCB68 that is connected to a PCI7831R. At the DIO1, I get a SPDIF TTL signal.
 
Regarding your second question, the purpose of my application, is to test 10 seconds of the SPDIF signal coming out of any DCT, for which I am evaluating the usage of the FPGA boards.
 
Finally, I have tried to develop my own SPDIF reader, based on the pulse length readers exmples, and when I do a simple pulse length reading, I get the proper pulse lenghts of the SPDIF signal, which outputs almost the same results as yours, 20 and 35 (you get 33) are the cuts for differentiating the lengths of the pulse. However, when I add case structures inside the while loop in order to build the frame the frames, I start getting different pulse lengths readings. They do increase! I don't know how to deal with this.
 
Thanks for your time,
 
0 Kudos
Message 5 of 14
(4,918 Views)

I have two suggestions to try.

In regards to developing your own SPDIF reader; when you only measure the pulse lengths you get the proper readings, but as you add more code to the loop the readings changes and become incorrect. This is most likely a result of the extra code slowing down the loop and causing it to not run fast enough to read each pulse. Using a regular While loop in LV FPGA, each function block you use takes up at least one FPGA clock cycle. In addition the While loop has an overhead of two FPGA clock cycles. So assuming you have a While loop with 5 consecutive functions it will take 7 clock cycles to run each iteration of the loop. If you were to use this loop to measure the pulse length it would give you a measurment with a resolution of 7 ticks, i.e. the pulse length would be 7, 14, 21, 28, etc. As you add more code to this loop the length of each iteration increases and the resolution of the pulse width decreases. In order for us to adequately measure the width of the pulses in the SPDIF signal we need to have a loop iteration time of less than 6 or 7 clock cycles (about half of the shortest pulse we want to measure). This is the reason why the original SPDIF code is set up in three different loops and the first loop that measures the pulse width is kept very simple. It also uses pipelining to further reduce the time of each iteration and we compile the FPGA for a 80 MHz clock rate to get more clock cycles per pulse. I think in your code as you add the Case structure and additional code, you are increasing the loop time above the necessary limit.

One 'easy' solution to this problem is to use the Single Cycle Timed Loop (SCTL) instead of the While loop. This loop is processed differently by the compiler so that all of the code inside the SCTL is executed in one clock cycle. (The SCTL was not available in LV FPGA when the original SPDIF code was developed, otherwise we would have used it then.) So in the updated SPDIF code we use the SCTL and can include all of the SPDIF processing in one loop. There are some limitations on the code that can be included in a SCTL. Information about the SCTL and optimizing FPGA code can be found in this prsentation (Advanced FPGA Programming). I think if you convert your code to the SCTL (right click on the While loop and chose Replace with Timed Loop) you should be able to measure your signal correctly.

Getting back to the SPDIF code I included on my last post. This code does work correctly on my end with a SPDIF signal coming from a Soundblaster sound card. This signal has two raw audio channels with 20-bit data per channel. The 4 AUX bits in the SPDIF packet are not used. I have logged the data to file and can load the file using the Reader VI included in my last post. To play the sound back on a regular sound card in LabVIEW I have to resample the data to 44.1 kHz and then use the upper 16-bits of the 20-bit audio signal. I'm attaching a sample file of logged data on this post that you can open and play back using Read SPDIF Data File.vi.

Is there a chance that the audio data in your signal is formatted differently? Could it be using 5.1 or 6.1 encoding with DTS or Dolby?

authored by
Christian L, CLA
Systems Engineering Manager - Automotive and Transportation
NI - Austin, TX


  
0 Kudos
Message 6 of 14
(4,908 Views)

Hi Christian,

Thanks for your suggestions. Still, the NI SPDIF code doesn't work for me. I still get the noise, whose picture I attached in a previous post. I tried the "easy" solution and it is giving me better results, but not totally satisfied, because I am reading a bunch of consecutives zeros (25 pulse lengths) without any reason.

Regarding your last question, yes!, it is possible that my audio is formatted into a different way, but unfortunatley, I have no way to find out which one it is 😞

I will give it a try to the "easy" solution and hope that it works.

Just one more question, if I have another question, do I still post to this thread in order to contact you?

Thanks for your time and support,

 

0 Kudos
Message 7 of 14
(4,851 Views)

If the question is related to SPDIF, please post it in this thread. If it is an unrelated question then please start another thread. By posting this information in the discussion forum, hopefully other people reading here will also benefit and may not have to post similar questions in the future.

Is there a chance that you can take a picture of the raw signal (oscilloscope style) and post it, or can you collect a binary file of the raw data in your signal that is generating the noise you hear and post it? The image of the noise signal is not detailed enough for me to be able to tell much from it.

Message Edited by Christian L on 12-12-2006 09:02 AM

authored by
Christian L, CLA
Systems Engineering Manager - Automotive and Transportation
NI - Austin, TX


  
0 Kudos
Message 8 of 14
(4,831 Views)
Christian,
 
I am attaching a sample data file which I get with the second version of the NUI SPDIF software. The file is binary, I just changed the extension from bin to txt.
 
Also, I do have a question. Is there any synchronization in the software with the input signal coming in? I mean, do you search for a header in order to start building the frames? I don't understand what you do in the first part. The point is that when I start the program, the signal is already running.
 
I already tried synchronizing my software with the SPDIF signal, but the more stuff I add to the Timed While Loop, the more likely, it will not compile, which at the end, it happened.
 
Thanks for your time,
 
 
0 Kudos
Message 9 of 14
(4,819 Views)

Christian,

I must add something very important. I tried to condition the signal as much as possible and I know that it is not as clean as I would like to, but I took a while to condition it in order to keep the SPDIF information when I hook it up to the SCB68. That is, I get sometimes a value, still greater than 33, after getting the LONG PULSE, which means the start of a pulse. For example, I can get, 34, 40, 13, 14, 26, 26, 26, ..., 25.

Regards,

 

0 Kudos
Message 10 of 14
(4,819 Views)