Frequency change of waveform

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Andrew7
Level 3
Level 3
25 sign-ins 10 questions asked 10 replies posted

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!

0 Likes
1 Solution
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

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 

 

View solution in original post

0 Likes
4 Replies
pacr_284376
Level 5
Level 5
100 replies posted 10 solutions authored 50 sign-ins

Depending on your application your might be better off by using a WAVEDAC.

0 Likes
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

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 

 

0 Likes
lock attach
Attachments are accessible only for community members.

>> 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

0 Likes

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. 

0 Likes