Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
can you please help me how to make a sine wave from a micro controller, 8051 using! If it is a problem to make the negative cycle, can you tell me how to make at least the Positive sine wave cycle. any codes are welcomed
Perhapps this should've been posted microcontrollers section.
What programming language are you using?
It should be fairly easy using basic or C.
Does this micro have a FPU?
If not then you'll need an emulator or a library, which might be too slow to generate a sinewave of any usable frequency, but there again there are tricks like look-up tables but I'm no professional programmer, I only know BASIC.
Use Excel to compute the sin function and scale the floating point values to the nearest integer to create a table of values. Export the data as a .CSV file. If you are clever with the setup of the spreadsheet you can paste the .CSV output right into your source file and have the compiler generate the table.
Pick a time increment, fetch a value from the table and write the output to a DAC or a PWM. However long it takes to run through the table will determine the frequency of the output.
The answer is to use a lookup table, which is what Papabravo actually explained, there's no need for anything difficult on the micro-controller, generate the table on a PC and the micro just reads it.
As suggested, you could use Excel, but even a DOS BASIC does it easily.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.