Interfacing a DDS chip

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
JAE
Posts: 4
Joined: Tue Oct 18, 2016 4:18 am

Interfacing a DDS chip

Postby JAE » Mon Mar 06, 2017 5:39 am

I would like to post a topic of writing the interface code for several DDS chips (Analog Devices). At this point I am having problems using the AD9834 would appreciate any help on this.

Thanks

JAE

User avatar
deshipu
Posts: 1077
Joined: Thu May 28, 2015 5:54 pm

Re: Interfacing a DDS chip

Postby deshipu » Mon Mar 06, 2017 11:00 am

How can we help? Do you have any specific problems or questions?

I think the best starting point is reading the datasheet for the chip in question -- have you already tried this?

JAE
Posts: 4
Joined: Tue Oct 18, 2016 4:18 am

Re: Interfacing a DDS chip

Postby JAE » Tue Mar 07, 2017 2:49 am

I have reviewed the specification. I am having a problem with shifting data into the control registrar. Any help would be appreciated..

User avatar
deshipu
Posts: 1077
Joined: Thu May 28, 2015 5:54 pm

Re: Interfacing a DDS chip

Postby deshipu » Tue Mar 07, 2017 7:51 am

So what do you have so far, and how the problem manifests itself?

JAE
Posts: 4
Joined: Tue Oct 18, 2016 4:18 am

Re: Interfacing a DDS chip

Postby JAE » Wed Mar 08, 2017 5:48 am

Here is my initial code for the serial registrar.

def shift16():
for i in range(16) #loop for 16 data bits
value = data & 0x8000 #look at left-most bit
SetPin (SDAT, Value) #puts its value on data line
data <<=1 #shift data bit to left
data &=0xFFFF #limit data to 16 bits
toggle sclk() #clock in the data bit_length
FSYNC.high() #bring FSYNC high after word sent

I am particularly concerned about the syntax,

Thanks JAE

User avatar
deshipu
Posts: 1077
Joined: Thu May 28, 2015 5:54 pm

Re: Interfacing a DDS chip

Postby deshipu » Wed Mar 08, 2017 3:56 pm

I guess to learn Python's syntax it's best to start with the official tutorial: https://docs.python.org/3/tutorial/

For sending data to that chip, you would probably be best off using the SPI peripheral: http://docs.micropython.org/en/latest/p ... e.SPI.html

JAE
Posts: 4
Joined: Tue Oct 18, 2016 4:18 am

Re: Interfacing a DDS chip

Postby JAE » Tue Apr 18, 2017 4:53 am

I having a problem getting this going. I am particular concerned about the code that I sent you. DO you see anything just glaringly wrong.
I must confess i am principally a hardware person. I am certainly not a code writer. Any examples you could send would help a great deal.
Particularly the code that I sent if you could point out what I am doing wrong it would be much appreciated.

Thanks

Jim

User avatar
deshipu
Posts: 1077
Joined: Thu May 28, 2015 5:54 pm

Re: Interfacing a DDS chip

Postby deshipu » Tue Apr 18, 2017 8:24 am

The code you posted doesn't make any sense, it's certainly not Python, and it doesn't use the commands that MicroPython makes available. Have you looked at the links I gave you? Try to write your code using the functions that are described there, and not just invent your own names and hope they somehow magically work.

User avatar
pythoncoder
Posts: 1646
Joined: Fri Jul 18, 2014 8:01 am

Re: Interfacing a DDS chip

Postby pythoncoder » Tue Apr 18, 2017 4:48 pm

Indeed. I'd start by learning the language using standard Python 3.x or MicroPython on a PC and working through a tutorial text. When you've got to grips with the language syntax, then move to hardware-oriented code on a Pyboard. It really is much quicker to do it that way.

Don't use Python 2.x as significant differences appeared with V3. MicroPython has always been 3.x compliant.
Peter Hinch


Return to “The MicroPython pyboard”

Who is online

Users browsing this forum: No registered users and 1 guest