send digital float value to DAC (mcp4725) and take analog output !!!

hello guys .. :slight_smile:

I want to send float value to SDA pin of the mcp4725 ..

  • how to send it ?

i have alternative float value from de Adc , just want convert digital value to analog wave and see in OSC.

Please Help me solve it :frowning: :frowning: :frowning: :frowning: :frowning: :frowning: :frowning: !!!

#####See the picture below#####

mcp4725 can ONLY accept 0-4095 INTEGER value.

why not send just the ADC value? that too would be an integer value!

if the sending ADC resolution is not the same as the DAC resolution then all you would need to do on the receiving side is use the 'map' function to output to the DAC.

ie something like this:
uint32_t DAC_out = map(recv_value, 0, ADC_RESOLUTION, 0, DAC_RESOLUTION);

ahaa ok !

if i send Adc integer value to DAC , what should I do ??

#note : ADC resolution is the same as the DAC resolution - 12bits

please more help me

navid1998:
ahaa ok !

if i send Adc integer value to DAC , what should I do ??

#note : ADC resolution is the same as the DAC resolution - 12bits

please more help me

something like this probably. (source: MCP4725 Digital to Analog Converter Hookup Guide - SparkFun Learn)

Just substitute the 'sintab2[lookup]' with your received ADC value

void loop()
{
  Wire.beginTransmission(MCP4725_ADDR);
  Wire.write(64);                     // cmd to update the DAC
  Wire.write(sintab2[lookup] >> 4);        // the 8 most significant bits...
  Wire.write((sintab2[lookup] & 15) << 4); // the 4 least significant bits...
  Wire.endTransmission();
  lookup = (lookup + 1) & 511;
}

You said just replace the int value with 'sintab2[lookup]' !

  • Like this? Is that correct ? ? ?

code:

void loop()
{
Wire.beginTransmission(MCP4725_ADDR);
Wire.write(64); // cmd to update the DAC
Wire.write(sintab2[Adc_Value] >> 4);
Wire.write((sintab2[Adc_Value] & 15) << 4);
Wire.endTransmission();
lookup = (Adc_Value+ 1) & 511;
}

i'm confused

I said:

sherzaad:
Just substitute the 'sintab2[lookup]' with your received ADC value

and this is what you do: sintab2[Adc_Value] ??????

Sigh....

No wonder you're 'confused'! maybe ACTUALLY learning how to code might help you!

the link I shared gives you an example code to generate a sine wave (preloaded into an array) using the mcp4725. perhaps you should try that first and have a play with it to understand how to change it...

PS: "lookup = (lookup + 1) & 511;" in post #3 is part of the EXAMPLE code is used to loop though the sintab2 array. do YOU have an array in your code??

  • look, I haven't worked with DAC before, I'm so confused.

Let me simple say, I have an ECG signal input that ADC sends it via wifi to esp and I want to
turn it into an analog signal that I can see with osc.

-My problem is that I can not do it.
-Is sinTab still needed for this task!
-If so how?

I'm sorry to ask a lot but I need to solve my problem