December 26, 2012

Sine wave generating from PIC

Hello friends,

To do sinusoidal modulation you need sine wave which can be compared with high frequency carrier(triangular waves). And i was also about to generate Sine modulation so i needed to do this.


      You can generate by calculating sine values at run time also but that is time consuming and keeps your microcontroller busy with calculations only, so I suggest you to make a look up table  and recall the value at run time from there.

      So here is what I have done its a simple task just have a look at the code,....

///////////////////////////////////////////////////////////
#include "pic .h
#include "htc .h"
#define _XTAL_FREQ 4000000

const unsigned char wave[181] ={128,132,137,141,146,150,155,159,163,168,172,176,180,184,188,192,196,200,203,207,210
,214,217,220,223,226,229,232,234,237,239,241,243,245,247,248,250,251,252,253,254,254,
255,255,255,255,255,255,255,255,254,253,252,251,250,248,247,245,243,241,239,237,234,
232,229,226,223,220,217,214,210,207,203,200,196,192,188,184,180,176,172,168,163,
159,155,150,146,141,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,24,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,39,42,46,49,53,56,60,64,68,72,76,
80,84,88,93,97,101,106,110,115,119,124,128};

int main(void)
{
TRISD = 0x00;
unsigned char i;

for(i=0;i<181 ;i++) {
PORTD = wave[i];
__delay_us(79);
}

return 0;
}

///////////////////////////////////////////////////////////

 But,here instead of using normal DAC to generate sine wave I have here used R-2R ladder(no specific reason).
Here is the schematic.

R-2R ladder in proteus generating sine wave for sine modulation

Here VSM Timer counter is used to measure the frequency generated by R-2R DAC. 


The output of the circuit is as shown below..

Sine wave and vsm counter in proteus

if you want to make frequency variable just keep a variable in delay and update it by any key..... 


For more Proteus projects  click here.
Read more ...

Sinusoidal modulation in PIC

Hello Friends,

Many of the readers are asking for sinusoidal modulation with pic microcontrolle. So here is the answer....

1)Read my previous post about sine wave modulation.

2)Now you need  Sine wave of 50Hz to generate reference for modulation.Read this post about generating Sinusoidal waveforms with PIC. (you can generate sine wave from any microcontroller by using this method.)

3)Create a triangle wave either from microcontroller or 555 timer IC.

sine pwm modulation in pic
4)You are done ......





You can see other AVR Projects HERE.



Read more ...

December 05, 2012

Graphical programming including VHDL with code generation

Hello friends i was always fascinated about programming graphically so we don't need to write any code(that saves your lot energy, don't consider me lazy!!!!).

Here is the answer of

How to do VHDL programming graphically?

step1) Open NI- Multisim
ni-multisim


step 2) go to place menu and select "New PLD Sub circuit"


step 3) then a PLD wizard will open select "Create empty PLD" and in subsequent steps select the name of circuit and operating voltage of the processor ( it has nothing to do with code generation but only useful for simulation in Multisim)

PLD wizard

step 4) click on the PLD setting Button

pld setting

step 5) you will be asked  for input, output and bi-directional pins in this menu


select_io_pins


step 6) now make whatever circuit you want to make(time to  have fun!!!)...

gate_schematic


step 7)  Click on PLD topology check



step 8) if there is no error in your topology you can export the VHDL code



step 9) finally your VHDL code is ready to be saved save it whenever you want  and have fun.

step 10)  Go to main circuit and build some circuit around your PLD to simulate


 
 Step 11) Don't forget to leave a comment here.....!!!!


"LET THY BE FREE FROM TEXTUAL PROGRAMMING"

                                                                          -Keyur




Read more ...
Related Posts Plugin for WordPress, Blogger...