# Fastest DAC Transmission Possible

Hello everyone,

I'm trying to control a galvoscanner for laser scanning purposes and I wondered if I can use Arduino for this purpose. Then I found MCP4725 DAC card for Arduino. Followed the examples that is shared by Adafruit. But as far as I can see and I could achieve with a decent quality of waveform, maximum achievable signal rate is around 20 Hz. But we may need more than 1kHz, at least it should be more than 500Hz.

How can achieve that kinda fast signal rates? Any suggestions except Arduino is welcome too.

“Fast Mode I²C you can update the VOUT at ~200 KHz”

JarkkoL:
"Fast Mode I²C you can update the VOUT at ~200 KHz"

How can I generate that kinda fast signal (i.e. sawtooth with 150kHz), could you please explain?

Any ideas, fellas?

First, define the problem. An Arduino can easily generate "signals" in the MHz frequency range.
Using a lookup table, you can send data to an ADC as fast as it can be driven.

Let's expand this excellent response:

jremington:
First, define the problem. An Arduino can easily generate "signals" in the MHz frequency range.
Using a lookup table, you can send data to an ADC as fast as it can be driven.

and the MCP4725 speed would be constrained by the I2C bus which is the limiting factor. An SPI based DAC could be orders of magnitude faster but how fast is fast enough? It all depends upon what other tasks the processor is performing and you've provided no details of what those tasks might be.

At the risk of repeating the above quote, until the context of the entire problem is presented, you're just getting a back-of-the-napkin guess for a solution where the problem is yet to be defined.

"achieve with a decent quality of waveform"

What kind of waveform are you trying to create?

I thought the problem was clear, let me explain a bit in detail then. I'm trying to generate a waveform which is changing in time (like sweeping). To do that, I need to send the digital data that I'm generating to form the waveform, to DAC. That's because our servo driver accepts an analog inputs. Angle of rotation of the mirrors on galvoscanner system is related to voltage level. So I need to control the voltage values to rotate in way I desired.

I thought that for this purpose I might use Arduino. Then I found MCP4725. Using 512 data points to form the sinewave, I was only able to achieve 13.5 Hz. Decreasing sample rate to 256, increases it to 27 Hz. But the quality of the waveform decreases. We don't want this since we need a precise motion.

So question is simple: For that kinda application, which approach should I use? I know the fact that I2C transmission is the bottleneck here. But I don't know what to do to go beyond 500 Hz.

For informed help, supply some information, like the code you used, the I2C data rate, the data sheet for the galvanometer, you know, stuff like that.

We don't want this since we need a precise motion.

Define "precise motion".

It sounds like the problem is not the transmission rate to the DAC but the computation of the datapoints.

Post your code if you want more help OP.

I'm guessing it is the opposite problem. Sending the data is slow.

The problem is definitely in the code, though.

Define "precise motion".

