Pages: [1]   Go Down
Author Topic: Flexible PWM including phase control of multiple channels  (Read 748 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hello, sorry if this has been covered before, but the search function fails me. I would like to do mulitple pwm oscillators off of an uno. The oscillators need to be locked in frequency, but able to have different "start points". Therefore, they would be out of phase with each other. The idea is to make something like a CMOS melody generator:

I figure if I have full flexibility of the oscillators, I can combine as many pwm channels as I want to make complex digital waveforms, sequences, or even just clock or trigger signals for other devices. Therefore, I need frequency control, pulse width control, and a phase (or start point delay) function.

I'm unsure whether I would attenuate each channel separately using a potentiometer or a VCA in the case of the waveform/melody generator. Yet, if it was able to be done in the microcontroller and give an analog output, I feel that would be superior.

Can anyone help point me in the right direction? so far, the pwm articles i've read say little about creating out of phase pwm channels. I feel like the tlc5940 is a good start since it'll give a max of 16 channels. Then I could make a 16 step analog sequencer with the same device! I'm not sure if the best approach is a ton of conditional statements or ________?

first microcontroller project if it isn't obvious smiley

thanks,
nate
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

right around minute 4 of this video shows a CMOS project doing basically what I'd like to do with a microcontroller. It uses multiple square waves attenuated separately to control an oscillator. Project page at the cat girl synth site.

Logged

Dubai, UAE
Offline Offline
Edison Member
*
Karma: 21
Posts: 1670
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
No sure what your trying to do from the description, but the sounds in the video are easily achieved with Arduino.

Have a look at the Auduino, its two independently controlled triangle wave oscillators synched by a third oscillator (kind of).

Here are some examples -

http://rcarduino.blogspot.com/2012/08/adding-audio-to-arduino-projects.html

As I say, I am not sure what you are after, but in my experience when you try to mix together many square waves its a bit like mixing colours - it all turns to brown.

Duane B

rcarduino.blogspot.com
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I appreciate your reply. the sounds in the video are not inherently what i'm after, it's the piece sending the voltage control to the oscillator that I want. Maybe it's best visualized with pictures.

Here's a stepped wave from the web:


I'm only interested in the positive going side of the wave. Therefore, I would view that as 4 PWM waves in frequency sync with each other, but each with varying pulse width, amplitude, and phase. I would like to manipulate each pulse on its own to go from simple clock signals all the way up to complex waveforms that would of course have to be fined tuned on the user's end with a scope to be musical smiley-wink
Logged

UK
Offline Offline
Shannon Member
****
Karma: 184
Posts: 11164
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm only interested in the positive going side of the wave. Therefore, I would view that as 4 PWM waves in frequency sync with each other, but each with varying pulse width, amplitude, and phase. I would like to manipulate each pulse on its own to go from simple clock signals all the way up to complex waveforms that would of course have to be fined tuned on the user's end with a scope to be musical smiley-wink

It sounds as if you're trying to approximate a DAC, and doing that with multiple PWM signals doesn't seem a particularly obvious way to achieve that.

What sort of sampling frequency do you want to achieve on the output? What sort of resolution do you need to achieve on the amplitude?
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I need to be able to use the individual pwm signals for triggers and gates in a synthesizer for creating funky rhythms and the like. I haven't got as far as amplitude resolution since I figured I could do that after the fact if needs be by attenuating each channel. I'm mostly concerned with getting the pwm waves out of phase and pulse width controllable. so that I can do something like this:

I'm viewing this as 4 different waves locked to the same frequency, but out of phase with each other. I want control over the pulse width and phase so that I can change it subtly like this

or I could fine tune it so that the waves align themselves like a low bit rate stepped wave into audio frequencies, as a step sequencer, or as a melody generator sending CV to an oscillator.
Logged

Dubai, UAE
Offline Offline
Edison Member
*
Karma: 21
Posts: 1670
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Its easy enough to do with DDS, you could even use the Auduino as a starting point, the two triangle waves are easily converted to square waves, you could also easily output them on two seperate pins rather than mix them on a single pin.

Phase and pulse width are also easy enough, in fact the triangle wave is a really good base for variable pulse width - I will let you figure out how and why.

This project uses DDS to generate four simultaneous waveforms - it isn't exactly what you want but has a lot of explanation and the code is fully commented for you to adapt -

http://rcarduino.blogspot.com/2012/08/the-must-build-arduino-project-illutron.html

Duane B
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ok, cool. had considered wavetable synthesis for my needs, but thought it was too complex for what I wanted to accomplish. I'll have a go at that and see what I can come up with.

if someone else has an idea using the timer registers and some alternate thinking, I'd gladly hear it.

thanks
nate
Logged

UK
Offline Offline
Shannon Member
****
Karma: 184
Posts: 11164
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That is starting to look a bit like a serial data stream and if your modulation patterns are simple enough, perhaps you could achieve them as a bitstream.

Failing that, I remember reading about an Arduino tone generator project which worked on the basis of a timer triggering at a frequency which was suitable higher than the frequencies of all the tones that needed to be generated and just toggled the outputs high and low at the appropriate times. I'm sure that Googling for Arduino tone generator would find it for you.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Pages: [1]   Go Up
Jump to: