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.

Generating sine wave using interrupt

Status
Not open for further replies.

Chinmaya12

Newbie level 3
Joined
Apr 18, 2018
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
25
I want to generate sine wave and also I want calculate the power factor of rl series circuit using interrupt
Can anyone give me suggestions
I am not knowing about how to use interrupt in arm lpc2148
 
Last edited:

Hi,

This question is too vague.

Show your ideas, show what you have done so far...
Then ask a detailed question.

Klaus
 

I am not knowing about how to use interrupt in arm lpc2148
 

Hi,

Still a vague question.

A forum is a place where you should find answers...
A forum search "interrupt LPC2148" gives currently 78 hits.(an internet search gives a lot more)
Did you read through them?
Which code did you try so far? What was the result?

I just performed an internet search "LPC2148 interrupt video tutorial"....you can do the same...it gives a lot results.

Klaus
 

I have tried one example of blinking an led using interrupt through a switch but now I am not getting to know how to generate sine wave and calculate power factor
 

Hi,

Show your code. Show your effort.
Which document or other source did you use to write it?
How did you test it?
What did you expect and what did you see instead.

There will be (about) nobody who writes the code for you, but there will be many that help you to correct your code.

Klaus
 

Hello,

little hint - you can generate sine wave by using for example these methods:

1) using DAC (digital-analog converter)

2) by generating PWM (pulse width modulation)

In 1) case look for such cheap DAC:

**broken link removed**

12bit DAC MCP4725 (with I2C interface) - this is slow DAC
If you need faster DAC: lookh for AD9837 IC:

https://www.sparkfun.com/products/11420

2)Generating sine wave with PWM is a bit more complicated.

Now you have a foothold for your problem.

Regards
 

Generating a sine wave (or any other repetitive wave shape) isn't difficult using interrupts. The steps are:

1. Divide your waveform into enough equally spaced points that they can reasonably reconstruct the wave shape. It will never be perfect.
2. Based on the highest frequency you want to produce, find out how many points per second are needed. (max freq x number of points)
3. Set a timer to produce interrupts at that speed. In other words the interrupts are at the same rate as the points in your waveform.
4. At each interrupt, read the next value from a look-up table of the voltage at the point in your waveform.
5. Send the value to the DAC.

So the DAC produces a voltage matching the voltage at each sample point in your waveform and therefore reconstructs it.

Note: If the waveform is a sine/cosine wave or any other symmetrical waveform, you can simplify the process by making the table much smaller and re-using the values more than once. For example, in a sine wave there are four 'mirror images' of each quadrant, if you store the values only for say 0 degrees to 90 degrees, you can use (1 - table value) to get the second quadrant and so on.

Brian.
 
Generating a sine wave (or any other repetitive wave shape) isn't difficult using interrupts. The steps are:

1. Divide your waveform into enough equally spaced points that they can reasonably reconstruct the wave shape. It will never be perfect.
2. Based on the highest frequency you want to produce, find out how many points per second are needed. (max freq x number of points)
3. Set a timer to produce interrupts at that speed. In other words the interrupts are at the same rate as the points in your waveform.
4. At each interrupt, read the next value from a look-up table of the voltage at the point in your waveform.
5. Send the value to the DAC.

So the DAC produces a voltage matching the voltage at each sample point in your waveform and therefore reconstructs it.

Note: If the waveform is a sine/cosine wave or any other symmetrical waveform, you can simplify the process by making the table much smaller and re-using the values more than once. For example, in a sine wave there are four 'mirror images' of each quadrant, if you store the values only for say 0 degrees to 90 degrees, you can use (1 - table value) to get the second quadrant and so on.

Brian.

Hello betwixt,

nice clarification. Could you give a recipe for generating sine wave with using PWM modulation?

Kind Regards :)
 

Very similar procedure:

First configure the PWM frequency so the pulse rate is at least twice the highest frequency you want to produce. Higher frequencies will work better but watch out for lower resolution (fewer bits available) as the rate is increased on some processors.

Then follow the DAC method but instead of feeding the value to the DAC, use it as the PWM duty cycle instead.

The idea is that instead of the DAC directly producing a voltage proportional to the value fed to it, you adjust the proportion of time the PWM signal is low to time it is high. The pulse rate stays fixed but the width of the pulse changes and hence so does it's average voltage. Narrow pulses have a low average and 100% pulses (always high) have maximum average. You need to use a filter to perform the analog averaging, usually a simple RC filter will do, make it's time constant long enough to minimize the residual pulsing but short enough that the average can change quickly enough to follow your waveform.

Brian.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top