He did say "laser scanning galvanometer", which carries a fair amount of implications on speed and accuracy - essentially you're trying to scan a video-sized vector field mechanically, and human PoV rates (depending on actual application. But think Galvo Scanners for Laser Light Show Applications - YouTube - really fast...)
(Just because we don't fully understand the application doesn't mean they haven't given a moderately good description. OTOH, if you're going to ask a "generic" community a question, it's good to phrase it in generic terms, rather than "jargon" from a particular sub-segment of the field.)

Using 512 data points to form the sinewave, I was only able to achieve 13.5 Hz.

"512 datapoints to form the sinewave" means 512 values in each half of the sinewave, or each whole sinewave?
In any case, an I2C 12-bit DAC like the MCP4725, running a simple driver, takes about 4 bytes for each sample. (32bits * ~1000 points/sinewave * 13 sinewaves/s is about 400kbps, which is a pretty good match for the 400kHz of "fast" I2C.
The MCP4725 also supports 3+MHz "high speed" mode, but the AVR doesn't (I don't know whether the AVR will go above 400kHz...)
But 1000 sinewaves/s * 1000 samples/sinewave * 16bits/sample (for a more optimized driver) is 16Mbps, which is completely out of the question for an AVR-class microcontroller, or an I2C DAC.

He did say "laser scanning galvanometer", which carries a fair amount of implications on speed and accuracy

Not to me. The OP hasn't bothered to post a single useful detail, and leaves the distinct impression that some basic understanding is lacking.

Edit: interesting thread on >800 kHz I2C clock rates, with the MCP4728 DAC, but as noted in reply #5, SPI DACs are readily available.

I have been using Teensy 3.6, which has two 12bit DAC’s capable for pretty high sampling rates. Someone was saying he was able to produce decent sine wave with it at 100-200kHz. Also MKR Zero has 10bit DAC but not sure about the sampling rate.

westfw:
He did say "laser scanning galvanometer", which carries a fair amount of implications on speed and accuracy - essentially you're trying to scan a video-sized vector field mechanically, and human PoV rates (depending on actual application. But think Galvo Scanners for Laser Light Show Applications - YouTube - really fast...)
(Just because we don't fully understand the application doesn't mean they haven't given a moderately good description. OTOH, if you're going to ask a "generic" community a question, it's good to phrase it in generic terms, rather than "jargon" from a particular sub-segment of the field.)"512 datapoints to form the sinewave" means 512 values in each half of the sinewave, or each whole sinewave?
In any case, an I2C 12-bit DAC like the MCP4725, running a simple driver, takes about 4 bytes for each sample. (32bits * ~1000 points/sinewave * 13 sinewaves/s is about 400kbps, which is a pretty good match for the 400kHz of "fast" I2C.
The MCP4725 also supports 3+MHz "high speed" mode, but the AVR doesn't (I don't know whether the AVR will go above 400kHz...)
But 1000 sinewaves/s * 1000 samples/sinewave * 16bits/sample (for a more optimized driver) is 16Mbps, which is completely out of the question for an AVR-class microcontroller, or an I2C DAC.

Thank you for the detailed answer. The code I used is down below.

Regarding the "precise motion" question, I still don't understand why I share that information but, it should be 0.01 degrees for the servo motor. I'm pretty sure it still means nothing to you. We are building an SD-OCT system and developing a new scanning protocol. It means nothing if I see a ladder pattern when I zoom in to a sine wave. It's because the motion must be precise to make measurements with a decent amount of error. I hope it means something now.

I just need to send the digital data as fast as I can and convert it to analog data. That was all you need to know guys. I don't understand why some of the people stuck with the other details which are out of scope. All I want to know, am I able to achieve 1 kHz sinewave using DAC? If yes, how? I need practical answers, not theoretical ones. I know how to Google it too. But I haven't seen any applications like that. The examples that I saw was not beyond 50 Hz. So that's why I said, "Any suggestions except Arduino is welcome too."

Hello Flexar,

Regarding the "precise motion" question, I still don't understand why I share that information but, it should be 0.01 degrees for the servo motor. I'm pretty sure it still means nothing to you.

Please remember this forum is run by and for volunteers, not paid professionals. The people on here range in expertise from absolute beginner to experts in electronics and computers who have worked all their lives in a wide variety of industries. What those of us giving answers share is a desire to help others if we can. You need to share whatever is asked for for 2 reasons in my opinion; there might be someone here who has done what you are trying to do who, when they know the exact thing you are trying to achieve will be able to give you a really good solution. That solution might be different to anything you imagined, but might be just what you are looking for. If you don't provide the details, you miss the chance of that solution. The other reason is this is a hobby, we do this for pleasure. Maybe we are interested in what you are doing. My 'payment' if I can call it that, for providing help and information is seeing what others are up to and maybe learning from them and maybe being inspired by other people's projects.

So please, if you want help, be prepared to willingly give whatever information is asked for.

I thank you.

PerryBebbington:
Hello Flexar,

Please remember this forum is run by and for volunteers, not paid professionals. The people on here range in expertise from absolute beginner to experts in electronics and computers who have worked all their lives in a wide variety of industries. What those of us giving answers share is a desire to help others if we can. You need to share whatever is asked for for 2 reasons in my opinion; there might be someone here who has done what you are trying to do who, when they know the exact thing you are trying to achieve will be able to give you a really good solution. That solution might be different to anything you imagined, but might be just what you are looking for. If you don't provide the details, you miss the chance of that solution. The other reason is this is a hobby, we do this for pleasure. Maybe we are interested in what you are doing. My 'payment' if I can call it that, for providing help and information is seeing what others are up to and maybe learning from them and maybe being inspired by other people's projects.

So please, if you want help, be prepared to willingly give whatever information is asked for.

I thank you.

Of course, I'm aware of all of that and I totally understand. I'm managing a volunteer job for many years too. I'm willing to share the information that is needed, but I don't understand the rude replies caused by lack of information. People don't have to answer my question. If you don't like it, just leave it alone. We all spend our time in here.

Also, I didn't share all the information because I can not share my project details. People should have to think if I'm not sharing any information it might have a reason. That's why I was "question oriented".

Flexar:
I thought the problem was clear, let me explain a bit in detail then. I'm trying to generate a waveform which is changing in time (like sweeping). To do that, I need to send the digital data that I'm generating to form the waveform, to DAC. That's because our servo driver accepts an analog inputs. Angle of rotation of the mirrors on galvoscanner system is related to voltage level. So I need to control the voltage values to rotate in way I desired.

I thought that for this purpose I might use Arduino. Then I found MCP4725. Using 512 data points to form the sinewave, I was only able to achieve 13.5 Hz. Decreasing sample rate to 256, increases it to 27 Hz. But the quality of the waveform decreases. We don't want this since we need a precise motion.

So question is simple: For that kinda application, which approach should I use? I know the fact that I2C transmission is the bottleneck here. But I don't know what to do to go beyond 500 Hz.

Provide a datasheet for the servo driver and galvo scanner please, I thinking xyproblem here.

Normally you can get away with far fewer than 512 samples per period for accurate sine
wave generation in a low-pass-filtered situation, this is what DDS signal generation relies on.

MarkT:
Provide a datasheet for the servo driver and galvo scanner please, I thinking xyproblem here.

Normally you can get away with far fewer than 512 samples per period for accurate sine
wave generation in a low-pass-filtered situation, this is what DDS signal generation relies on.

Thank you for your interest. Unfortunately, we are using ScannerMax Compact 506 Galvoscanner and company don't share that information on their manual. But I'm sure it's not related galvos since we measure the analog signal on an oscilloscope.

You are right about using less than 512 data points, but this is not the actual limit for us. We are too far to reach the 1 kHz limit. Changing it to 256 samples gives us a 2x factor but it is still insufficient.

Well I found the datasheet: https://www.scannermax.com/pdf/C506.pdf

Some pretty potty choices of units there, but basically
its torque constant is 1.84 mN/A and MoI unloaded is 1.4x10^-9 kg m^2, which
indicates a few kHz as the frequency roll off point

Given the response is in the audio range, Why not try 16kSPS with an SPI DAC using DDS generation?
Or even a DDS module?