Closed CarlosNet closed 3 years ago
@CarlosNet
please checkout the latest 0.2.0 release.
It supports setting float frequencies by means of setFrequencyF(float freq) call.
Sorry I do not guarantee 3 decimal places (not tested that), the code is optimized to squeeze max resolution.
Be sure to set the autoRefClock to LOW. for low frequencies (AD9851 specific)
Please let me know your test results, Thanks
Thank you, I will review it in a few days and I will inform you. thanks
@CarlosNet release 0.2.1 released
What kind of wave do you need? Square wave or a sine wave?
Hello Rob. The type of wave I need is square. I am waiting for the modules to test. Is the library ready to put two modules and call them independently? thank you very much for your great work
El dom., 10 ene. 2021 19:14, Rob Tillaart notifications@github.com escribió:
@CarlosNet https://github.com/CarlosNet release 0.2.1 released
What kind of wave do you need? Square wave or a sine wave?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/RobTillaart/AD985X/issues/9#issuecomment-757527989, or unsubscribe https://github.com/notifications/unsubscribe-auth/APXUEZYYPVKIF2PJ6FASD3TSZH4BDANCNFSM4VOE2FZQ .
The devices should have different pins in the begin() function, especially the select pin. [not tested however]
void begin(int select, int resetPin, int FQUDPin, int dataOut = 0, int clock = 0);
For a square wave you could just use an Arduino, it is fast enough to get to 3 decimals
//
// FILE: simpleSquareWave.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.0
// PURPOSE: demo
// DATE: 2021-01-10
// (c) : MIT
//
uint8_t pin1 = 13;
uint8_t pin1state = LOW;
float frequency = 5;
float dutycycle = 0.50;
uint32_t ldur = 0;
uint32_t hdur = 0;
uint32_t lastTime = 0;
uint32_t lastTogglePin = 0;
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
pinMode(pin1, OUTPUT);
digitalWrite(pin1, LOW);
float wavelength = 1000000 / frequency;
ldur = round(dutycycle * wavelength);
hdur = round((1 - dutycycle) * wavelength);
}
void loop()
{
uint32_t now = micros();
// check if keypressed
if ((now - lastTime) >= 500)
{
lastTime = now;
if (Serial.available())
{
int c = Serial.read();
switch (c)
{
case '0' ... '9':
frequency *= 10;
frequency += (c - '0');
break;
case '+':
frequency += 0.001;
break;
case '-':
frequency -= 0.001;
break;
case '*':
frequency *= 10;
break;
case '/':
frequency /= 10;
break;
case 'c':
frequency = 0;
break;
}
// may differ
float wavelength = 1000000 / frequency;
ldur = round(dutycycle * wavelength);
hdur = round((1 - dutycycle) * wavelength);
Serial.println(frequency, 4);
}
}
// check if pin needs toggle
if ((pin1state == LOW) && ((now - lastTogglePin) >= ldur))
{
digitalWrite(pin1, HIGH);
pin1state = HIGH;
lastTogglePin = now;
}
if ((pin1state == HIGH) && ((now - lastTogglePin) >= hdur))
{
digitalWrite(pin1, LOW);
pin1state = LOW;
lastTogglePin = now;
}
}
// -- END OF FILE --
just enter the string "c10354///" => clear 10354 / 1000 = 10.354 Hz
Might also have a look at - https://github.com/RobTillaart/FunctionGenerator
Thanks for the info.
The problem with arduino is that I already have very heavy code and use enough external interrupts to count encoders and frequencies at very high frequency.
Besides that I need very good frequency stability and buy TCXO crystals to improve stability with respect to temperature.
I ran tests with 10 esp32 arduinos and they all gave me the same code, different output frequency measurements, that's why I prefer to outsource it.
The MUC load also does not interfere with the agile management of the system.
I'll wait to see if the modules get to me and I'll inform you of my progress.
Thanks again.
El dom, 10 ene 2021 a las 19:56, Rob Tillaart (notifications@github.com) escribió:
The devices should have different pins in the begin() function, especially the select pin. [not tested however]
void begin(int select, int resetPin, int FQUDPin, int dataOut = 0, int clock = 0);
For a square wave you could just use an Arduino, it is fast enough to get to 3 decimals
//// FILE: simpleSquareWave.ino// AUTHOR: Rob Tillaart// VERSION: 0.1.0// PURPOSE: demo// DATE: 2020// (c) : MIT// uint8_t pin1 = 13;uint8_t pin1state = LOW; float frequency = 5;float dutycycle = 0.50;uint32_t ldur = 0;uint32_t hdur = 0;
uint32_t lastTime = 0;uint32_t lastTogglePin = 0; void setup() { Serial.begin(115200); Serial.println(FILE);
pinMode(pin1, OUTPUT); digitalWrite(pin1, LOW);
float wavelength = 1000000 / frequency; ldur = round(dutycycle wavelength); hdur = round((1 - dutycycle) wavelength); } void loop() { uint32_t now = micros();
// check if keypressed if ((now - lastTime) >= 500) { lastTime = now; if (Serial.available()) { int c = Serial.read(); switch (c) { case '0' ... '9': frequency = 10; frequency += (c - '0'); break; case '+': frequency += 0.001; break; case '-': frequency -= 0.001; break; case '': frequency = 10; break; case '/': frequency /= 10; break; case 'c': frequency = 0; break; } // may differ float wavelength = 1000000 / frequency; ldur = round(dutycycle wavelength); hdur = round((1 - dutycycle) * wavelength); Serial.println(frequency, 4); } }
// check if pin needs toggle if ((pin1state == LOW) && ((now - lastTogglePin) >= ldur)) { digitalWrite(pin1, HIGH); pin1state = HIGH; lastTogglePin = now; } if ((pin1state == HIGH) && ((now - lastTogglePin) >= hdur)) { digitalWrite(pin1, LOW); pin1state = LOW; lastTogglePin = now; }
} // -- END OF FILE --
just enter the string "c10354///" => clear 10354 / 1000 = 10.354 Hz
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/RobTillaart/AD985X/issues/9#issuecomment-757534128, or unsubscribe https://github.com/notifications/unsubscribe-auth/APXUEZ4ICQ2RCRVJRFQ27WLSZIA6FANCNFSM4VOE2FZQ .
Any progress?
Good Morning. today they give me the components. This weekend I do the tests
El jue., 21 ene. 2021 10:29, Rob Tillaart notifications@github.com escribió:
Any progress?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/RobTillaart/AD985X/issues/9#issuecomment-764503091, or unsubscribe https://github.com/notifications/unsubscribe-auth/APXUEZZ3436FXNTLFKNRKALS27XXFANCNFSM4VOE2FZQ .
I already have the circuit. they were wrong and they turned on the ad9850 I'm trying to get it up and running but can't get it to work. in the readme you put the names of the pins and configure them as you name them, I could not make it work. add some variables with pin assignments to avoid making a mess. and it doesn't work for me. const int W_CLK = 6; const int FU_UD = 7; const int DATA = 8; const int RESET = 9; const int SELECT_PIN = 10;
freqGen.begin (SELECT_PIN, RESET, FU_UD, DATA, W_CLK);
thinking that I could put something wrong, I looked for another code for the ad9850 from more than 2 years ago and if it works for me. I'm sure I have something wrong but with another code if it works for me. What I can do ? Thank you for your work.
// // FILE: AD9850_demo.ino // AUTHOR: Rob Tillaart // VERSION: 0.2.0 // PURPOSE: demo
const int W_CLK = 6; const int FU_UD = 7; const int DATA = 8; const int RESET = 9; const int SELECT_PIN = 10;
AD9850 freqGen;
uint32_t freq = 0; uint32_t prev = 0; uint32_t maxFreq;
void setup() { Serial.begin(115200); Serial.println(FILE); Serial.print("AD985X_LIB_VERSION: \t"); Serial.println(AD985X_LIB_VERSION);
help();
freqGen.begin(SELECT_PIN, RESET, FU_UD, DATA, W_CLK); freqGen.powerUp(); maxFreq = freqGen.getMaxFrequency(); Serial.println(maxFreq); }
void loop() { if (Serial.available() > 0) { int c = Serial.read(); switch (c) { case '?' : help(); break; case 'R' : freqGen.reset(); freq = freqGen.getFrequency(); break; case 'P' : freqGen.powerDown(); break; case 'U' : freqGen.powerUp(); break; case '+' : freq += 1; break; case '-' : freq -= 1; break; case '' : freq = 10; break; case '/' : freq /= 10; break; } if (freq > maxFreq) freq = maxFreq; }
// UPDATE AD985X IF NEW VALUE if (prev != freq) { prev = freq; freqGen.setFrequency(freq); Serial.println(freq); } }
void help() { Serial.println(); Serial.println("+ : f = f + 1"); Serial.println("- : f = f - 1"); Serial.println(" : f = f 10"); Serial.println("/ : f = f / 10"); Serial.println("? : help"); Serial.println("R : AD9850 reset"); Serial.println("P : AD9850 power down"); Serial.println("U : AD9850 power up"); Serial.println(); }
// -- END OF FILE --
El jue, 21 ene 2021 a las 9:29, Rob Tillaart (notifications@github.com) escribió:
Any progress?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/RobTillaart/AD985X/issues/9#issuecomment-764503091, or unsubscribe https://github.com/notifications/unsubscribe-auth/APXUEZZ3436FXNTLFKNRKALS27XXFANCNFSM4VOE2FZQ .
I found the bug. a duplicate old library generates the error
pinout picture based on this (or some similar) https://components101.com/modules/ad9850-dds-signal-generator-module
I found the bug. a duplicate old library generates the error
OK good to hear,
Can you post pictures how your hardware configuration looks like?
works great with a single module. the precision is very good, with the TCXO glass it will improve the stability. I need to put the calibration to the AD. is the calibration part included in the library? SELECT_PIN what function does it have?
look at .h file
void setCalibration(int32_t offset = 0) { _offset = offset; };
int32_t getCalibration() { return _offset; };
Default offset of the internal divider = 0, it can be set in integer steps as that is what the chip allows.
Your setup looks quite professional !
Your setup looks quite professional !
thanks
SELECT_PIN what function does it have?
It is the means how the SPI signals (data in , data out and clock) can be shared over multiple SPI devices. Only the chip with the SELECT pin HIGH will respond to the data /clock signals. The others ignore them.
So if you have (N) SPI devices you need at least (3 + N) pins to address them.
Note: some devices do not have data out or data in.
Read - https://www.corelis.com/education/tutorials/spi-tutorial/) Or - https://www.circuitbasics.com/how-to-set-up-spi-communication-for-arduino/
// common terms used SCK = Serial Clock SDI = Serial Data In SDO = Serial Data Out SS = Slave Select CS = Chip Select
Thanks for the info. Sorry, I did not explain well, I understand how SPI and I2C work, what I can't find is where is the select pin on the AD985x? Would you have to do it from external logic doors?
Thank you
I checked the datasheet but apparently there is none. I never tested with more than one at the same time. Good catch!
[think I need to spend a remark on this in the readme ].
What you can do is share the data pin and give every AD9850 a clock of its own.
Thanks for the tip!
El sáb., 23 ene. 2021 15:56, Rob Tillaart notifications@github.com escribió:
What you can do is share the data pin and give every AD9850 a clock of its own.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/RobTillaart/AD985X/issues/9#issuecomment-766103946, or unsubscribe https://github.com/notifications/unsubscribe-auth/APXUEZ4G2IXOQHLTJJPRY33S3LWTZANCNFSM4VOE2FZQ .
You can share the FQ_UD pin too. Toggling it would just confirm earlier settings of the "not selected" devices. As they do not have new settings, they would not change their behavior.
Sharing the FQ_UD pin even has the advantage that in theory it could synchronize the start / change of multiple devices. First you clock new settings to every device, then you pulse all of them with one FQ_UD.
Note that such behavior is not supported by in the library.
What would be needed?
Good idea for next release...
The problem I see is the reset. it is common in both chip. I don't know what problems it would generate. I can duplicate the outputs or it did not complicate me and I put a chip like this CBT3244AD
El sáb., 23 ene. 2021 16:45, Rob Tillaart notifications@github.com escribió:
You can share the FQ_UD pin too. Toggling it would just confirm earlier settings of the "not selected" devices. As they do not have new settings, they would not change their behavior.
Sharing the FQ_UD pin even has the advantage that in theory it could synchronize the start / change of multiple devices. First you clock new settings to every device, then you pulse all of them with one FQ_UD.
Note that such behavior is not supported by in the library.
What would be needed?
- need an autoFQ_UD flag == toggle FQUD manually of automatically (default)
- toggle FQ_UD function
Good idea for next release...
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/RobTillaart/AD985X/issues/9#issuecomment-766137317, or unsubscribe https://github.com/notifications/unsubscribe-auth/APXUEZYLZDUCAY54QTI2GPTS3L4LBANCNFSM4VOE2FZQ .
With respect to the SELECT pin.
What could be done is place an AND port to combine a shared CLOCK and an unique SELECT pin and connect the output to the clock of the AD9850. Then one mimics the SPI bus quite well.
RESET is not part of the SPI bus afaik. But it could be multiplexed too. Optional the same way with an AND port and the SELECT signal.
Need to include these ideas in the readme file.
On Sat, 23 Jan 2021, 22:07 CarlosNet, notifications@github.com wrote:
The problem I see is the reset. it is common in both chip. I don't know what problems it would generate. I can duplicate the outputs or it did not complicate me and I put a chip like this CBT3244AD
El sáb., 23 ene. 2021 16:45, Rob Tillaart notifications@github.com escribió:
You can share the FQ_UD pin too. Toggling it would just confirm earlier settings of the "not selected" devices. As they do not have new settings, they would not change their behavior.
Sharing the FQ_UD pin even has the advantage that in theory it could synchronize the start / change of multiple devices. First you clock new settings to every device, then you pulse all of them with one FQ_UD.
Note that such behavior is not supported by in the library.
What would be needed?
- need an autoFQ_UD flag == toggle FQUD manually of automatically (default)
- toggle FQ_UD function
Good idea for next release...
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/RobTillaart/AD985X/issues/9#issuecomment-766137317, or unsubscribe < https://github.com/notifications/unsubscribe-auth/APXUEZYLZDUCAY54QTI2GPTS3L4LBANCNFSM4VOE2FZQ
.
— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/RobTillaart/AD985X/issues/9#issuecomment-766179055, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADQ77CZOXQ3M6N3K6LOHX3S3M27RANCNFSM4VOE2FZQ .
I'm going to test fast frequency changes on a single chip and then break my head to add the second chip. thanks for your help
El dom, 24 ene 2021 a las 8:41, Rob Tillaart (notifications@github.com) escribió:
With respect to the SELECT pin.
What could be done is place an AND port to combine a shared CLOCK and an unique SELECT pin and connect the output to the clock of the AD9850. Then one mimics the SPI bus quite well.
RESET is not part of the SPI bus afaik. But it could be multiplexed too. Optional the same way with an AND port and the SELECT signal.
Need to include these ideas in the readme file.
On Sat, 23 Jan 2021, 22:07 CarlosNet, notifications@github.com wrote:
The problem I see is the reset. it is common in both chip. I don't know what problems it would generate. I can duplicate the outputs or it did not complicate me and I put a chip like this CBT3244AD
El sáb., 23 ene. 2021 16:45, Rob Tillaart notifications@github.com escribió:
You can share the FQ_UD pin too. Toggling it would just confirm earlier settings of the "not selected" devices. As they do not have new settings, they would not change their behavior.
Sharing the FQ_UD pin even has the advantage that in theory it could synchronize the start / change of multiple devices. First you clock new settings to every device, then you pulse all of them with one FQ_UD.
Note that such behavior is not supported by in the library.
What would be needed?
- need an autoFQ_UD flag == toggle FQUD manually of automatically (default)
- toggle FQ_UD function
Good idea for next release...
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <https://github.com/RobTillaart/AD985X/issues/9#issuecomment-766137317 , or unsubscribe <
https://github.com/notifications/unsubscribe-auth/APXUEZYLZDUCAY54QTI2GPTS3L4LBANCNFSM4VOE2FZQ
.
— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/RobTillaart/AD985X/issues/9#issuecomment-766179055, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AADQ77CZOXQ3M6N3K6LOHX3S3M27RANCNFSM4VOE2FZQ
.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/RobTillaart/AD985X/issues/9#issuecomment-766312073, or unsubscribe https://github.com/notifications/unsubscribe-auth/APXUEZ4FCLX2LHJUBK2MK3TS3PMMFANCNFSM4VOE2FZQ .
@CarlosNet The original topic - decimals in frequency is solved so I close this issue. Will create another one called multi-AD985X how to do that.
Hello Rob. First thank you for your great work You could implement decimals in frequency. I am doing a project that needs to generate frequencies with decimals and it is very complicated for me. I wish if you can integrate at least 3 decimal places. 10,564 Hz. Thanks