Giter Club home page Giter Club logo

fgen's Introduction

fGen

This is an user friendly function generator in C. You can simple way generate different waveforms and do operations with them.

Features

SIMULATION

  • You can set the simulation time
  • You can add the number of simulaton steps

WAVEFORMS

  • periodic signals: sine, square, triangle
  • non-periodic signals: square root, Log, Log2, Log10, Lin

OPERATIONS

  • math: add, sub, mul, div

OUTPUTS

  • showWaves: makes a list with two columns in console
  • writeCSV: makes a CSV file with content of "showWaves"
  • writeHeader: makes a standard C header file with two arrays

Getting started

To use this repository, you will need:

  • GCC (or similar C compiler)

Clone source

git clone https://github.com/vargalaszlo87/fGen.git

Quick build

If you use Windows

๐Ÿ”ด Important! Check the gcc --help command in your Command Prompt. If it doesn't work you need add GCC to system variable (PATH).

install.bat

If you use Linux

install.sh

Self compiling

If you use Windows

gcc -c src/main.c -o build/main.o -I"include"
gcc -c src/signals.c -o build/signals.o -I"include" 
gcc -c src/operands.c -o build/operands.o -I"include" 
gcc -c src/outputs.c -o build/outputs.o -I"include" 
gcc -c src/adjust.c -o build/adjust.o -I"include"
gcc -c src/create.c -o build/create.o -I"include"
gcc build/main.o build/signals.o build/outputs.o build/adjust.o build/create.o -o bin/fGen.exe

If you use Linux

gcc -c src/main.c -o build/main.o -I"include" -lm
gcc -c src/signals.c -o build/signals.o -I"include" -lm
gcc -c src/operands.c -o build/operands.o -I"include" -lm
gcc -c src/outputs.c -o build/outputs.o -I"include" -lm
gcc -c src/adjust.c -o build/adjust.o -I"include" -lm
gcc -c src/create.c -o build/create.o -I"include" -lm
gcc build/main.o build/signals.o build/outputs.o build/adjust.o build/create.o -o bin/fGen

Usage

Insert your headers:

#include "fgen.h"

Create a simulation:

struct generator g;
g.step = 10000;               /* number of steps */
g.simulationTime = 0.1755;    /* time in seconds */

Create a waveform:

struct waveform signal;
signal.amplitude = 230;       /* set amplitude */
signal.frequency = 120;       /* set frequency */
makeSine(&g, &signal);

Generate an output:

showWaves(&signal);

Example

src/main.c file:

#include <stdio.h>
#include <stdlib.h>

#include "fgen.h"

int main(int argc, char *argv[]) {
	
	// create a simulation
	struct generator g;
	g.step = 10000;
	g.simulationTime = 0.1755;
	
	// create a sine signal
	struct waveform signal;
	signal.amplitude = 230;
	signal.frequency = 120;
	makeSine(&g, &signal);

	// crate a sine noise-signal
	struct waveform noise;
	noise.amplitude = 23;
	noise.frequency = 5000;
	makeSine(&g, &noise);

	// create a ramp (sqrt function)
	struct waveform ramp;
	makeSqrt(&g, &ramp);

	// make an 'out' waveform
	struct waveform out;
	
	// add two signals (out = signal + noise)
	// multiply two signals (out = out * ramp)
	out = addWaves(&g, &signal, &noise);
	out = mulWaves(&g, &out, &ramp);

	// write to stdout and CSV
	showWaves(&out);
	writeCSV(&out);	
		
	return 0 ;
}

License

Distributed under the MIT License. See LICENSE.txt for more information.

Contact

Varga Laszlo - https://vargalaszlo.com - [email protected]

Project Link: https://github.com/vargalaszlo87/fGen

portfolio

fgen's People

Contributors

vargalaszlo87 avatar

Watchers

 avatar

fgen's Issues

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.