I have already solved the BNC cable connection. I am not able to design a proper circuit. I know this could sound like a very trivial issue but this is not my field of expertise. If you can explain me in detail the basic wiring diagram pointing at the precise pins and connections I will be more than greatful.
Friendly English pointer it is "analogue signal" not "analogic signal"
Do what you have not put on your original diagram is the timing between ramps, and where that Square pulse fits in. Is it a separate signal or is it part of the same signal. That is do you have one signal at the far end or two?
The other thing is what you are going to do with it at the far end?
The signal will be a low impedance one, that means it will not be very strong at the far end. So for example you will not be able to drive a light or motor whiteout some sort of signal driver at the far end.
At this point lack of this information is stopping us from getting you a fuller answer.
- Time between ramps vould vary. Let's say I need 3 times. A) 7 seconds B) 30 seconds C) 1 minute
- At the far end I need to send a TTL signal via a BNC to a led driver (T-cuve led driver from thorlabs). You can find in a previous message the specs.
- The square wave is a second device triggered by the arduino and it should start 10 ms before the led driver turns off. But maybe should be wiser to just focus on the ramp and, then once solved, move on the next step. I need to understand a very basic circuit design for the uno and DAC (pins connections and a very basic code).
I know I am asking a huge effort but I know forums are full of amazing guys who can really help
On that link you provided I can only find a T-Cube, not a T-cuve, is it a T-Cube you have?
Understood, but how long should a ramp take? That is starting from a zero voltage, how long should it be before it finishes the ramp?
It probably would be, but it is good to know it is a separate signal and when it occurs.
There are some very good answers here, but sadly bad ones as well. I thought that @barshatriplee was a good first stab at some simple code that could do what you want. Why did you reject it? was it because you didn't have the filter that @JohnLincoln suggested it needed?
Or was it the also excellent idea of using a buffer amplifier that you didn't understand?
How would you like to select the different timings between the ramps, knob, switch or push button? Would you like a switch to control the starting and stopping of the ramps?
Yes there is a lot more the Arduino code has to do rather than just provide the ramps, and we need to know this before we can provide useful (for you) code. There will be some construction you will have to do, will this be soldered or solder less bread board? The solder less bread board can only be a short term solution while you get things going, in the end you or a college will have to do some soldering on strip board.
Thanks again for your help. I really appreciate your efforts.
- T-cube (cuve was a typo).
- let's say the ramp should reach the peak value in 1 second and then remain in a plateau value for 2 more seconds
- i was hoping to not using a buffer amplifier as I don't have one. About the filter, if needed i will add it to the circuit. I do not have the 1 microF capacitor (which I believe it was used in the circuit). I have 100pF or 10microF and 100microF.
- a knob for varying the ramp duration should work.
I do soldering, and I have solderless breadboard and soldering board as well.
The 10microF better written as 10uF is the closest.
OK what about the time between ramps? An other knob?
And an on / off throw switch?
someting along the lines of (blue pulse is to trigger the scope)

then it repears after 7 seconds?

