tirsdag den 31. maj 2011

Diagrams

The diagram for the analog setup:












 




The diagram for the code structure:


mandag den 30. maj 2011

Code and DAC construction

After making the diagrams, I constructed the code and the DAC.
The DAC ended up looking like this:

















The four red wires coming from the PIC is the four input bits.
The other wires are connections for 15 volts, -15 volts, output and ground.

The code for the counter is as follows:

#include 

void main()
{
 TRISD = 0;
 
 PORTD = 0b00000000;

while(1)
{

PORTD++;

if(PORTD == 16)
{
 PORTD = 0; 
}

for(int i = 0 ; i < 30000 ; i++);
 
}
}

Measuring results

 After getting the code to run and assembling the 4 bit DAC converter I went to the lab to measure it.
The code is written to make a slow curve. The upper curser is placed at approximately 0 volts and the lower curser is set at approximately – 4 volt.

Step up jump zero. Cycle time 1.5 second

















Step up step down. Cycle time 3 seconds

















Sinus wave. Cycle time 3.6 seconds
















Here is a video of the sinus wave: