Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Library with multiple AD9833 circuits #5

Open
virtq opened this issue Feb 9, 2018 · 7 comments
Open

Use Library with multiple AD9833 circuits #5

virtq opened this issue Feb 9, 2018 · 7 comments

Comments

@virtq
Copy link

virtq commented Feb 9, 2018

Hi,
I'm trying to get this library working with multiple AD9833 circuits connected on the same SPI-bus.
So I've added the following;
AD9833.cpp

void AD9833 :: SetFNCPin ( uint8_t FNCpin ) {
	this->FNCpin = FNCpin;
}

AD9833.h

// Change FNCPin
void SetFNCPin ( uint8_t FNCpin );

However it doesn't really seem to work properly. One of them sometimes get the command that was supposed for the other one, but could perhaps be related to an electrical issue. I just wonder if there's anything more I should do to the library?

@Billwilliams1952
Copy link
Owner

Billwilliams1952 commented Feb 9, 2018 via email

@Billwilliams1952
Copy link
Owner

Billwilliams1952 commented Feb 9, 2018 via email

@virtq
Copy link
Author

virtq commented Feb 12, 2018

Thank you for your answer. I actually started out creating an additional instance but since the SPI.begin() is executed within the AD9833.begin() function, I thought it would not be correct to run that function for every instance, since the bus was already started. But perhaps that would be the only problem and I can try to only run that function for the first instance instead.

@Billwilliams1952
Copy link
Owner

Billwilliams1952 commented Feb 13, 2018 via email

@virtq
Copy link
Author

virtq commented Feb 13, 2018

I was finally able to sort it out. It turned out that it was some kind of electrical issue with the IC, so I had to replace it. Now it works as expected with both code solutions, but I will stick to yours, with creating different instances, because it would probably make the code easier to read.

However, regarding the code library, should perhaps SPI.begin() be moved out from the library completely? Then it would be logically to call Begin() for every instance as you also call the Reset function in there. Alternatively you could have some other function for that in the library, but I don't know what would be the best solution.

@Billwilliams1952
Copy link
Owner

Billwilliams1952 commented Feb 13, 2018 via email

@Billwilliams1952
Copy link
Owner

Billwilliams1952 commented Feb 21, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants