Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 7 months ago.
Generating a Sine Wave with an input from function generator
How do I generate a Sine Wave with an input from function generator? I will need to come up with a program that I can put in a signal from the function generator and display it on my LCD screen. (If I put in a sine wave, I should get a sine wave on my LCD. Square wave in, square on LCD.)
Platforms used: - mbed LPC1768 - C12832 LCD
Your help is gladly appreciated!
1 Answer
9 years, 7 months ago.
What frequency range? If you can get away with a fixed sample period or a user selected period then the basic code is very simple:
AnalogIn input(inputPin); main() { setupDIsplay(); while (true) { for (row = 0; row < display_width; row++) { plotpoint(row, input*display_height); wait(sample_period); } }
Thank you, Andy.
I am actually working on a project - to make a portable ECG. It is broken into 2 parts - hardware and software development.
The hardware development is my bio-amplifier circuit which has been done and tested. I will be connecting the hardware and software together, to display the captured signal unto the screen. (That's why I wanted to try a program that's able to display a sine wave on the LCD screen)
posted by 19 May 2015In that situation you may want to make it a little fancier in order to keep the pulses centered on the screen or at least in roughly the same location all the time.
Get the un-synchronized display working first and see how it looks but keep in mind that you should be able to tidy it up a lot.
The easiest way to do this is only start plotting when the input goes from below a certain threshold to above the threshold.
If you wanted to get fancy you could have a rolling buffer of one screen worth of data and then when the highest value is in the middle of the buffer display it on the screen, that would keep the peak value in the same location each update. Also in that situation since you would know the all data before you displayed it you could potentially auto-scale the y-axis to always use the full screen (depending on the data that may be misleading but it's nice to have the option)
posted by 19 May 2015