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.

sinewave generator using pic

Status
Not open for further replies.

Raveesh

Member level 2
Joined
Feb 6, 2011
Messages
42
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,564
Hi,
I need to generate a sine way at frequency from 15kHz to 25KHz using PIC micron and DAC.
I have to go with PIC controller (any low cost comptroller ) with in built in DAC and I'm not supposed to use any external circuit, .

Can any one suggest how to generate the sine way using pic?

regards
Ravee
 

Hi,
Thanks for the details .
Actually in my project I just need to generate a sine wave at frequencies between 15kHz to 25KHz. And I wont be doing any other kind of processing or interfacing to the micro controller . So is there any other way to do this , just with normal microcontroller with DAC ?
regards
Ravee
 

Hi Raveesh,
You can use look up table to generate sine wave. Make a array of sine values, store it in memory. Access each value sequentially, send it to DAQ. By varying the rate of updating DAC, desired frequency can be obtained.
Kindly check this up... **broken link removed**
Hope this helps....
 

Hi,
Thanks for the details .
Actually in my project I just need to generate a sine wave at frequencies between 15kHz to 25KHz. And I wont be doing any other kind of processing or interfacing to the micro controller . So is there any other way to do this , just with normal microcontroller with DAC ?
I tend to regard a dsPIC as a normal microcontroller these days
what were you thinking of?

have a look at
YouTube - Audio DAC Peripheral on dsPIC DSC devices
 
Last edited:


Looking at the Microchip web site I don't think there is a PIC16 with a DAC (he cannot use an external circuit).
Could try using PWM to generate sine waves but the frequency is fairly high - perhap someone could advise?
I would use a dsPIC but then I use dsPICs all the time!
for example, the dsPIC33FJ06GS101/X02 comes in a 28pin SDIP package which would be easy to build a PCB or even a breadboard
dsPIC33FJ06GS202
 
Last edited:

Hi,
I would generate the lookup table for sinewave and also I have generated the timer interrupt for 50µs(20khz) , Now I have a small doubt at sending the data to DAC ,
If I have some 30 values ( assuming sinewave values for one full cycle ) ,How to release all these values one by one to the DAC in order to generate the required data rate ..?
 

given the frequency required from the period of the sine wave the timer should interrupt period/30
on each timer interupt you output the next value to the DAC
Code:
int sinewave[30];     // table of sine values normalised to DAC range
volatile int index=0;  // index into table

void timer_interrupt()   // timer interrupt function
{
    DAC = sinewave[index++];
    if (index >= 30) index=0;
}
one assumes the DAC can convert in the time between timer interrupts

here is an example using a dsPIC30F3013 to drive a MCP41010 digital potentiometer (SPI interface) to generate a sine wave (frequency about 2KHz)
Code:
/* timer 2 interrupt service routine */ 
/* write next byte of data to MCP41010 on SPI1 */                  
void __attribute__((__interrupt__)) _T2Interrupt(void)
 {
  WriteTimer2(0);			// reset timer counter to 0
  IFS0bits.T2IF = 0;    		/* Clear Timer interrupt flag */
  PORTDbits.RD8 = 1;			// set EABLE high to execute last command
  PORTDbits.RD8 = 0;			// reset EABLE low to load next command
  WriteSPI1(((WRITE+POT1)<< 8 ) + txSinx[txSinxIndex]);	// write the data value
  if (++txSinxIndex==TXDATA)txSinxIndex=0;	// check array bounds - reset if required
 }
 
Last edited:

Hi,
I want to build my own PCB for dsPIC,. Can you provide reference details for design and low cost programmer/ debugger where I can program any other pic also ..
I searched in micro chip site but got confused with lots of programmers ...

regards
Ravee
 

It is a good idea to get a modern programmer otherwise you may find older programmers won't work with new PICs.
I tend to use an ICD3 programmer as it is very fast loading code. However, it is expensive and a cheaper alternativly is the pickit3. Have a look at
**broken link removed**
 

Hi,
Could try using PWM to generate sine waves but the frequency is fairly high - perhap someone could advise?
dsPIC33FJ06GS202

I could not understand how to genarate a sinewave using PWM,, can you provide some steps / docs which helps me to work on this ..?

regards
Ravee
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top