Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

DAC0832 simulating with Proteus and Arduino

Status
Not open for further replies.

pabspagg

New Member
Hi,
I am doing a project for an electronic class I am taking.
What I have to do is : Using an arduino as a counter ( 8 bits Counter) connected to a DAC0832 and in the output generating a Sine wave ( I can't use arduino for generating the sine wave. I will use amp ops later ). The last part I haven't simulate yet.
Cicuito Proteus com simulação.PNG

The problem is the following: I want the wave output to be triangular at first, with steps ups and downs . But now I am only getting the steps going down ( I am using an AMP OP inverter) and it's not going up ( Why not? ) . As you can see in the image, the arduino code is working 100%. It's going from 0 to 255 then 255-0. ( I am only showing part of it).

ArduinoContagem.PNG

Thanks a lot!
Sorry for the bad english :)
 
hi p,
Look at this clip from the datasheet, the Vout polarity is negative.
E
A002.gif
 
hi p,
Try to simulate this version of the circuit taken from the datasheet.
E
A003.gif
 
hi p,
If you post your program listing I am sure one of us could help.
Looking at your print out, you seem to be incrementing the DAC input, in one bit steps, the input inc/dec should follow a Sine wave sequence.
E
 
Can you post the code.... The simulation shows a ramp output... Its the code you need to change.. you have decreasing amounts going to the DAC but then when it hits bottom you need to slowly increase not start all over!!
 
When portd-- != 0.... It'll mess up with this...

The easier way is an index

C:
int inc = 1;
void setup() {
   PORTD = 0;
   DDRD = 255;
}

void loop()
   {
    PORTD += inc;
    delay(100);
     if ( PORTD > 254 ) inc = -1;
     if ( PORTD < 1 ) inc = 1;
    }
 
Last edited:
After trying a lot to solve the problem. The issue was indeed the code. It turned out that it wasn't a viable option using PORT manipulation on arduino .
Here's the new one .
Code:
int led[8] = {0,1,2,3,4,5,6,7};
boolean A[8];
int inc=1;
int saida=0;

void setup() {  
  for(int i=0;i<8;i++)  {   
    pinMode(led[i], OUTPUT);  
  }  
}

void loop() {  
  saida += inc;  
  if( saida > 254 )  {   
      inc= -1;  
    }  
  if( saida < 1 )  {   
      inc= 1;  
    }  
  conversor();  
 
  for(int i=0;i<8;i++)  {   
    digitalWrite(led[i],A[i]);  
  }  
}
void conversor(){
  int valor=saida;
  for(int i=0;i<8;i++)  {
      if(valor%2>0)    {
          A[i]=1;
        }
        else    {
          A[i]=0;
        }
      valor=(valor/2);
    }
  }

The output I am getting now. There's some noise. I'm still trying to figure out how to remove this.

new.PNG
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top