View previous topic :: View next topic |
Author |
Message |
davidapex
Joined: 12 Mar 2006 Posts: 42 Location: Auckland
|
Posted: Sat Aug 12, 2006 6:47 am Post subject: ATmega168 for DDS |
|
|
Hi All,
A while back I got involved with the DDS code posted by Luciano and had this running nicely (with internal oscillator) on an ATmega 168.
Then by chance I obtained a crystal oscillator with the magic frequency 16.777216MHz (2^24) and thought this would be great for the project as it makes the maths all integer and allows me to step in 0.1Hz increments.
The problem now relates to the dumb port/pin allocations on the chip.
I need an 8 bit DAC (port c), the xtal on port b.6, b.7, the LCD on port b.0-b.5 and a keypad on port c.
It's the keypad that is giving me problems as I can only give it port c.0 to c.6.
The keypad command appears to be looking for 7 pins even though port x.3 is not used in a 4x3 keypad.
How involved is it to rewrite a keypad routine to use 7 consecutive port pins on a 4x3 keypad?
Best regards,
David |
|
Back to top |
|
|
i.dobson
Joined: 05 Jan 2006 Posts: 1570 Location: Basel, Switzerland
|
Posted: Sat Aug 12, 2006 8:33 am Post subject: |
|
|
Hi David,
Wouldn't it be easier to write your own routine? All the keypad routine does is to set each line to high in turn and see which row is high, then decode which key is pressed.
Regards
Ian Dobson _________________ Walking on water and writing software to specification is easy if they're frozen. |
|
Back to top |
|
|
davidapex
Joined: 12 Mar 2006 Posts: 42 Location: Auckland
|
Posted: Sat Aug 12, 2006 9:06 am Post subject: |
|
|
Hi Ian,
I think you are right and I should bite the bullet and have a go myself.
I still can't believe the dumb way the chip has been arranged. If you were wanting a xtal timed UART you lose both 8 bit ports and are left with only a 7 bit port C. Why not put the xtal osc and UART on to the 7 bit port in the first place? Perhaps I'm missing something and greater minds have already pondered this.
Cheers,
David |
|
Back to top |
|
|
Luciano
Joined: 29 Nov 2004 Posts: 3149 Location: Italy
|
Posted: Mon Aug 14, 2006 1:23 pm Post subject: |
|
|
Hi David,
Why don't you put the LCD and the DAC on the same PortD?
(The LCD Enable pin and the DAC Enable pin could be on any
pin of the AVR).
The E pin enables or disables the LCD module. When Enable
is low the LCD is disabled and the status of RS, R/W and the
data bus will be ignored. When Enable pin is high the LCD is
enabled and the status of the other control pins and data bus
will be processed by the LCD.
What model of DAC chip are you using?
Best regards,
Luciano |
|
Back to top |
|
|
davidapex
Joined: 12 Mar 2006 Posts: 42 Location: Auckland
|
Posted: Thu Aug 17, 2006 10:41 am Post subject: ATmega168 port/pin problems |
|
|
Hello Luciano,
Apologies for the delay in responding to your idea. This looks like the best way to go but I think I still have a problem. The DAC is actually a SIP R-2R ladder network from Dale and uses 20k and 10k elements - easy but needs to be buffered for anything useful.
If I put the LCD and ladder network on port D and the xtal on port b.6/b.7 where would I put the 7 pins for the keypad? Can I run a keypad across 2 ports - i.e. drive on one port and sense on another port?
About now the AD9833 chip looks very attractive.
http://www.analog.com/en/prod/0,,770_843_AD9833,00.html
Cheers,
David |
|
Back to top |
|
|
Luciano
Joined: 29 Nov 2004 Posts: 3149 Location: Italy
|
|
Back to top |
|
|
davidapex
Joined: 12 Mar 2006 Posts: 42 Location: Auckland
|
Posted: Fri Aug 18, 2006 11:31 am Post subject: |
|
|
Hello Luciano,
Sorry for the confusion - I was hinting that the AD9833 would replace the entire DDS software, ATmega 168 and DAC. The attraction is the hardware based DDS allowing higher speed and you would only need a small micro to talk to it.
Getting back to the software DDS approach - I did try my own keypad routine across a single port and it worked really well first time, something that doesn't happen too often for me. That was about when I turned the reset pin in to an I/O pin and realised it was not a good idea with a low voltage prammer.
I will try the keypad split across two ports.
Thanks for the support. Have a great weekend.
Cheers,
David |
|
Back to top |
|
|
pwillard
Joined: 03 Jan 2006 Posts: 12
|
Posted: Mon Aug 28, 2006 12:31 am Post subject: |
|
|
I keep thinking I want to play around with this DDS idea.
I realized that I didn't have a R2R ladder handy so I made one. To be honest, this is my first attempt at surface mounting components and it was much easier than I thought.
Guess I can give it a try now. Thanks for all the work on coding this so far.
PW _________________ pw |
|
Back to top |
|
|
pykedgew
Joined: 22 Feb 2005 Posts: 17 Location: Australia
|
Posted: Sun Feb 25, 2007 3:16 am Post subject: 16.777216MHz Xtal |
|
|
Hi David
Can you recall where you obtain this crystal oscillator with the magic frequency 16.777216MHz (2^24) from?
How much did it cost?
Cheers
Ken |
|
Back to top |
|
|
Luciano
Joined: 29 Nov 2004 Posts: 3149 Location: Italy
|
|
Back to top |
|
|
pykedgew
Joined: 22 Feb 2005 Posts: 17 Location: Australia
|
Posted: Mon Feb 26, 2007 12:13 am Post subject: |
|
|
Hi
@Luciano
Thanks for the reply.
Will check out the Australian suppliers.
Cheers
Ken |
|
Back to top |
|
|
|