code for ESP32
// ESP32 DAQ using timer interrupts 1000times/second to
// generate 1decond ramp then 2 second pllateau
// adapted from ESP32 Sine Wave Example https://deepbluembedded.com/esp32-dac-audio-arduino-examples/
#include <driver/dac.h>
// Timer0 Configuration Pointer (Handle)
hw_timer_t *Timer1_Cfg = NULL;
// Sine LookUpTable & Index Variable
volatile int SampleIdx = 0;
uint8_t lookupTable1[3000], lookupTable2[3000];
volatile int counter = 0, start=0;
// The Timer0 ISR Function (Executes Every Timer0 Interrupt Interval)
void IRAM_ATTR Timer1_ISR() {
if(!start)return; // wait for signal to start ramp
// SendTable Values To DAC One By One
dac_output_voltage(DAC_CHANNEL_1, lookupTable1[SampleIdx++]);
dac_output_voltage(DAC_CHANNEL_2, lookupTable2[SampleIdx++]);
if (SampleIdx == 3000) {
SampleIdx = 0; start=0; // ramp+plateau finished
dac_output_voltage(DAC_CHANNEL_1, 0);
}
counter++;
}
void setup() {
pinMode(33,OUTPUT); // trigger for scope
Serial.begin(115200);
Serial.println("\nESP32 DAC sine wave");
// Configure Timer0 Interrupt
Timer1_Cfg = timerBegin(1, 80, true);
timerAttachInterrupt(Timer1_Cfg, &Timer1_ISR, true);
// Set alarm to call onTimer function every second (value in microseconds).
// Repeat the alarm (third parameter)
timerAlarmWrite(Timer1_Cfg, 2000, true);
timerAlarmEnable(Timer1_Cfg);
for (int i = 0, dac=0; i < 1000; i++) // setup ramp
lookupTable1[i] = i/5;
for (int i = 1000, dac=0; i < 3000; i++) // serup plateau
lookupTable1[i] = 200;
// for (int i = 0; i < 30; i++)
// lookupTable2[i]=200;
// Enable DAC1 Channel's Output
dac_output_enable(DAC_CHANNEL_1);
dac_output_enable(DAC_CHANNEL_2);
}
void loop() {
digitalWrite(33,HIGH); // trigger for scope
delay(1000);
digitalWrite(33, LOW);
start=1; //start ramp
while(start) delay(10); // wait for end of ramp etc
delay(7000); // delay 7 seconds
start=1; //start ramp
while(start) delay(10); // wait for end of ramp etc
delay(3000);
}
I thinks @zonedro wants to use a Uno. A ESP32 would only produce 3V3 pulses without amplification.
I was thinking more of a state machine solution.
interesting to see if a UNO will generate the required waveform
I have always used DACs or DDS modules and got the hardware engineers to build amplifiers to suit end-users voltage requirements
@zonedro just bought both arduino due and MCP4725.
He doesn't want to use the UNO anymore
I found the due was not a wise choice as it only support 3.3 V output. Therefore I have adopted the uno and the 4725 DAC module. Today I have successfully write a script which deliver the work very smoothly. I am satisfied but I would like to see other and peraphs wiser solutions.
Due version
// Due using timer3 interrupts
// DAQ using timer interrupts 1000times/second to
// generate 1second ramp then 2 second plateau
#include <DueTimer.h>
// Sine LookUpTable & Index Variable
volatile int SampleIdx = 0;
uint8_t lookupTable1[3000], lookupTable2[3000];
volatile int counter = 0, start = 0;
void myHandler() {
if (!start) return; // wait for signal to start ramp
analogWrite(DAC0, lookupTable1[SampleIdx++]);
if (SampleIdx == 3000) {
SampleIdx = 0;
start = 0; // ramp+plateau finished
analogWrite(DAC0, 0);
}
counter++;
}
void setup() {
Serial.begin(115200);
Serial.println("Arduino timer3 ramp then plateau generator ");
// call timer handler every 1000 microseconds
Timer3.attachInterrupt(myHandler).start(1000);
pinMode(DAC0, OUTPUT); // enable DAC output
pinMode(DAC1, OUTPUT);
analogWriteResolution(8); // 8 bit resolution
for (int i = 0, dac = 0; i < 1000; i++) // setup ramp
lookupTable1[i] = i / 5;
for (int i = 1000, dac = 0; i < 3000; i++) // serup plateau
lookupTable1[i] = 200;
}
void loop() {
delay(1000);
start=1; //start ramp
while(start) delay(10); // wait for end of ramp etc
delay(7000); // delay 7 seconds
start=1; //start ramp
while(start) delay(10); // wait for end of ramp etc
delay(3000);
static long timer1 = millis();
if (millis() - timer1 >= 1000) {
Serial.print("Counter ");
Serial.println(counter);
timer1 = millis();
counter = 0;
}
}
gives

