Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

ATmega168 for DDS

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
davidapex

Bascom Member



Joined: 12 Mar 2006
Posts: 42
Location: Auckland

newzealand.gif
PostPosted: Sat Aug 12, 2006 6:47 am    Post subject: ATmega168 for DDS Reply with quote

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
View user's profile
i.dobson

Bascom Expert



Joined: 05 Jan 2006
Posts: 1544
Location: Basel, Switzerland

switzerland.gif
PostPosted: Sat Aug 12, 2006 8:33 am    Post subject: Reply with quote

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

_________________
Home of AVRTimer, the Bascom timer value calculator.
http://www.planet-ian.com

Walking on water and writing software to specification is easy if they're frozen.
Back to top
View user's profile Visit poster's website
davidapex

Bascom Member



Joined: 12 Mar 2006
Posts: 42
Location: Auckland

newzealand.gif
PostPosted: Sat Aug 12, 2006 9:06 am    Post subject: Reply with quote

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
View user's profile
Luciano

Bascom Member



Joined: 29 Nov 2004
Posts: 3149
Location: Italy

blank.gif
PostPosted: Mon Aug 14, 2006 1:23 pm    Post subject: Reply with quote

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
View user's profile
davidapex

Bascom Member



Joined: 12 Mar 2006
Posts: 42
Location: Auckland

newzealand.gif
PostPosted: Thu Aug 17, 2006 10:41 am    Post subject: ATmega168 port/pin problems Reply with quote

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
View user's profile
Luciano

Bascom Member



Joined: 29 Nov 2004
Posts: 3149
Location: Italy

blank.gif
PostPosted: Thu Aug 17, 2006 11:43 am    Post subject: Reply with quote

Hi David,

No. The AD9833 is a 10-bit DAC with 3-Wire SPI Interface.

You need a 8-Bit DAC with parallel interface like:
http://www.analog.com/en/prod/0%2C2877%2CAD557%2C00.html

Datasheet:
http://www.analog.com/UploadedFiles/Data_Sheets/616757999AD557_b.pdf

Was used here:
http://www.geocities.com/leon_heller/minidds.html

(Schematic in the ZIP file).
http://www.geocities.com/leon_heller/minidds.zip

* * * *

For the keypad splitted on two ports you will need
to write some code. The code is very simple. Don't
forget to put a 470 ohm resistor on each line of
the keypad.

Best regards,

Luciano
Back to top
View user's profile
davidapex

Bascom Member



Joined: 12 Mar 2006
Posts: 42
Location: Auckland

newzealand.gif
PostPosted: Fri Aug 18, 2006 11:31 am    Post subject: Reply with quote

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
View user's profile
pwillard

Bascom Member



Joined: 03 Jan 2006
Posts: 12

blank.gif
PostPosted: Mon Aug 28, 2006 12:31 am    Post subject: Reply with quote

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
View user's profile
pykedgew

Bascom Member



Joined: 22 Feb 2005
Posts: 17
Location: Australia

australia.gif
PostPosted: Sun Feb 25, 2007 3:16 am    Post subject: 16.777216MHz Xtal Reply with quote

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
View user's profile
Luciano

Bascom Member



Joined: 29 Nov 2004
Posts: 3149
Location: Italy

blank.gif
PostPosted: Sun Feb 25, 2007 10:07 am    Post subject: Reply with quote

Hi,

(From the US)

http://www.crystals.shopeio.com/inventory/catalog.asp?cat=Crystals
http://www.crystals.shopeio.com/inventory/details.asp?id=591&cat=Crystals&sub=
http://www.crystals.shopeio.com/inventory/pdf/MP1.pdf

Put the items in the shopping cart and then you will see the possible
shipping methods: International Airmail Parcel Post 4-10 Day USD 16.00


* * *

This is the manufacturer of the above crystal:

http://www.mtron.com
http://www.mtronpti.com

Select sales support/Distributors/Australia and you will find 4 distrubutors.
http://www.mtronpti.com/salessupport/index.php?id=47

Best regards,

Luciano
Back to top
View user's profile
pykedgew

Bascom Member



Joined: 22 Feb 2005
Posts: 17
Location: Australia

australia.gif
PostPosted: Mon Feb 26, 2007 12:13 am    Post subject: Reply with quote

Hi

@Luciano
Thanks for the reply.
Will check out the Australian suppliers.

Cheers
Ken
Back to top
View user's profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum