What is maximum frequency of sinus signal that can be generated using Arduino R4 - Page 1
Forum section: electronics / general

author: FlyingDutch
author_rank: Regular Contributor
timestamp: September 03, 2024, 11:46:38 am
content: Hello,I cannot find in datasheet what is maximum frequency of sinus signal generated from 32 samples using internal DAC in "Arduino UNO R4 Minima". I wasn't able to find this information on Arduino website, nor in Renesans manual of MCU R7FAM1AB3CFM. Found information that max. square signal frequency is about 52 KHz.Could somebody give me estimated max. frequency of sinus signal generated from min. 32 samples.Thanks in advance and regards

author: pcprogrammer
author_rank: Super Contributor
timestamp: September 03, 2024, 11:55:08 am
content: Quote from: FlyingDutch on September 03, 2024, 11:46:38 amLook in the datasheet what the maximum update rate of the DAC is. In other words what the maximum sample rate can be. Then divide this by your 32 samples and you have your answer.Also depends a bit on how you write to the DAC and how fast the CPU is. When using DMA, if available, it can be faster than using a software loop to write the samples.

author: Psi
author_rank: Super Contributor
timestamp: September 03, 2024, 12:14:35 pm
content: If you're after speed rather than accuracy you might also consider creating an artificial PWM based DAC using a timer.I'm not sure what speed that chip can do timer wise but it has a 64mhz clock. So it can likely clock a timer at 64mhz.Limit the timer count max to 32 and your down to a 2mhz cycle.

author: PCB.Wiz
author_rank: Super Contributor
timestamp: September 03, 2024, 09:41:09 pm
content: Quote from: FlyingDutch on September 03, 2024, 11:46:38 amYou may need to experiment, to see what can be done.Depending on the internal DAC design, you might be able to go (much) faster than the paper values.eg on a SiLabs MCU DAC, I've managed to directly INC/DEC the DAC register at up to 36MHz, which is way above their paper rate, but it keeps inside their slew rate spec, because only one LSB step changes at a time.It is also possible to generate sines faster than their paper rate, provided you keep inside the slew rate.A 32 step sine has only a small step change.The Renesas DAC data saysConversion time - - 30 μs-> 1041.666667 Hz max at your 32 samples per cycle.I cannot see a slew rate number.So you need to experiment, ie write a tight loop that dumps your table to the DAC and check it works at 30us per update, then speed that up until it breaks.If it appears to be slew rate limited, you can generate a smaller amplitude sine and add external gain to nudge the rate up faster.Addit: Google finds thishttps://forum.arduino.cc/t/arduino-uno-r4-dac-speed/1177741/8There, scopes shots give you exactly what you needOne example has updates at 588kHz and showsa DAC slew rate of about 5V in 2us or 2.5V/usYou can generate a triangle wave of roughly 5V amplitude up to 250kHz, at that top rate, actual values depend on slew rate, not DAC precision.A sine wave must fit inside that triangle, so you could choose a lower amplitude at 250kHz or a lower frequency.This comment in the code examples given is in one exampleCode:*DAC12_DADR0 = loop_count++; // DAC update - takes c. 210nS - DAC ignores top 4 bitsThat comment suggests ~150kHz for your 32 sample sine.For DDS you need to increment and table lookup, so if we guess that takes 312ns, you hit 100kHz ballpark for your 32 sample sine, using 100% MCU bandwidth.Looks like you hit a code speed limit just before you hit the DAC slew limit, if chasing full swing Sine out, for your 32 steps.Fewer steps will hit the slew limit first.

author: radiolistener
author_rank: Super Contributor
timestamp: September 04, 2024, 12:53:24 am
content: Quote from: FlyingDutch on September 03, 2024, 11:46:38 amMaximum sinus frequency is square wave signal which requires min 2 samples.You mentioneds that max square wave is 52 kHz which is for period 2 samples.So the max frequency with 32 samples will be 52 * 2 / 32 = 3.25 kHz.

author: FlyingDutch
author_rank: Regular Contributor
timestamp: September 04, 2024, 06:03:39 am
content: Quote from: pcprogrammer on September 03, 2024, 11:55:08 amHi,there is lack of this information (maximum data rate) in DAC datasheet. If I had this information, I wouldn't ask the question on the forum.Best Regards

