- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have generated triangular and sawtooth waveforms in Psoc 5LP and I am varying the frequency using Putty and using PWM_WritePeriod(). I want to change the frequency from Putty without using PWM Write Period. Can anyone tell me how to?
I have attached the zip file with both the codes. Please help!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Another way to change frequency is to change the frequency of the clock that feeds the PWM, using something like _SetDivider(...)
The drawback of this approach is poor precision at higher frequencies. For example, starting from MASTER_CLK=24MHz, and using 256 points per 1kHz waveform, the divider is 24E+6/256/1000=93.75 (approx.94), which is less than 7 bits already!
Better way to generate waveforms is to use DDS approach
PSoC5-Simple-Sine-WavePSoC5-Simple-Sine-Wave-Generator-using-DDS-and-DMA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Depending on your application your might be better off by using a WAVEDAC.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Another way to change frequency is to change the frequency of the clock that feeds the PWM, using something like _SetDivider(...)
The drawback of this approach is poor precision at higher frequencies. For example, starting from MASTER_CLK=24MHz, and using 256 points per 1kHz waveform, the divider is 24E+6/256/1000=93.75 (approx.94), which is less than 7 bits already!
Better way to generate waveforms is to use DDS approach
PSoC5-Simple-Sine-WavePSoC5-Simple-Sine-Wave-Generator-using-DDS-and-DMA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>> Better way to generate waveforms is to use DDS approach
>> PSoC5-Simple-Sine-WavePSoC5-Simple-Sine-Wave-Generator-using-DDS-and-DMA
... which is nowadays integrated in the WAVEDAC component. It also includes a nice editor as you can see in the attachment
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
pacr,
The WaveGenLT and WaveDac8 utilize different approaches to output waves (e.g. sine). The WaveGenLT has fixed clock output rate irrespective to wave output frequency (DDS approach), while WaveDac8 uses a fixed number of samples per wave period (e. g. 256), and variable sampling clock. The consequences are the following:
1. With WaveGenLT, the output wave frequency can be tuned with 32-bit precision, roughly 0.01Hz using 48MHz BUS_CLK. The WaveDac8 output accuracy is limited to whatever clock is attached to it. For example, to make 1kHz sine with 256 samples/period and 48MHz BUS_CLK, requires clock divider 187.5, which is not round. Therefore closest output frequencies which could be achieved are 1002.7Hz or 997.3Hz, but not 1000Hz! It gets only worse at higher frequencies.
2. The WaveGenLT can produce sine waves with up to 100kHz output frequency with reasonable harmonic content (<40dB). The WaveDac8 with 256 samples/period starts skipping samples and becomes unusable above ~17kHz.
3. The WaveGenLT allows wave parameters (amplitude, shape, frequency) on-the-fly. It was specifically developed for MIDI music playing, where all parameters are constantly changing to produce musical tones. The WaveDac8 is less flexible, and doesn't expose underlying RAM buffer through the API.