Hello everyone, this is my first time using this forum.
I’m trying to generate an exponential signal using the MCP4725 (one digital to analog converter, with a 12 bits resolution)
To generate the signal I’m using the next equation:
y = (x*0.5)^2
With this equation I just take the first 128 values, because in this range I get from 0 to 4096 levels corresponding to my 0 to 5V.
This is my code:
#include <Wire.h>
#include <Adafruit_MCP4725.h>
Adafruit_MCP4725 dac;
uint16_t datos[128];
int i;
int y;
void setup() {
dac.begin(0x60);
Serial.begin(9600);
for(i = 1; i < 129; i++)
{
y = pow((i*0.5),2);
datos *= y; *
- }*
}
void loop() { - for(int j = 0; j < 128; j++)*
- {*
- dac.setVoltage(pgm_read_word(&(datos[j])), false);*
- Serial.println(datos[j]);*
- }*
}
I have the equation inside of a “for” to get the values of the equation and then I save those values in the array.
The problem then, is when I take those values from the array and send them. I plot the values with arduino and i got this: (First image)
But then in the oscilloscope I have this: (Second Image)
Does someone have an idea of what could be the problem or how could I solve it?