author: westfw
author_rank: Super Contributor
timestamp: September 04, 2024, 06:54:42 am
content: Quotehuh?Right there in Table 48.51 "D/A conversion characteristics): Conversion time: 30us (max)That implies a a minimum max frequency for 32 steps of about 1kHz...(ok, the chapter about the DAC is pretty sparse. I don't even see info on clocking, there.)

author: pcprogrammer
author_rank: Super Contributor
timestamp: September 04, 2024, 07:15:01 am
content: Quote from: PCB.Wiz on September 03, 2024, 09:41:09 pmThe datasheet states a MAX conversion time of 30uS which means worst case sample rate to be 33,333kSa/s. There is no minimum specified so the sample rate can be much higher.The datasheet also specifies a resistive and capacitive load. Minimum resistive load is 30k Ohm and the maximum capacitive load is 50pF. This is also of influence on the slew rate, and thus max obtainable output frequency.Maybe there is more information to be found in the other manuals for this MCU. See:https://www.renesas.com/us/en/products/microcontrollers-microprocessors/ra-cortex-m-mcus/ra4m1-32-bit-microcontrollers-48mhz-arm-cortex-m4-and-lcd-controller-and-cap-touch-hmi#documents

author: westfw
author_rank: Super Contributor
timestamp: September 04, 2024, 08:29:44 am
content: QuoteWhat technology DAC has varying conversion times? Usually you're talking just some sort of resistor ladder, not even clocked. (And I don't see anything in the datasheet about any sort of clock provisioning for the DAC...)OTOH, given a 12bit DAC, you may get conversions to 8bit accuracy faster than the max time, I guess.

author: PCB.Wiz
author_rank: Super Contributor
timestamp: September 04, 2024, 08:43:54 am
content: Quote from: westfw on September 04, 2024, 08:29:44 amSee my reply and links that include scope shots (one added below) and sample code in #3You can update the DAC register much faster than 30us.The missing parameter that matters is slew rate,other vendors give this.

author: pcprogrammer
author_rank: Super Contributor
timestamp: September 04, 2024, 09:39:18 am
content: In thehardware manualthere is mention of "tDCONV" that specifies the delay after writing to the DAC data register, but there is no value given for it.So to know the absolute maximum speed at which the DAC can reliably be written just do a test with a fast scope and a single capture of a transition from 0 to 4096. This will show how fast the signal can change and be a measure for the maximum useful sample rate.

author: westfw
author_rank: Super Contributor
timestamp: September 04, 2024, 06:28:01 pm
content: Yeh; sucky datasheet. There aren't enough details in the DS of what might affect tdConv, either. The "block diagram" is full of info on the "prevent interaction with ADC" logic, but shows the DAC itself as a monolithic empty box. Grr.QuoteAlthough, if the conversion time is dependent on how big a jump is made, then the OP's desire for a 32-step sine wave is likely to able to go faster...Time for experiments, I guess.

author: PCB.Wiz
author_rank: Super Contributor
timestamp: September 04, 2024, 09:19:50 pm
content: Quote from: pcprogrammer on September 04, 2024, 09:39:18 amEven that is simplistic.The waveforms and tests I linked already in #3, show there are two delays.A propagation delay from Write until the register value is applied, and the output starts changing,PLUSa Slew Rate defined delay, until that value settles.Hopefully the propagation delay is consistent, and the slew rate means the conversion settle time varies with step size.A sine wave model table at higher speeds, could use that slew info to give better values ?The code used in test #3, sets the control register once, and can continually update the DADR0Code:*DAC12_DACR = 0x5F; // D/A Control Register -..void loop() // Total loop() - takes c. 667nS per loop; or c. 750nS per loop with if() exit{*PFS_P107PFS_BY = 0x05; // Set D7 output high - takes c. 83nS*DAC12_DADR0 = loop_count++; // DAC update - takes c. 210nS - DAC ignores top 4 bits*PFS_P107PFS_BY = 0x04; // Set D7 output low - takes c. 83nS}

author: radiolistener
author_rank: Super Contributor
timestamp: September 05, 2024, 01:33:56 am
content: I don't understand what is confusing you?Since it can produce max 52 kHz with 2 samples per period, it's pretty simple to calculate max frequency for 32 samples per period:52 * 2 / 32 = 3.25 kHz