electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
 Forum index » DIY Hardware and Software » Microcontrollers and Programmable Logic
PIC Wave generation
Post new topic   Reply to topic Moderators: State Machine
Page 1 of 1 [10 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
gby



Joined: Jan 23, 2020
Posts: 3
Location: Belgium

PostPosted: Thu Jan 23, 2020 11:35 am    Post subject:  PIC Wave generation Reply with quote  Mark this post and the followings unread

Hey everyone,
So I'm an enginnering student and we have a project where we have to build a PIC processor based Bass Synthisizer. We are only in the brainstorming phase for now and I was thinking:

Do you think it would be smarter to create a PWM square wave signal for the wave generation from the PIC and then put it through certain analog filters to make other waves or to make the initial wave a PWM based Sine wave and then filter it for different wave shapes?

Thanks already Smile
Back to top
View user's profile Send private message
Grumble



Joined: Nov 23, 2015
Posts: 1294
Location: Netherlands
Audio files: 30

PostPosted: Thu Jan 23, 2020 2:33 pm    Post subject: Reply with quote  Mark this post and the followings unread

A sine wave thru a filter is only more or less attenuated, to hear the filter doing its thing you have to have a wave with a spectrum containing a lot of frequencies like a square, pulse, triangle or saw-wave.
_________________
my synth
Back to top
View user's profile Send private message Visit poster's website
blue hell
Site Admin


Joined: Apr 03, 2004
Posts: 24079
Location: The Netherlands, Enschede
Audio files: 278
G2 patch files: 320

PostPosted: Thu Jan 23, 2020 2:35 pm    Post subject: Reply with quote  Mark this post and the followings unread

Hi gby & welcome

What PIC do you have in mind and on what frequency will/can it run?

And .. smarter than what Rolling Eyes

_________________
Jan
also .. could someone please turn down the thermostat a bit.
Posted Image, might have been reduced in size. Click Image to view fullscreen.
Back to top
View user's profile Send private message Visit poster's website
Electric Druid



Joined: Mar 13, 2012
Posts: 44
Location: UK

PostPosted: Fri Jan 24, 2020 6:20 pm    Post subject: Re: PIC Wave generation Reply with quote  Mark this post and the followings unread

gby wrote:
Hey everyone,
So I'm an enginnering student and we have a project where we have to build a PIC processor based Bass Synthisizer. We are only in the brainstorming phase for now and I was thinking:

Do you think it would be smarter to create a PWM square wave signal for the wave generation from the PIC and then put it through certain analog filters to make other waves or to make the initial wave a PWM based Sine wave and then filter it for different wave shapes?

Thanks already Smile



Given that this is a "bass synthesiser", I read that as "ignore aliasing"! That makes life a lot simpler. All you need to do is choose a PIC that can output audio at a reasonable quality and generate the waveforms. Beyond that, the algorithm is entirely up to you. Personally, I'd recommend something with a genuine DAC on the chip like the PIC 16F1765 (10-bit DAC). That doesn't sound like much, but for a VCO replacement where the waveform is always at maximum volume, it's not actually half bad! I did my PIC VCDO using an 8-bit PWM output (e.g. much worse quality) and that has still been a successful chip. Ok, it's not everyone's cup of tea, but it has it's own character and is not so noisy as to be unusable by any stretch. The 10-bit DAC chip will be a marked improvement over that.

When you're struggling with Flash memory for your waveforms, remember that most waveforms are symmetric from one half to the other (rotationally, often), and some (sine wave) have symmetry that means you only need to store a quarter waveform. This saves no end of program memory, and let's you get an unfeasible amount of waveforms into a very tiny chip!

This piece by Jet Holt about the development of the Frequency Central Chronograf might give you a few ideas:

https://jetholt.com/chronograf-its-about-time/

HTH,
Tom

References:
https://electricdruid.net/voltage-controlled-digital-oscillator-vcdo1/

_________________
Electric Druid Synth and Pedal DIY website
Back to top
View user's profile Send private message
gby



Joined: Jan 23, 2020
Posts: 3
Location: Belgium

PostPosted: Sat Jan 25, 2020 8:09 am    Post subject: Reply with quote  Mark this post and the followings unread

Blue Hell wrote:
Hi gby & welcome

What PIC do you have in mind and on what frequency will/can it run?

And .. smarter than what Rolling Eyes


Hey, thanks Smile
I have a PIC18F25K. We haven't decided exactly on the frequency range we want the synth to generate.

But now that you mention it, I'm starting to think maybe we won't be able to generate low frequencies as a sine wave anyways because the lowest clock speed we can choose is a 31.25kHz and even with the 1:256 prescaler we will have 122Hz minimum. So I guess we will have to go with a Square wave from the beginning.

Yeah since I'm new to this, I thought perhaps there was already a rule of thumb about the initial shape you generate because of this or that reason that I didn't know about. So that's what I meant by smarter I guess Very Happy
Back to top
View user's profile Send private message
gby



Joined: Jan 23, 2020
Posts: 3
Location: Belgium

PostPosted: Sat Jan 25, 2020 8:32 am    Post subject: Re: PIC Wave generation Reply with quote  Mark this post and the followings unread

Electric Druid wrote:
gby wrote:
Hey everyone,
So I'm an enginnering student and we have a project where we have to build a PIC processor based Bass Synthisizer. We are only in the brainstorming phase for now and I was thinking:

Do you think it would be smarter to create a PWM square wave signal for the wave generation from the PIC and then put it through certain analog filters to make other waves or to make the initial wave a PWM based Sine wave and then filter it for different wave shapes?

Thanks already Smile



Given that this is a "bass synthesiser", I read that as "ignore aliasing"! That makes life a lot simpler. All you need to do is choose a PIC that can output audio at a reasonable quality and generate the waveforms. Beyond that, the algorithm is entirely up to you. Personally, I'd recommend something with a genuine DAC on the chip like the PIC 16F1765 (10-bit DAC). That doesn't sound like much, but for a VCO replacement where the waveform is always at maximum volume, it's not actually half bad! I did my PIC VCDO using an 8-bit PWM output (e.g. much worse quality) and that has still been a successful chip. Ok, it's not everyone's cup of tea, but it has it's own character and is not so noisy as to be unusable by any stretch. The 10-bit DAC chip will be a marked improvement over that.

When you're struggling with Flash memory for your waveforms, remember that most waveforms are symmetric from one half to the other (rotationally, often), and some (sine wave) have symmetry that means you only need to store a quarter waveform. This saves no end of program memory, and let's you get an unfeasible amount of waveforms into a very tiny chip!

This piece by Jet Holt about the development of the Frequency Central Chronograf might give you a few ideas:

https://jetholt.com/chronograf-its-about-time/

HTH,
Tom

References:
https://electricdruid.net/voltage-controlled-digital-oscillator-vcdo1/


Firstly, thanks a lot this looks really helpful.
Secondly, we already have a PIC18F25K from our other classes so we thought we would just use that. It has a DAC module but it's only 32 steps so I guess it wouldn't really be very high quality.

We are allowed to use analog filters after the digital wave generation, so i guess we could still smooth it out if it's not good enough. But what we had in mind from the beggining was to use the PWM module.

Thanks a lot for the tips as well, I think I might be updating this post when we have some more progress as well Smile
Back to top
View user's profile Send private message
Electric Druid



Joined: Mar 13, 2012
Posts: 44
Location: UK

PostPosted: Sat Jan 25, 2020 4:11 pm    Post subject: Re: PIC Wave generation Reply with quote  Mark this post and the followings unread

gby wrote:


Firstly, thanks a lot this looks really helpful.
Secondly, we already have a PIC18F25K from our other classes so we thought we would just use that. It has a DAC module but it's only 32 steps so I guess it wouldn't really be very high quality.

We are allowed to use analog filters after the digital wave generation, so i guess we could still smooth it out if it's not good enough. But what we had in mind from the beggining was to use the PWM module.

Thanks a lot for the tips as well, I think I might be updating this post when we have some more progress as well Smile


If you've only got a 5-bit DAC, you'd be better off using the NCO to produce a PDM output, rather than using a PWM output. You just use the NCO in "fixed pulse width" mode and then the frequency increment sets the density of output pulses. This provides a higher output frequency and smoother output than PWM usually manages. I've had 2 MHz output at 16-bit resolution instead of 10-bit at 32.5KHZ, for example. It makes a big difference.

HTH,
Tom

_________________
Electric Druid Synth and Pedal DIY website
Back to top
View user's profile Send private message
gabbagabi



Joined: Nov 29, 2008
Posts: 651
Location: Berlin by n8
Audio files: 23

PostPosted: Wed Jan 29, 2020 4:49 am    Post subject: Reply with quote  Mark this post and the followings unread

NCO? PDM? WTF? Shocked
Never hears about that (new) feature,
very interesting indeed!
cheers
Back to top
View user's profile Send private message
ian-s



Joined: Apr 01, 2004
Posts: 2669
Location: Auckland, New Zealand
Audio files: 42
G2 patch files: 626

PostPosted: Thu Jan 30, 2020 12:24 am    Post subject: Reply with quote  Mark this post and the followings unread

NCO => PDM? very interesting.

I found this app note but it looks like you found a less complicated way of doing it.

Do you use the technique in any of your published projects Tom?
Back to top
View user's profile Send private message
Electric Druid



Joined: Mar 13, 2012
Posts: 44
Location: UK

PostPosted: Wed Jul 22, 2020 2:07 pm    Post subject: Reply with quote  Mark this post and the followings unread

ian-s wrote:
NCO => PDM? very interesting.

I found this app note but it looks like you found a less complicated way of doing it.

Do you use the technique in any of your published projects Tom?


Sorry, haven't been back around here for while, so I've only just seen this.

Yes, the STOMPLFO uses this for its output.

The NCO module on some of the newer "enhanced" 16F PICs has a "Pulse Frequency" mode. Basically this produces a short fixed pulse every time the NCO wraps around. Since how often the NCO wraps around is directly related to how large the Frequency increment is, you've got output pulses whose density is related linearly to the frequency increment. Since the frequency increment on the chips is 16 or 20-bit, you've got a lot more resolution than you'd typically get with PWM. And the clock frequency is much higher too, since the NCO runs at the instruction rate or some fraction of it, so MHz. This makes the subsequent filtering much less demanding. You can get lovely clean LFO waveforms out of the STOMPLFO with only a RC lowpass.

It's great. I don't think it's what they had in mind for the NCO module, but it does a good job and it's much better than the PWM modules.

I think there might be some 18F chips with two NCOs too - am yet to look into that, but it sounds good if true.

Tom

PS: DSP-G1 chip used the same technique on a completely different processor (NXP LPC800 series) as far as I know.

_________________
Electric Druid Synth and Pedal DIY website
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic Moderators: State Machine
Page 1 of 1 [10 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » Microcontrollers and Programmable Logic
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2009 by electro-music.com - Conditions Of Use