Go Down

Topic: send digital float value to DAC (mcp4725) and take analog output !!! (Read 229 times) previous topic - next topic

navid1998

hello guys .. :)

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  :(  :(  :(  :(  :(  :(  :( !!!

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

sherzaad

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);

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


sherzaad

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: https://learn.sparkfun.com/tutorials/mcp4725-digital-to-analog-converter-hookup-guide?_ga=2.207929042.1710487460.1563220294-1571602782.1494565492)

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

Code: [Select]
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;
}

navid1998

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

sherzaad

I said:

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??

navid1998

- 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

Go Up