Main Site Documentation

Analog Output Implementation


I’m from the Arduino world, and in the Arduino I’m used to simulating an “analog output” by using PWM. My question is: When I started looking over the USBizi chip, it seems like there’s a difference between pure analog and PWM. Does anyone know the difference? Specifically, how exactly is the analog output implemented, if not using PWM?

Also, it says on the USBizi Manual that PWM cannot be controlled per pin. Is there any way to do that? I’m trying to control two motors without the use of a motor shield, and both motors need to be controlled independently, making it necessary to control the PWM frequency of two different PWM pins separately.



See the PWM and OutputCompare sections of the Tutorials page.


In the FAQ page under the “Downloads & Tutorials” menu, the only thing about OutputCompare and PWM is:

“OutputCompare that allows generating waveforms. Generate software-PWM, tones, UART or even TV remote waveforms easily. Runs on any digital IO and is not system blocking (runs in background on interrupts).”

That kind of explains the difference between analog and PWM. However, I’m still confused as to what each of the outputs (analog vs PWM) produce in concrete terms of signal. For example, I understand that PWM turns the digital signal all the way on (3.3V) and all the way off (0V) very fast.

From my understanding of analog, it should have a certain number (probably 256) of voltage levels that are allowed, and the number of voltage levels between 0 and 3.3V should be enough to form a “smooth analog” curve. Although the smoothness is subjective, the point is the varying levels of voltage, as opposed to a simple modulating on and off signal, as in PWM.

Am I correct in this understanding of the difference between the two methods of producing “analog” signals? This link helped me understand the traditional method of digital to analog conversion:


In simple words you control analog part of the pwm output by by “how long” is your high part compare to low part of the pulse period.

So if it is 50% high and 50% low then output would be half of the 3.3v ~ 1.6v. If 30% high and 70% low than it is ~1.1v and so on.


I understand how PWM works. My concern is how the analog outputs differ from PWM. Please read my last reply.

Do they implement the analog the same way as PWM? In that case, why are there separate outputs for analog and PWM?


[quote]are there separate outputs for analog and PWM?


The analog output is a voltage. There are 10 bits of precision, and the voltage varies from 0 to 3.3 volts.
Analog output is pure dc, not a square wave.


Mike, thanks for that answer. So you can have 2^10=1024 levels of voltage between 0 and 3.3V for the analog output, correct?


Did you know you can play WAV files on FEZ analog output?


I was aware that it’s possible to play WAV files, but how do I implement that? Do I need a shield?


Nop, nothing…just connect your PC speakers to the analog output pin and enjoy the music!

Always look at the tutorials page, you will find cool things, like this for example


[quote]So you can have 2^10=1024 levels of voltage between 0 and 3.3V for the analog output, correct?

Yep! But there is going to be some drift and noise.


Yeah noise is something I would expect from a raw output. Thanks for clarifying about the voltage levels.