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.

sine wave pic 18f452(c language)

Status
Not open for further replies.

mansouri_1987

Newbie level 3
Joined
Apr 25, 2012
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,295
i need help to write a program to generate sine wave (pic 18f452)c language
 

Have a look at this thread..
https://www.edaboard.com/threads/236741/

You need to attach a DAC with your micro-controller...

See the schematic in the above thread..
Code:
#include<htc.h>

const unsigned char wave[181] = {128,132,137,141,146,150,155,159,163,168,172,176,1 80,184,188,192,196,200,203,207,210,214,217,220,223 ,226,229,232,234,237,239,241,243,245,247,248,250,2 51,252,253,254,254,255,255,255,255,255,255,255,255 ,254,253,252,251,250,248,247,245,243,241,239,237,2 34,232,229,226,223,220,217,214,210,207,203,200,196 ,192,188,184,180,176,172,168,163,159,155,150,146,1 41,137,132,128,124,119,115,110,106,101,97,93,88,84 ,80,76,72,68,64,60,56,53,49,46,42,39,36,33,30,27,2 4,22,19,17,15,13,11,9,8,6,5,4,3,2,1,1,0,0,0,0,0,1, 1,2,3,4,5,6,8,9,11,13,15,17,19,22,24,27,30,33,36,3 9,42,46,49,53,56,60,64,68,72,76,80,84,88,93,97,101 ,106,110,115,119,124,128};

void main()
{
unsigned char i;
TRISD = 0x00;
for(i=0;i<181;i++)
{
PORTD = wave[i];
__delay_us(70);
}

The above code is written for PIC16F877A, you can modify the code for PIC18F, which depends on your compiler, only thing that will change is delay function, depending upon ur compiler
 

What do you use the IR2110 for? It's a MOSFET driver. It's not hard to change from port D to port C in the code.

Are you trying to make a PWM inverter, to drive a motor or make an AC power supply?

Then that's a different matter and you need to give more explanation of your requirements.
 

What do you use the IR2110 for? It's a MOSFET driver. It's not hard to change from port D to port C in the code.

Are you trying to make a PWM inverter, to drive a motor or make an AC power supply?

Then that's a different matter and you need to give more explanation of your requirements.
Sans titre.jpg i need just to generate pwm pulse like that appnote.tsa002.figure02.gif
 

You need sine wave directly from PIC, **broken link removed**
or you need SPWM (to make inverter), **broken link removed**
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top