Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PIC Sinewave design issue: the wave increases in lenght.

Status
Not open for further replies.

JJFORTY

Member level 1
Joined
Nov 16, 2004
Messages
40
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
368
PIC SINEWVAE DESIGN

Hi

I'm new to PIC's I'm trying to generate a sinewave using lookup table I created my code below which gives a pretty good sinousoidal the problem is that as the wave increases in lenght the amplitude decreases .. I can't figure out why.. is it the code is it the DAC .. Please give me your comments

Thanks in Advance

Code:
	list p=16f84

	; Include file, change directory if needed
	include "p16f84.inc"

	org 0x00
INIT
	bsf STATUS,RP0
	clrf PORTB
	clrf TRISB 
	bcf STATUS,RP0
BEGIN

        movlw B'00000000'
	movwf PORTB
	movlw B'00000001'
	movwf PORTB
	movlw B'00000001'
	movwf PORTB
	movlw B'00000010'
	movwf PORTB
	movlw B'00000010'
	movwf PORTB
	movlw B'00000010'
	movwf PORTB
	movlw B'00000011'
	movwf PORTB
	movlw B'00000011'
	movwf PORTB
	movlw B'00000100'
	movwf PORTB
	movlw B'00000100'
	movwf PORTB
	movlw B'00000100'
	movwf PORTB
	movlw B'00000101'
	movwf PORTB
	movlw B'00000101'
	movwf PORTB
	movlw B'00000101'
	movwf PORTB
	movlw B'00000101'
	movwf PORTB
	movlw B'00000101'
	movwf PORTB
	movlw B'00000101'
	movwf PORTB
	movlw B'00000101'
	movwf PORTB
	movlw B'00000101'
	movwf PORTB
	movlw B'00000101'
	movwf PORTB
	movlw B'00000100'
	movwf PORTB
	movlw B'00000100'
	movwf PORTB
	movlw B'00000100'
	movwf PORTB
	movlw B'00000011'
	movwf PORTB
	movlw B'00000011'
	movwf PORTB
	movlw B'00000010'
	movwf PORTB
	movlw B'00000010'
	movwf PORTB
	movlw B'00000010'
	movwf PORTB
	movlw B'00000001'
	movwf PORTB
	movlw B'00000001'
	movwf PORTB
	movlw B'00000000'
	movwf PORTB
	movlw B'11111111'
	movwf PORTB
	movlw B'11111111'
	movwf PORTB
	movlw B'11111110'
	movwf PORTB
	movlw B'11111110'
	movwf PORTB
	movlw B'11111101'
	movwf PORTB
	movlw B'11111101'
	movwf PORTB
	movlw B'11111101'
	movwf PORTB
	movlw B'11111100'
	movwf PORTB
	movlw B'11111100'
	movwf PORTB
	movlw B'11111100'
	movwf PORTB
	movlw B'11111011'
	movwf PORTB
	movlw B'11111011'
	movwf PORTB
	movlw B'11111011'
	movwf PORTB
	movlw B'11111011'
	movwf PORTB
	movlw B'11111011'
	movwf PORTB
	movlw B'11111011'
	movwf PORTB
	movlw B'11111011'
	movwf PORTB
	movlw B'11111011'
	movwf PORTB
	movlw B'11111011'
	movwf PORTB
	movlw B'11111100'
	movwf PORTB
	movlw B'11111100'
	movwf PORTB
	movlw B'11111100'
	movwf PORTB
	movlw B'11111101'
	movwf PORTB
	movlw B'11111101'
	movwf PORTB
	movlw B'11111101'
	movwf PORTB
	movlw B'11111110'
	movwf PORTB
	movlw B'11111110'
	movwf PORTB
	movlw B'11111111'
	movwf PORTB
	movlw B'11111111'

goto   BEGIN

	end
 

Re: PIC SINEWVAE DESIGN

