cjheath / AD9959

AD9959 4-channel Direct Digital Synthesis Arduino Library
13 stars 11 forks source link

Update AD9959.h #4

Closed maggo1404 closed 5 years ago

maggo1404 commented 5 years ago

Change the SPI-interface from LSB to MSB transfare morde

cjheath commented 5 years ago

Please confirm that you have the AD9959 working with this change? (I have yet to complete this project).

maggo1404 commented 5 years ago

Yes, the AD9959 is only running with this change. Look the datasheet (https://www.analog.com/media/en/technical-documentation/data-sheets/AD9959.pdf) page 36. The standard config is the msb mode.

cjheath commented 5 years ago

Many thanks. Hopefully I can test my own hardware soon!

chunsik79 commented 5 years ago

hi guys, could you share arduino code to test AD9959.h? I've been having trouble running it on my ArduinoMega. Thanks!

cjheath commented 5 years ago

@chunsik79 Have you tried the obvious? It can be tested with a four-line program, have you done that? You'll need to ensure that your wiring is correct also, that's the most likely reason for failure. If you don't know how to do those things, I'm not sure whether an example will help you. If you've done them, you're more likely to get help after you show us what you've tried.

chunsik79 commented 5 years ago

@cjheath Thanks for the reply and making this code available. Let me explain what I have been doing. First of all, the following link shows a photo of my current hardware setup.

(https://user-images.githubusercontent.com/30134870/64458529-75bf4d80-d0aa-11e9-951b-a8e19543d705.jpg)

I connected the pins from ArduinoMega 2560 to AD9959 using a level shifter (3.3 V <-->5 V)

The following is what my Aruino sketch that compiles without any error.

include "AD9959.h"

class MyAD9959 : public AD9959< 2, // ResetPin 3, // ChipEnablePin 4, // UpdatePin 25000000 // (reference_frequency) // SPIRate, SPIClkPin, SPIMISOPin, SPIMOSIPin

{};

MyAD9959 dds;

void setup() {

dds.reset();

dds.setClock(4, 1200);

uint32_t delta; delta = dds.frequencyDelta(455000); dds.setFrequency(MyAD9959::Channel2, 7140000UL); // shorthand for: dds.setDelta(MyAD9959::Channel2, dds.frequencyDelta(7140000UL)); // 7.14MHz dds.setAmplitude(MyAD9959::Channel2, 1023); // Maximum amplitude value dds.setPhase(MyAD9959::Channel2, 16383); // Maximum phase value (same as -1) dds.update(); }

void loop() {

}

Please let me know if you can see any issue with my setup or arduino sketch. Thanks!!

cjheath commented 5 years ago

I don't immediately see anything wrong with your code, though you have an unused delta variable, and you should not need to set phase unless you are coordinating two or more channels. I suspect you have wiring issues.

I haven't used an Arduino Mega. I assume that you've checked that the pins you've assigned are actually correctly wired? You could check with a little sketch that slowly toggles each one and hook up an LED to ensure that the pins are actually toggling. Even check at the other side of the level shifter, so you know that is working as expected. These level shifters are strong in one direction but weak in the other, but with such short wiring that should not be an issue. You could slow down the SPI if you're worried.

My AD9959 module has pull-ups or pull-downs on some of the control pins but not all. SDIO_1 can float, but SDIO_3 should be pulled down, as I note in my ReadMe. Check your module has the appropriate pull-down or add one yourself.

It might be safe to insert a delay after power-on before you initialise the AD9959, in case you have power sequencing issues.

chunsik79 commented 5 years ago

Thank you so much @cjheath. I've reviewed my board connection. Could you explain by what you mean by "Check your module has the appropriate pull-down or add one yourself"? I just simply connected SDIO_3 to GND that is shared by arduino, AD9959, and level shifter. Would this be enough or I need to do something else?

cjheath commented 5 years ago

I think my module (different from yours) has a pull-down resistor fitted for SDIO_3, so I can leave it non-connected. If yours is the same, you can also. Otherwise connect it to GND either directly or by a resistor.

chunsik79 commented 5 years ago

Thanks! Could you let me know which module you are using?

cjheath commented 5 years ago

I bought this one but do not recommend it https://www.aliexpress.com/item/32713419146.html It presents an unbalanced load to the four balanced pairs of DAC outputs (one is a resistor to ground, one is the filter which rejects harmonic energy). As a result the harmonics from each DDS appear in the on-chip power supply rails, which reduces the isolation between channels. Find one that has transformers (like in the eval kit) or fast op-amps. Some modules have two of each.

chunsik79 commented 5 years ago

Okay, thanks. I think my module definitely have intrinsic problems. https://www.eevblog.com/forum/rf-microwave/all-you-need-to-know-about-the-chinese-ad9959-ebay-board/ I will try the same board you used and see how it goes. Thanks!

chunsik79 commented 5 years ago

I forgot to ask. Do you know any module that you think can work better than what you have?

cjheath commented 5 years ago

The EBay one shown on that page is also unbalanced. I've just done another search and found these ones:

The transformers are not cheap, so cut-price vendors like to omit them.

My one, the one you already have, and this one are all unbalanced: https://www.aliexpress.com/item/33002306603.html

cjheath commented 5 years ago

This version uses a balanced filter followed by an op-amp to convert to single-ended. Not sure if you can buy it without the controller: https://www.aliexpress.com/item/32722156286.html

chunsik79 commented 5 years ago

I appreciate your help a lot. What do you think about this one? : https://www.ebay.com/itm/US-AD9959-RF-Signal-Source-Four-Channel-Signal-Generator/163597924991?hash=item2617323a7f:g:1jkAAOSwTmxci2yy

I am looking for AD9959 module that I can get it delivered from US seller.

cjheath commented 5 years ago

Look at the board yourself FFS! No transformers, no op-amps, four outputs, so it has unbalanced loads to the DDS channels and they will crosstalk. That might not matter to you, but it's not optimal.

This is a pull request, not a hardware support thread. Get someone to check your connections, I can't help you more.

chunsik79 commented 5 years ago

@cjheath I am so sorry for asking hardware support questions. I will try the codes with properly working boards and share proper information on this thread.