DDS on Propeller?
Drone
Posts: 433
Hi All... Has anyone implemented Direct Digital Synthesis (DDS) on the Propeller? Did a brief search of the forum and ObEx and didn't come up with anything. Will dig deeper tomorrow.
Thanks, David
Thanks, David
Comments
This comes up from time to time. What frequency sine waves were you thinking? 0-100Hz for 3 phase motor control, or higher? I believe the Prop2 might be able to do DDS nicely (there was something in the webinar earlier this year).
I looked at it briefly before deciding the AD9959 evaluation board (4ch DDS for $250) was good value for a nice bit of ready made test gear
Here are a couple of related threads from earlier.
http://forums.parallax.com/showthread.php?p=739083
http://forums.parallax.com/showthread.php?p=815643
and towards the end of this one
http://forums.parallax.com/showthread.php?p=596612
cheers
tubular
I'm looking for a couple hundred kHz with an 8bit D/A and maybe 24 bit DDS control and accumulator. Looking at the assembler instructions though was a bit of a let down. I had forgotten PASM instructions take at least four clock cycles. So if the simplest DDS loop takes around 10 instructions, even with the system clock at 80MHz I don't think I'll even hit 100kHz. Maybe I'll look at an Atmel AVR part. AVR instructions are typically one clock cycle each, which will result in better performance even with a system clock of 20MHz.
I'll have a look at the links you provided as well.
Thanks for taking the time to reply, David
www.geocities.com/leon_heller/minidds.html
A 20 MHz Tiny2313 would be a lot better.
Leon
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM
Suzuki SV1000S motorcycle
* Heterodyne Sine wave generator - What if Tesla had a Propeller to play with?
http://forums.parallax.com/showthread.php?p=739083
* OBEX update: PWM_32_v1
http://forums.parallax.com/showthread.php?p=815643
* Control Phase on NCO
http://forums.parallax.com/showthread.php?p=596612
Here are a couple more links I found that might be helpful:
* Problems getting Sinewave Generator to output full bandwidth
http://forums.parallax.com/showthread.php?p=744980
* SPIN CODE EXAMPLES FOR THE BEGINNER (Public Version)
This is Tracy Allen's post with sinewave0.spin, sinwave1.spin, sinwave3.spin
http://forums.parallax.com/showthread.php?p=606978
Yes... Your AVR DDS page and the link to Jesper's DDS is exactly what I've been thinking about. In looking at my ASM minimal DDS pseudocode for doing this and it became apparent the typical 4 clock cycles per instruction required in PASM is problematic. The PASM code at 80MHz system clock will run significantly slower compared with the AVR at 20MHz.
Jesper's AVR code is almost identical to what I came up with in terms of the DDS main loop. I looked at protoboarding a DIP28 ATMega168-20PU at 5V to implement the DDS (instead of the 2313; I only have a 168 on-hand) with a 16MHz crystal (no 20MHz on-hand) with a discrete resistor (30k/15k so 6-pin ISP can work in parallel) 8-bit R2R DAC. Argh, it turns out with the 168 vs. the 2313 if you want to use a crystal and USART TXD/RXD, you can't get a GPIO port bank with full 8-bits. This adds instructions to the main DDS loop and slows it down (but not by much compared to PASM. Each AVR ASM instruction adds 1 clock cycle, PASM adds at least 4.) IMHO This is a deal-killer in DDS applications like this with PASM.
I'm by no means giving up on the Propeller. If time permits, I'll port my solution to PASM with a Spin wrapper and freely distribute the code on ObEx.
Yes I know a middle-ground solution is to implement the DDS in the likes of a CPLD in VHDL etc. But for 200kHz 8-bit waveforms, I'd rather find a very low cost single chip DIP micro-controller solution so everyone can use it on the bench.
Best 73's Leon, David
Why that? PASM: 80MHz/4 = 20MIPS, AVR: 20MHz/1 = 20MIPS, but only 8 bit MIPS.
For a DDS, you need additions with more then 8 bits, so the propeller should be faster for this.
Here a possible minimal DDS for 100 kHz with a triangle wave, instead of a sine (not tested):
Andy
The code below is scraped from Jesper's source at www.myplace.nu/avr/minidds/index.htm is for a DDS with 8-bit DAC, 24-bit accumulator, and 24-bit adder. It takes 9 cycles at 20MHz for a 2.2MHz fastest loop. Assuming 4-cycles per instruction (best case) the PASM code you presented would take 20 clock cycles at 80MHz tor a 4MHz fastest loop. So you are right, if my assumption of 4 cycles per instruction in PASM is correct, the propeller is roughly twice as fast as the 20MHz AVR with your PASM code. I stand corrected. Note, Jesper's code uses a data table for sine, triangle etc.
I'm not good with PASM yet. How would you implement your code with a data table? Say 256 steps or 16x16.
Thanks - David
Post Edited (Drone) : 7/2/2009 12:01:44 PM GMT