Do you have a schematic you can post? What is you oscillator frequency for the PIC? If I am correct in looking at you oscillicope plot it seems you frequency is contant and only you amplitude is changing. What is you load, just the scope probe? Also did you cosider using a buffer, possibly a transistor?
 

Re: PIC SINEWVAE DESIGN

Hi pgiatis thanks for answering.

schematic is at the botton of the post. Crystal is 4Mhz.. no load just the scope + a LPF at output.
 

PIC SINEWVAE DESIGN

some suggestions:
- put the probe at the output of the dac (set it to 10x or higher to avoid loading). same result? it will help you isolate the problem.
- is the period of the wave 128 uS? it should be something close to that.
- take a close look at your filtering ection. I didn't study it but I'd bet its something in there.
- do you realy need all that filtering? a simple RC low pass at 4X your max frequency should kill all the DDS noise.
- check your unity gain opamp, wired correctly?
 

    JJFORTY

    Points: 2
    Helpful Answer Positive Rating
Re: PIC SINEWVAE DESIGN

Which DAC is it? From the looks of it it has a differential current output and I
agree with philba on the filtering - it looks odd.
 

Re: PIC SINEWVAE DESIGN

Checking ..

DA = DAC08
 

Re: PIC SINEWVAE DESIGN

Oh, that old one... ;)
Then you should follow the example in the datasheet, shown below.

I'm guessing that what you see on your scope is the ringing caused by the
inductors, each time the output of the DAC changes by a step, so remove
all filter components except the load resistor. When you get a signal through
you can start playing with the filter again - if needed.
 

    JJFORTY

    Points: 2
    Helpful Answer Positive Rating
Re: PIC SINEWVAE DESIGN

As u said XNOX_Rambo the waveform was caused by the inductors, I removed the whole filter section and use the diagram from datasheet but still nada. I get an output form DAC pin 4 of -3.80V even if I disconect the PIC.. is this correct? I'm using +5/-5 to power the chip and +5 for VREF. How can I know if the DAC is working ?
 

Re: PIC SINEWVAE DESIGN

You could try and decrease IREF. The datasheet says "When operating at supplies
of ±5 V or less, IREF≤1 mA is recommended."

You could also run the DAC "manually" by connecting D7 to +5V and the rest of
the input bits to GND. Then the output should be -(IREF•RL)/2, i.e. the half-scale
value - and if you try other bit combinations the output should vary accordingly.
 

Re: PIC SINEWVAE DESIGN

Thanks for your replies XNOX_Rambo an philba..

After so many goes.. I decided to change the DAC08 to AD558 and go an output straight away.. Very HAppy.. -- Now output a bit doted can you suggest any good filter to remove points..

Thanks again..
 

PIC SINEWVAE DESIGN

like I said earlier - try a simple low pass filter. resistor in series, cap to gnd, after the resistor. formula for the 3db frequency is:
f = 1/(2PiRC) R in ohms, C in fahrads.
3db means the frequency when the amplitude is reduced by 1/2

Since your highest frequency is something like 8Khz, I'd pick values that make the 3db point something like 32Khz. All those "bumps" which are higher frequency components of your waveform should be significantly diminished. You might want to play with the 3db cutoff point a bit. Just remember that the resistor affects your impedence, don't make it too high.
 

Re: PIC SINEWVAE DESIGN

Why don't u use SPI based DACs from analog device...
 

Re: PIC SINEWVAE DESIGN

A simple R-2R network even with no precision resistors (20K and 10K) could have shown if your soft was working.

Have recently completed the improvement of one DDS (from an existing soft for a 16F84A) which uses a R-2R network, a 4 poles filter for a 10 to 550 Hz output, to be employed in testing ADCs. Frequency and phase (when 2 of them working together) can be changed at will. Also there is an option for fixed selectable frequencies.

Working with a 18F452 now, had to revisit the limitations of the 16F84A. Nice experience!
 

Re: PIC SINEWVAE DESIGN

Very useful informations so far i am searching for.thank you all
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top