Analog Output/Waveform
Up to Project Discussion
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?
- 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.
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.
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.
Previously Bodo Schmidt wrote:
Thanks,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.
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.
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.
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
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
Powered by
Ploneboard

