Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

How to compare audio signal to 300KHz sawtooth for PWM output?

I am creating a sawtooth wave with the frequency based on my loop speed and I want to compare an audio signal to that sawtooth wave in order to create a PWM signal. The sawtooth wave needs to running at 300KHz or faster. I have tried several methods and seem to be stuck. The vi I have attached shows my attempt to send the audio signal into the 9205 A/D module (runs at 421 ticks) out of a digital module and then back in through a digital module for comparison. I don't believe this works correctly because now I am comparing my sawtooth against a digital TTL signal instead of a sinewave???

 

MOD 2 9403

MOD 3 9403

MOD 4 9401

MOD 5 9205

 

 

0 Kudos
Message 1 of 13
(4,817 Views)

Here is the vi. Also I have tried several other methods and this seems to be the fastest method to generate a sawtooth that I have been able to think of. If you have any ideas on how to possibly transfer the data from the 9205 to the loop with the sawtooth without slowing it down that would be perfect.

 

Thanks,

Dane Miller

0 Kudos
Message 2 of 13
(4,816 Views)

Hi Dane,

 

Have you looked into this example?

 

Let me know if that's what you're looking for.

 

Thanks,

Dan Richards
Certified LabVIEW Developer
0 Kudos
Message 3 of 13
(4,796 Views)

I have looked into that example, but the sawtooth doesn't seem to be the problem. Its a matter of trying to put an audio wave into the loop with the sawtooth without slowing it down to far. It seems that whenever I put anything analog with the sawtooth it can no longer run at 300KHz + due to how slow the modules can write. I was also thinking of maybe putting a wave file in the FPGA memory, but that doesn't seem like an easy task. Do you think there is a way to get the audion signal into the loop while maintaning the freq of the sawtooth?

 

Thanks,

Dane Miller

0 Kudos
Message 4 of 13
(4,794 Views)

The vi I have posted is giving me the desired result with a sinewave. I was hoping to figure out a way to get the audio from the outside.

0 Kudos
Message 5 of 13
(4,792 Views)

Here are the attachments, the goal is to find a way to replace the sinewave with an audio signal?

 

Thanks,

Dane Miller

Download All
0 Kudos
Message 6 of 13
(4,788 Views)

Hi Dane,

 

Would you mind taking screenshots? Also it would help if you added just a few minor comments to your code to help clear up what's doing what.

 

You are correct to assume that there is no way to speed up the module. There might be a way to use parallel loops but that would depend on exactly what your needs are. Would you mind explaining a little more about your application and what your ultimate goal is?

 

Thanks,

Dan Richards
Certified LabVIEW Developer
0 Kudos
Message 7 of 13
(4,765 Views)

Dan,

 

Thanks for the replies. My application is for a class D audio amplifier and my part is to make the PWM signal that will go into switches to amplify and go out a filter. Therefore I need a sawtooth running around 300KHz + to compare to an audio input wave. The document I have attached explains my coding and shows my desired result. If there is anyway to send an audio signal into the 9205 module and then some how be able to read the data at a rate close to 9 ticks (40MHz clock rate) that would be ideal. I have tried a lot of different strategies and I am stuck, thats why I am here. Also if I can't put the audio data coming from a 9205 in a loop that runs at my desired rate then is there any examples of writing and reading music files from the computer into FGPA memory? Let me know what strategies you have in mind. I have about ten days to solve the problem.

 

Thanks

Dane Miller

0 Kudos
Message 8 of 13
(4,755 Views)

Dan,

 

Another question I have on top of the previous message is when you send an audio signal into the A/D module does it decrease in amplitude as frequency increases or is that only the case for the D/A? I sent a signal into the A/D and out of the D/A and saw that as I increased the frequency of my signal the amplitude decreased. So I was hoping to get an understanding of which module may be causing this.

 

Thanks,

Dane Miller

0 Kudos
Message 9 of 13
(4,737 Views)

Hi Dane,


Are you looking to use audio that has been sampled at 40MHz? I think CD quality audio is about 48 kHz. So if you take a .wav, save it to your RT target, use the ****** VI to extract its waveform data (array), index that array, send the indexed data to the RT FIFO, read the RT FIFO from the FPGA chip, convert to PWM signal in the FPGA, and then output it, that might be an option.

 

By the way, if you look at the LV help document entitled, "Conversion Timing for the NI 9205/9206 (FPGA Interface)," you'll see that the maximum conversion rate should be 8ms if you want to maintain module accuracy with the 9205. That would give you 125kHz (very fast) of audio signal sampling.

 

We do have solution ideas to get you 40MHz of audio sampling if that's definitely what you need, so keep me posted on that.

 

I look forward to your reply.

 

Thanks,

Dan Richards
Certified LabVIEW Developer
0 Kudos
Message 10 of 13
(4,736 Views)