general question- PWM and resolution

hi all,

I haven’t visited this forum for a while and it’s good to see that it’s keep growing :slight_smile:

anyway, I have confused a few things so any help is welcome:

I’m working on a project where I need to output a variable voltage from 0-5V. I know this can be done with PWM. My questions are:

  1. What is the maximum resolution I can get for the voltage range?
    (It is important to work on 16 or 24 bit resolution as I need precise representation of the output voltage)

  2. Shall I start looking for other microcontrollers (PIC maybe) with better resolution, and if so any suggestions?

I know is a dump question but… ::slight_smile:

thanks,
warpie

PWM is not a real analog voltage signal. It’s simply HIGH and LOW, where it’s HIGH some percentage of the time. The “resolution” is how many different percentages (called duty cycles) you can select. The analogWrite() function takes numbers from 0 (never HIGH) to 128 (HIGH and LOW in roughly equal amounts) to 255 (always HIGH). So there you go.

You may want to look at trying to integrate a high resolution ADC chip of the type used in digial audio equipment. I have no experience with this one but it seems very inexpensive for what it does: http://www.futurlec.com/ADConv/TDA1543.shtml

Precision (resolution) and Accuracy (representation) are not the same thing. As already mentioned, it sounds like you want an ADC more than a PWM. In either case, simply having the resolution may not yield a more accurate result.

If your system has enough noise (in either the output signals or the power supply or from external sources), it doesn’t matter what resolution your output device has.

hi guys and thanks for your help.

I think some more info about the project will help…

I’m trying to build a MIDI to CV convertor for one of my analog synths.
That is :

MIDI note on/off - > arduino digital in - > arduino output 0 or 5V ->CV gate

MIDI note 0-127-> arduino digital in - > arduino output 0 to 5V →
CV in

The CV gate is ok as I only send 0 or 5V.

But for the CV input, 255 steps will give about 19mV of each step which is not what I would like to have as resolution.

Will external DAC give me better resolution than 255 steps?

thanks,
warp

Regarding the component posted by mem:

It is a 16 bit unit, therefore you should be able to step in units of 5v / (2^16) = very small number, so more than enough

  1. the bit resolution affects the width of the pulse on PWM. That is 256 different ‘widths’ (duty cycles) for 8-bit resolution and 65,536 for 16 bit ADC.

  2. The more the bit resolution is, the ‘smoother’ voltage range (0-5V) I’ll get.

I hope I’m not missing anything… :-?

So, if I go for an external 16-bit DAC how can I bypass the 8-bit DAC on the Arduino?

p.s hope I’m not asking too much…

warp

if I go for an external 16-bit DAC how can I bypass the 8-bit DAC on the Arduino?

If you add an external D-A converter, you won’t use “analogWrite” to send data to it. At least, not without a lot of reprogramming. Probably you’ll end up using SPI or I2C; it will depend on the exact nature of the D-A you pick.

Note that at 65536 steps, you’re talking about each bit being 0.002% of full scale, approximately. Compare to the 1% or 5% resistors you’ll probably be using, and perhaps even the thermal variance of your other components… (This may not be too important, if absolute accuracy is not so important, but most people tend to forget how “extreme” the analog design they’ll need if they really want “16 bits” of analog performance.)

So if I understand you correctly, you are only receiving 128 unique values from MIDI yet you are worried about having only 256 unique values on PWM? Can you help me follow your reasoning for needing a 16 bit DAC?

The reason for the wanted higher bit depth is usually that you want to be able to do pitch bends which requires a much higher resolution than the 128 midi notes not to give a “stepped” output.

I was planning on building a 4 channel CV interface for my synrth using the MAX 536 DAC. it’s a 4 channel 14 bit rather expencive DAC chip, but one i know have been used before by Kymatica: http://www.bitminds.net/kymatica/uploads/Hardware/pc-interface.pdf.

I have two of the MAX536 IC’s waiting in my drawer :slight_smile:

how can I bypass the 8-bit DAC on the Arduino?

It’s important to understand that there is no DAC on an Arduino. It has a 12-bit ADC, but no DAC. The so-called analog outputs are done with PWM, which produces a pulsating DC voltage with variable mark/space ratio.

For your application, you’ll need to use an external DAC.

thank you all for your help guys. Really appreciated…

It’s important to understand that there is no DAC on an Arduino. It has a 12-bit ADC, but no DAC. The so-called analog outputs are done with PWM, which produces a pulsating DC voltage with variable mark/space ratio.

For your application, you’ll need to use an external DAC.

Does this mean that I will not need PWA for my project?
only an external DAC will do the trick? :-?

Does anyone aware of any good tutorials regarding DAC from digital pins? I guess it doesn’t necessarily have to be an arduino tutorial.

still a bit confused but I’m getting there… :slight_smile:

warpie

Does this mean that I will not need PWA for my project?
only an external DAC will do the trick?

Assuming that’s a typo for PWM, then yes, you won’t need PWM, you will need an external DAC with sufficiently high resolution.

Here are some examples of 12 and 16-bit DAC chips from Maxim:

http://www.maxim-ic.com/quick_view2.cfm/qv_pk/5518

ok, thanks.

I’ll have a go and see how it goes :slight_smile:

warp