Sections
You are here: Home Forum Project Discussion Analog Output/Waveform

Analog Output/Waveform

Up to Project Discussion

Analog Output/Waveform

Posted by Bodo Schmidt at September 17. 2008
I need to drive generate a relatively slow waveform (something like triangle or saw-tooth). Since there's no analog out on the board itself, does anybody have any clever ideas how to do this with the MAKE board?

Re: Analog Output/Waveform

Posted by Lou Deluxe at September 18. 2008
  • Hijack one or more channels of PWM from digital out duty.
  • Add an external ADC.
  • Hang an Arduino (or other coprocessor) off of the serial port, using either its PWM channels or a wave shield.
None of those is particularly easy (depending on one's level of expertise), but they are all arguably clever.

Depending on exactly how slow the waveform is to be, some easier options might become available.  Wave shape tells me nothing about how fast this needs to be.
  • Bit-bang PWM using a fasttimer as a timebase.  There will be jitter if anything else (like servos) is using a fasttimer.
  • Use a servo channel with appropriate signal conditioning (scaling, translation, etc.).  You're stuck with ~50 samples/s with that, though.

Re: Analog Output/Waveform

Posted by Bodo Schmidt at September 18. 2008
Thanks, I was thinking about going the DAC route, although I'm not sure how to simultaneously update all DigOut channels at once to avoid getting spikes at the transitions from one sample to the next. I thought I checked out the Arduino and I didn't see an AnalogOut, but I'll look again. For the sampling rate - I was thinking about something on the order of 100Hz.

Re: Analog Output/Waveform

Posted by Lou Deluxe at September 18. 2008

Previously Bodo Schmidt wrote:

Thanks,

I was thinking about going the DAC route, although I'm not sure how to simultaneously update all DigOut channels at once to avoid getting spikes at the transitions from one sample to the next.

Oh yeah.  DAC.  That's what I meant by ADC above.  I got it exactly backward.  I was thinking of something more like SPI to talk to an external DAC.

The approach you mention could work.  Almost.  There is a way to set up and use the GPIO hardware so that you can write to a bunch of bits at one time without disturbing the others.  If all of the digital outs are on one GPIO (there are two banks of them in the chip).
Unfortunately, 6 of the digital outs are in PIOA and 2 of them are in PIOB.  If you only need 64 levels, that's still an option.  Otherwise, you'll still have a glitch between setting 6 of the bits and then the other 2 (or vice versa).
I thought I checked out the Arduino and I didn't see an AnalogOut, but I'll look again.
I don't know whether they have a DAC, but they do have 6 PWM channels.
For the sampling rate - I was thinking about something on the order of 100Hz.
You could probably pull it off with a fasttimer.  There may be certain limits on minimum or maximum duty cycle due to interrupt latency, and I don't know how granular it is, though the docs say "microsecond resolution".  The fasttimer code hurts my brain.

Re: Analog Output/Waveform

Posted by Liam Staskawicz at September 23. 2008
If you're willing to do some coding on the SAM7X itself, I have some half-baked timer code that can generate a square wave at a configurable rate. Ultimately I hope to make a library out of it, but it's not there yet :) Contact me via email (liam at makingthings dot com) if you're interested. Otherwise, using one of the existing PWMs is not a bad plan. There's some decent support for setting the periods of them now - http://www.makingthings.com/ref/firmware/html/group___pwm.html and

Re: Analog Output/Waveform

Posted by John (EBo) David at September 27. 2008
why not just build an integrator on a PWM line? It only takes a resistor and capacitor . EBo --

Re: Analog Output/Waveform

Posted by Aaron Tunell at October 13. 2008

i agree with EBo, you may have to tinker with the resistor and capacitor values to match the PWM frequency, but this is the correct solution to DAC using PWM.

http://en.wikipedia.org/wiki/Low-pass_filter

Powered by Ploneboard
Document Actions