- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This one may be a simple question to answer. I am interested in generating tones, much like notes on a piano, that I can use in a program that I am writing.
I am not asking anyone to write the code for me, just point me in the right direction - using Creator 3.0 - and off I will go, writing code and making beautiful (hopefully) noises from a PSoC4.
If it works with the PSoC4 Pioneer Kit - even better, because that's what I am using for my 'dev kit'.
Thanks.
James
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There is a WaveDAC-component that sends a pre-defined table to a digital-to-analog converter using DMA. Getting harmonic tones is a bit more complicated, but here's the hint: Two half-toned differ by the factor of the 12th root of 2 from each other.
There was a project shown recently generating random tones, you may watch it here. http://www.cypress.com/?app=forum&id=2492&rID=86654
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is an approach that may be of interest, basically an IIR filter
with + fdbk. Keep in mind table lookup suffers from limited speed.
The approach, however, needs more work to be flexible, but for
simple tone generation suitable.
http://www.cypress.com/?app=forum&id=2492&rID=87059
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Bob,
If you are referring to the WaveDAC8... I am not sure that that works. Have you (or anyone else) actually used it with a PSoC4?
I get compile errors.
Plus, looking at the Device Selector - the PSoC3 and the PSoC5LP have 8-Bit DACs in their columns... the PSoC4 does not.
I believe that the WaveDAC8 will not work with the PSoC4, but I may be wrong.
Thanks for the suggestions so far. It looks like it isn't as simple as my last microprocessor I was using... or I may be overcomplicating it.
Regards,
James
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
PSoC4 is a rather small device, use PWM instead under CPU-controll to generate tunes or use a PSoC5 with DMA
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
PSOC 4 is more than adequate to do tone generation. Its has DACs, and you can still do table
lookup generated tones with no DMA, just use timed ISR which sets sample rate, hence frequency.
And using table lookup you can do tones with complex harmonics. SAW, TRI, RAMP......
Or use its fast single 32 bit multiplier and do a digital approach. Or the IIR approach mentioned
earlier. Note multiplier allows modulation, and then there is the approach Kamil is using on forum
yielding very complex tones, JLS1 on forum. Karrplus Strong approach.
Regards,. Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is a project Kamil did for PSOC 4 -
http://www.cypress.com/?app=forum&id=2492&rID=87511
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The WaveDAC8 component relies on DMA, and the PSoC4 doesn't have any of that. So you need to do this manually.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
PSoC4 is insufficient resources to produce audio but
Pioneer-Kit can do it, it has a Extra great PSoC5LP.
Did you see this thread?
http://www.cypress.com/?app=forum&id=2492&rID=86654
There are many actual samples and YouTube video
However that sound is so random and fuzzy.
Last sample is able to control the PSoC5LP from PSoC4 capsense.
I do not recommand Wave-DAC
It is too young, it has stall soon when I used it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is a very simple approach to tone generation, classic table lookup.
Could be driven by timer and ISR to control freq. In this example, 48 Mhz clock
sine wave = 12.5 Khz
#include <project.h>
const uint8 sinetable[ 32 ] = { 127, 152, 176, 198, 217, 233, 245, 252,
254, 252, 245, 233, 217, 198, 176, 152,
128, 103, 79, 57, 38, 22, 10, 3,
0, 3, 10, 22, 38, 57, 79, 103 };
uint8 sineptr = 0;
int main()
{
/* Place your initialization/startup code here (e.g. MyInst_Start()) */
IDAC8_Start( );
/* CyGlobalIntEnable; */ /* Uncomment this line to enable global interrupts. */
for(;;) {
IDAC8_SetValue( (uint32) sinetable[ sineptr++ ] );
if ( sineptr == 32 ) sineptr = 0;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
HW looked like this -
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you wrote code in ASM probably much higher freq and/or use a
finer (bigger) sine table at same freq.
There are many methods of generating tones, and with the onboard single
cycle multiplier filter (IIR) / modulate them.
PSOC 4 has plenty of resources for tone generation and modulation.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
To generate an instrument type tone (a basic type only, you need more for high quality simulation)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is a third way to generate sine, via PWM. Note I used
a UDB, you could have used timer/PWM block instead.
So in short 3 methods -
1) Table lookup to DAC
2) IIR with + fdbk to DAC
3) PWM to pin/RC filter
And of course always classical methods using the OpAmps, Wien Bridge,
BiQuad.......
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Not exactly what you are looking for, but for another idea:
You may be also interested to check out the PSoC 4 1-bit audio example from the 100-projects-in-100-days initiative here:
Cheers,
Antonio
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
And Jim,
I almost forgot - here's another PSoC 4 audio example (a theremin) from the 100-days initiative.
This one uses a PWM to generate tones/notes. In fact, in 'Discrete' mode, the theremin actually plays the notes of a scale!
The firmware should be well commented and pretty instructive.
All the best, and let us know how your piano sounds!
Antonio
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dana,
Thanks for working on this. The last example you posted using the PWM component works very well for what I need it to do.
I will probably add a for loop, and use that to play 5 different tones, and I'm done.
Thanks again.
Regards,
James Jackson
Oztronics
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
One additional thought on this.
The PWM approach has the biggest drawback of harmonic distortion,
and requires more stringent LPF filtering than a table lookup or IIR
approach.
Regards, Dana.