Giter Site home page Giter Site logo

picsine's Introduction

Fast Sine Wave Generation with PIC microcontroller

This project is part of a college subject and demonstrates how to generate a sine wave with a 12-bit DAC as fast as possible using the PIC12F1822 microcontroller and the DAC MCP4921.

The goal of the project is to optimize the code to generate the sine wave with the highest possible frequency, while maintaining a resolution of 1 degree.

Function to Generate

The function to generate is: $$y = 1.0 + |3.5 * \sin(\omega t)|$$

Screenshot

Screenshot

Options Considered

The following options were considered for generating the sine wave:

  • List of pre-built values of sine: This option involves pre-computing a list of sine values and storing them in memory.

  • Using the sine function: Another option is to use the built-in sine function provided by the C_Math library of MikroC PRO for PIC. The sine function calculates the value of sine for a given angle on the fly, which means that it takes more processing time to generate the sine wave than the pre-built values option.

  • List of pre-built DAC values: This option involves pre-computing a list of DAC values to generate the function and storing them in memory.

Results

After testing and optimization, the highest frequency achieved was 290.69Hz. This was achieved by using a pre-built list of DAC values.

The following table shows the results of the different options:

Option Frequency (Hz)
Pre-built list of DAC values 290.69
Pre-built list of sine values 68.77
Using the sine function 4.72

While the use of a pre-built list of values may not be appropriate for all applications, it was an effective technique for achieving high-frequency sine wave generation with 1 degree resolution with the PIC12F1822 microcontroller and the DAC MCP4921.

Getting Started

To get started, simply download the repository and open the code in MikroC Pro. Follow the instructions in the code comments to modify the code or adjust the hardware setup as needed.

Dependencies

  • MikroC Pro for PIC v4.0 or later
  • PIC12F1822 microcontroller
  • DAC MCP4921

License

This project is licensed under the MIT License.

picsine's People

Contributors

sebastian-ga avatar imgbotapp avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.