Page 1 of 1

Interfacing a DDS chip

Posted: Mon Mar 06, 2017 5:39 am
by JAE
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

Re: Interfacing a DDS chip

Posted: Mon Mar 06, 2017 11:00 am
by deshipu
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?

Re: Interfacing a DDS chip

Posted: Tue Mar 07, 2017 2:49 am
by JAE
I have reviewed the specification. I am having a problem with shifting data into the control registrar. Any help would be appreciated..

Re: Interfacing a DDS chip

Posted: Tue Mar 07, 2017 7:51 am
by deshipu
So what do you have so far, and how the problem manifests itself?

Re: Interfacing a DDS chip

Posted: Wed Mar 08, 2017 5:48 am
by JAE
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

Re: Interfacing a DDS chip

Posted: Wed Mar 08, 2017 3:56 pm
by deshipu
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

Re: Interfacing a DDS chip

Posted: Tue Apr 18, 2017 4:53 am
by JAE
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

Re: Interfacing a DDS chip

Posted: Tue Apr 18, 2017 8:24 am
by deshipu
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.

Re: Interfacing a DDS chip

Posted: Tue Apr 18, 2017 4:48 pm
by pythoncoder
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.