Generate complex signals

Hello,
is it possible to generate a complex signal composed by 3-4 subsignals like sawtooth, sine, square at different frequencies?
Can it be done making a sum of different PWM generated signals?
thank you! :slight_smile:

is it possible to generate a complex signal composed by 3-4 subsignals like sawtooth, sine, square at different frequencies?
Can it be done making a sum of different PWM generated signals?

For what purpose? How accurately? Anything's possible, if your timing requirements and accuracy requirements are low enough.

It's just a signal to be amplified later on 0-12v basis. It's a kind of signal composed by a sum of basic signals ad different frequencies.
I just need to know if it is possibile to generate with arduino PWM and amplify it later.

I would like to have complete control on the characteristics of that signal using software and leave the hardware the only job to amplify it.

How can be a software implementation? what are the accurancy limits of arduino outputs?

Before an answer is possible you need to properly 'flesh' out your generator specifications. Your project is only going to be as good as the specification for it is...
This unfortunately is meaningless

It's a What? kind of signal composed by a sum of basic signals ad different Range, duration and monotonic or mixed frequencies. and scripted, keyboard or externally controlled and by externally controlled what type of input is required and whether a serial link is necessary... is a simplistic outline for a set of comprehensive specs for an arbitrary waveform generator... Doess it need to 'encode' data and 'Generate a serial data stream as well?

???

Doc

sorry for my ignorance in this field :smiley:

I don't need code, I need just an indication on how to accomplish following tasks using PWM:

  1. generate a sine signal (with some charcteristics)
  2. generate a step signal (with some other charcteristics)
  3. generate a sawtooth (with some other charcteristics)
    ...
    ...

4.mix them up (sum)

  1. and finally have that complex signal as output of the Arduino board.

(I need a such a waveform generator :), is it possible to make it with Arduino?)

After that I imagine I will need to scale it (amplify) using an external source, because my system need an input signal 0-12v.
Thank you :wink:

  1. generate a sine signal (with some charcteristics)

What does "with some characteristics" mean? How close to a sine wave is the output supposed to be? What frequency?

because my system need an input signal 0-12v.

What system? Feel free to quit being mysterious.

There is an apparent disconnect here... Somehow.

D.

Sorry guys. I posted a simple question. I cannot say anymore because I'm part of an R&D project and I'm not authorized to say more. In this project I would like to use Arduino technology to make a first prototype because I trust is a good platform that is easy to learn and manage.
If you can help thank you, if you cannot thank you anyway.

The only way you are going to deal with the NDA is to do your own research. Start simple with a simple sinewave generator There is adaptable code found in a popular GLCD demo program used on Itead Studio's 3.2" displays... at least the math's for the sine function and the period of the waveform generated.
There are also many ways to make a ramp, the R 2R method comes to mind and a set of shift registers sufficient to the required number of steps
complex rectangular waveforms can be generated from simple array's and stored to program memory (Progmem), local eeprom (limited to 1K), external eeprom, SDcard...
Word generators are obvious.
My initial comments on your specifications are valid whether you are able to disclose information...
As to 'Disclosure, I'm quite sure that you could figure out a set of questions that might be answered without violating spirit or letter of the NDA... and in the process a better understanding of how the Arduino might be of value in solving your challenges.

Doc

if i was guessing, i think this is a "make my own synth" type of question.

fading leds, controlling motors, taking sensor readings dont make any sense when you mix the signal.

but producing a quality square wave, with controllable frequency, and mixing with sine waves is the stuff that all drum and bass evolves from!

it is one of my thoughts, but im happy flashing leds at the moment!

thank you!
yes it's the same as for music synthetizers!!

to be more precise what I need is a software "arbitrary waveform generator"
will Arduino be able to do that without any other hardware and using its own PWM output?

Hello Avafab : Yes.
Yes, the Arduino can make complicated waveforms. Mathematical and logical calculations can be written by you. The "normalization" of the sum that results from the calculation is important so the sum total of the signals does not exceed a magnitude which will "clip".

ysin = Asin(time);
ytri = B
wavetable(time);
ySUM = 0.5*(ysin+ytri);

ysin is a sine wave with peak 1 and minimum of -1
ytri is a "constant" triangle wave from a lookup table array of voltages from -1 to +1
ySUM is the normalized result of adding two waves , 0.5 is the normalization factor

Thank you AmbiLobe!!
yes perfect!

just a final question, are there any other built-in language commands for other basic signals?

sinusoidal = sin
wavetable = triangular ?
step = ?
sawtooth = ?
..

is "wavetable" command configurable to have many other forms using other tables? where can I find these tables?

will Arduino be able to do that without any other hardware and using its own PWM output?

Maybe.

Until you answer the questions on frequency, accuracy, etc., you'll have to settle for a definitive maybe.

Avafab asked:
"Are there any other built-in language commands for other basic signals?"
Yes, sinusoidal signals can have their phases changed using cos cosine. You can multiply signals using the * operator. You can add and subtract and invert signals using + - and *(-1).

Sawtooth can be produced using addition and modular math % operator. The % will keep the peak magnitude below a level :

ySaw = .005*((x++)%200);
When the x exceeds 200, the result falls back to zero and starts up the ramp again.

sinusoidal = sin
wavetable = triangular ?
step = ?
sawtooth = ?
..

is "wavetable" command configurable to have many other forms using other tables? where can I find these tables?

The wavetable is my proposed function that you will write.
The EEPROM memory can hold the wave tables that are prepared by a separate program.
You write the software, the tables are not prepared for you by elves.
You can calculate the sounds while listening to them, or you can pre-calculate wave tables on Monday, and listen to them on Tuesday after your production software is written to play the wave tables from EEPROM using scaling and normalization of time and magnitude. Linear interpolation of wave tables allows your custom software to play back one table at any speed so the musical pitch can be any pitch.

You sure you want to run this via PWM and not to use a D/A converter? If it's a synth it'll sound horrible with PWM I would think.

JarkkoL:
You sure you want to run this via PWM and not to use a D/A converter? If it's a synth it'll sound horrible with PWM I would think.

he did say he wanted some "character"

I'm pretty sure there was a demo of sine wave output. Try Googling that. Your limitations are the Niquist frequency from memory. With that limitation in mind you can read from a table containing any waveform you like and output it. The limit is going to be how fast you can read and shove out the data in your table. And how much memory you have to store it.

If you want to mix sine/triangle/etc. waves, which are analog, it doesn't make really sense to output them as PWM, which is digital. What you should be doing is to mix those signals on Arduino CPU and output the result to 8 pins at 44KHz for example, then convert that to analog signal (e.g. by using simple transistor/resistor setup for the 12V signal you were talking about).

Interesting task generating an "Even Tempered Scale".. The notes vary by the 12th root of 2 or about 1.059436%.

Doc