Congratulations. Well done on getting something working!
something along the lines of
// Due using timer3 interrupts
// DAQ using timer interrupts 1000times/second to
// generate 1 second ramp then 2 second HIGH plateau then 7 seconds LOW
#include <DueTimer.h>
// Sine LookUpTable & Index Variable
volatile int SampleIdx = 0;
uint8_t lookupTable1[1000];
// generate 1 second ramp then 3 second HIGH plateau then 7 seconds LOW
// then 1 second ramp then 3 second HIGH plateau then 20 seconds LOW
enum states { STOP,
RAMP1,
PLATEAU1,
ZERO7SEC,
RAMP2,
PLATEAU2,
ZERO30SEC };
volatile int state = STOP, stimer = 0, counter = 0;
void myHandler() {
switch (state) {
case RAMP1: // ramp state
case RAMP2:
analogWrite(DAC0, lookupTable1[SampleIdx++]);
if (SampleIdx == 1000) { // if ramp complete
SampleIdx = 0; // reset index
analogWrite(DAC0, 200); // next state is high
stimer = 3000; // plateau timer
switch (state) {
case RAMP1: state = PLATEAU1; break; // ramp finished next plateau
case RAMP2: state = PLATEAU2; break; // ramp finished next plateau
}
}
break;
case PLATEAU1: // plateau state
case PLATEAU2: // plateau state
// analogWrite(DAC0, 200); // is high
if (--stimer) break; // plateau not finished?
analogWrite(DAC0, 0); // next state is LOW
switch (state) {
case PLATEAU1:
state = ZERO7SEC;
stimer = 7000;
break;
case PLATEAU2:
state = ZERO30SEC;
stimer = 20000;
break;
}
break;
case ZERO7SEC: // zero state
case ZERO30SEC: // zero state
//analogWrite(DAC0, 0); // is LOW
if (--stimer) break; // zero not finished
switch (state) {
case ZERO7SEC: state = RAMP2; break; // next state is ramp
case ZERO30SEC: state = RAMP1; break; // next state is ramp
}
break;
}
counter++;
}
void setup() {
Serial.begin(115200);
Serial.println("Arduino timer3 ramp then plateau generator ");
// call timer handler every 1000 microseconds
Timer3.attachInterrupt(myHandler).start(1000);
pinMode(DAC0, OUTPUT); // enable DAC output
pinMode(DAC1, OUTPUT);
analogWriteResolution(8); // 8 bit resolution
for (int i = 0, dac = 0; i < 1000; i++) // setup ramp
lookupTable1[i] = i / 5;
analogWrite(DAC0, 0); // is LOW
Serial.println("hit key to start sequence?");
while (!Serial.available()) delay(10);
state = RAMP1; // initial state
}
void loop() {
static long timer1 = millis();
if (millis() - timer1 >= 1000) {
Serial.print("Counter ");
Serial.print(counter);
Serial.print(" state ");
Serial.println(state);
timer1 = millis();
counter = 0;
}
}
generates a ramp/plateau delay 7 seconds ramp/plateau delay 20 seconds then repeats

That's my code. Please feel free to comment it.
/**************************************************************************/
#include <Wire.h>
#include <Adafruit_MCP4725.h>
#define MCP4725_ADDR 0x60
Adafruit_MCP4725 dac;
const PROGMEM uint16_t DACLookup_Saw_100[100] =
{
0
};
int PWM_PIN = 3;
int con1 = 2800;
int con2 = 10;
int con3 = 200;
int con4 = 5000;
void setup(void) {
Serial.begin(9600);
Serial.println("Hello!");
pinMode(PWM_PIN, OUTPUT);
// For Adafruit MCP4725A1 the address is 0x62 (default) or 0x63 (ADDR pin tied to VCC)
// For MCP4725A0 the address is 0x60 or 0x61
// For MCP4725A2 the address is 0x64 or 0x65
dac.begin(0x60);
Serial.println("Generating a triangle wave");
}
void loop(void) {
// Generate a sawtooth wave
for(int i = 0; i < 4096; i++) {
dac.setVoltage(i, false);
delay(1);
}
dac.setVoltage(0, true);
delay(1);
analogWrite(PWM_PIN,HIGH);
delay(con2);
dac.setVoltage(0, true);
analogWrite(PWM_PIN,LOW);
delay(con4);
}```
Hello everyone,
I have uploaded the code, but I have noticed that the generated ramp is ok, but the square output (which should last 10 ms and starts 10 ms before the ramp return to zero -thus while the ramp is hitting the plateau) is being delivered after the ramp is off/low.
@horace thanks for your support, but in the end I will not use arduino due as 3.3V output is not suited for my output
Try this:
/**************************************************************************/
#include <Wire.h>
#include <Adafruit_MCP4725.h>
#define MCP4725_ADDR 0x60
Adafruit_MCP4725 dac;
const PROGMEM uint16_t DACLookup_Saw_100[100] =
{
0
};
int PWM_PIN = 3;
int con1 = 2800;
int con2 = 10;
int con3 = 200;
int con4 = 5000;
void setup(void) {
Serial.begin(9600);
Serial.println("Hello!");
pinMode(PWM_PIN, OUTPUT);
digitalWrite (PWM_PIN,LOW);
// For Adafruit MCP4725A1 the address is 0x62 (default) or 0x63 (ADDR pin tied to VCC)
// For MCP4725A0 the address is 0x60 or 0x61
// For MCP4725A2 the address is 0x64 or 0x65
dac.begin(0x60);
Serial.println("Generating a triangle wave");
}
void loop(void) {
// Generate a sawtooth wave
for(int i = 0; i < 4096; i++) {
dac.setVoltage(i, false);
delay(1);
if (i == 4085){
digitalWrite (PWM_PIN, HIGH);
}
}
dac.setVoltage(0, true);
digitalWrite (PWM_PIN, LOW);
delay(con4);
}
Change dac.setVoltage(0, true); to dac.setVoltage(0, false);
Mike! Haven't seen you post in a long time, was starting to wonder.
We lost too many.
