Home

Awesome

CControl

CControl is a library written in 100% ANSI C (C89) code. No external libraries and 100% platform independent. The purpose with this library is to fit advanced tools for really small embedded systems or desktop as well. Here I have focused on practical numerical methods and selected the methods that works best in practice. It has been a lot of work finding the best methods and best algorithms.

CLAPACK, Math Kernel Library, FFTPACK support

This library have different types of libraries. First library is the internal lightweight library that suits small embedded systems. The second library is higher lever library for larger matrices. The third library is libraries that are hardware independent. Set this as your math library inside defines.h file. The Math Kernel Library is extremely optimized and it's suitable for operative systems such as Windows, Linux, Mac OS meanwhile the lightweight library or CLAPACK and FFTPACK is suitable for an Arduino, STM32, PIC etc because they are 100% portable. The internal library is suited for really small devices.

RoutinesFunctionComment
ssyevdsvd.cSingular value decomposition for symmetric matrices
ssyevdeig.cEigendecomposition for symmetric matrices
sgeeveig.cEigendecomposition for square matrices
sgessdsvd.cSingular value decomposition for general matrices
spotrfchol.cCholesky facorization for real symmetric matrices
sgetrflup.cLU factorization with pivoting for square matrices
sgetrslinsolve_lup.cSolve linear system Ax = b with LU factorization
sposvlinsolve_chol.cSolve linear system Ax = b with Cholesky factorization
sgetriinv.cInverse by using LU factorization for square matrices
sgeqrf sorgqrqr.cQR factorization for general matrices
sgemm ssymm sgemv ssymvmul.cMultiplication
sgesvdpca.cPrincipal component analysis
sggeveig_generalized.cGeneralized eigenvalue problem for non-symmetric matrices
ssygvdeig_generalized.cGeneralized eigenvalue problem for symmetric matrices
rfftffft.cCompute Fast Fourier Transform 1D
cfftbifft.cCompute Inverse Fast Fourier Transform 1D
rfftffft2.cCompute Fast Fourier Transform 2D
cfftbifft2.cCompute Inverse Fast Fourier Transform 2D

If you want to add more, just download clapack-3.2.1.zip from Netlib and include necessary .c files inside the Lapack folder of this project, for supporting your routine.

TypeInternalMLKCLapackFFTpack
SpeedSlow for large dataFast for large dataFaster than internalVery fast
PortabilityPlatform independentOnly Windows/Linux/ Mac OSPlatform independentPlatform independent
MissingEigenvectors for general matricesNothingNothingNothing
Memory requirementsLightweightLargeMediumLightweight

Computer vision support

CControl have sevral algorithms for computer vision. They are chosen and reduced so they will fit embedded systems.

NameModelMulti classificationLocalizationNoise invariantLummination invariantRotation invariantScale invariantTranslation invariantSuitable for
Fisherfaces1-Layer NNYesNoYesYesNoNoNoObjects
Viola JonesHaar-LikesNoNoYesYesNoNoNoObjects
Generalized Hough TransformHough modelNoYesNoYesYesYesYesObjects
Hough TransformHough modelYesYesYesYesYesYesYesLines
Harris corner detectionNoYesYesNoYesYesYesYesCorners
Feature detectionNoYesYesNoYesYesYesYesFeatures

Main focuses are:

/*
 ============================================================================
 Name        : Main.c
 Author      : <Your Name Here>
 Version     : 1.0
 Copyright   : MIT
 Description : Initial template
 ============================================================================
 */

#include "CControl/ccontrol.h"

int main() {
	clock_t start, end;
	float cpu_time_used;
	start = clock();

	/* Your ANSI C logic here - All examples can be found at the folder src/CControl/Documents/Examples */

	end = clock();
	cpu_time_used = ((float) (end - start)) / CLOCKS_PER_SEC;
	printf("\nTotal speed  was %f\n", cpu_time_used);


	return EXIT_SUCCESS;
}

Projects made with CControl

Fan Controller with Linear Quadratic Integral Control

I have created a controller for a fan. The controller works as it read the temperature sensor and it compare the temperature sensor with the potentiometer, which is the reference set point. If the error is large between the temperature sensor and the potentiometer, then the fan is going to turn on high, or low, depending on if the error is negative or positive.

The goal with this system is that I'm going to implement this on a heat source. The fan is going to blow warm air onto a object and the object is holding the temperature sensor. If the fan is blowing to much warm air, then the controller is going to turn down the speed of the fan so the temperature of the object meets the reference

a

I have been using Matavecontrol and Mataveid to estimate and creating the kalman gain matrix and the LQR control law with integral action. I'm the author of both Matavecontrol and Mataveid.

Identification process. Here I have using the Observer Kalman Filter Identification and Eigen System Realization methods.

a

Simulation process:

a

Model Predictive Integral Temperature Controller

This is a Model Predictive Controller, with integral action. It uses linear programming instead of quadratic programming for the optimization. This controller works well.

This predictive controller have a wiring diagram if you want to build the same controller for your temperature project.

a

a

Step answer of first order model.

a

Model Reference Adaptive CAN-bus controller

This is a MRAC project, Model Reference Adaptive Controller. This controls the a Sonceboz stepper motor with CAN-bus J1939-21 protocol. The purpose is to control a big wheel with two multivariable hydraulical valves.

See the movie in the project folder.

Library for SAE J1939 https://github.com/DanielMartensson/Open-SAE-J1939

a

Square Root Uncented Kalman Filter for state estimation and parameter estimation

This is the latest Uncented Kalman Filter. MATLAB is using the same algorithm. A .m file is available at the SR-UKF folder.

For state estimation

a

For parameter estimation

a

How to use this library with Eclipse CDT

I have made so both Microsoft Visual Studio users and Eclipce CDT can use this library without conflicts. Here is a tutorial how to configure your Eclipse CDT for this repository.

  1. I'd recommend Eclipse IDE for compiling this software. Eclipse IDE is a very boring IDE, but it's robust and trustable. The Eclipse IDE is always going to be available for you.

a

  1. Once you have Eclipse IDE installed. Show Git perspective.

a

  1. Select Git

a

  1. Copy ssh

a

  1. Clone git. Just press next and end with finish

a

  1. Import project

a

  1. Show view

a

  1. Select Git staging

a

  1. Every time you change a file and you want to update your repository

a

  1. If you don't have a C-compiler, here is a video how to set up a compiler

  2. Begin with your main.c file. Then go to src/CControl/Documents/Examples/ and select a .txt file and paste it into main.c file and press the green circle with a white triangle inside

  3. If you got problem with push your updates to this repository, the you need to configure your authorization. See this link