Skip to content

Instantly share code, notes, and snippets.

View joaoantoniocardoso's full-sized avatar
🎯
Focusing

João Antônio Cardoso joaoantoniocardoso

🎯
Focusing
View GitHub Profile
///////////////////////////
//main.c
///////////////////////////
extern void delay(int milli);
extern long long mult(long a, long b);
#define MS_DELAY 1000
int main(void)
uint8_t machine_clk = 0;
void machine_init(void)
{
TCCR2A = (1 << WGM21) | (0 << WGM20) // Timer 2 in Mode 2 = CTC (clear on compar e)
| (0 << COM2A1) | (0 << COM2A0) // do nothing with OC2A
| (0 << COM2B1) | (0 << COM2B0); // do nothing with OC2B
TCCR2B = (0 << WGM22) // Timer 0 in Mode 2 = CTC (clear on compar e)
| (0 << FOC0A) | (0 << FOC0B) // dont force outputs
| (1 << CS22) // clock enabled, prescaller = 1024
@joaoantoniocardoso
joaoantoniocardoso / compiling_OpenFOAM-4.x.md
Last active December 19, 2023 17:00
Compiling OpenFOAM-4.x at 2019 on Linux with ZSH, GCC 9.1

PROBLEM

I was trying to install Helix-OS on my Arch Linux at 2019 with ZSH and GCC 8.1 and because it is quite old it recommends OpenFOAM-4.1.

Naturally, there is no package for older OpenFOAM on AUR, so it need to be built from the sources and of course we have to solve some compatibility issues and here is a collection of fixes found on the internet :)

Get the sources

Note that using the folder names with sufix 4.1 for version 4.1 would help some of the scripts.

mkdir -p $HOME/OpenFOAM

@joaoantoniocardoso
joaoantoniocardoso / freecad-build.sh
Created April 24, 2019 16:26
Script to build freecad at arch-linux from git sources without Ship module.
#Defines development directory:
FREECAD_DEV_DIR=~/freecad
CURRENT_DIR=$(pwd)
echo "> Development dir: $FREECAD_DEV_DIR."
echo "> Note that you are at: $CURRENT_DIR."
# Installing needed packages from a package-manager
echo "> Installing needed packages from a package-manager"
yay -S --needed boost-libs curl desktop-file-utils glew hicolor-icon-theme jsoncpp libspnav med opencascade shiboken2 xerces-c pyside2 python-matplotlib python-netcdf4 python-pivy qt5-svg qt5-webkit qt5-webengine boost cmake eigen git gcc-fortran pyside2-tools swig qt5-tools pybind11 python36
#!/bin/sh -exu
dev=$1
cd $(mktemp -d)
function umountboot {
umount boot || true
umount root || true
}
# RPi1/Zero (armv6h):
@joaoantoniocardoso
joaoantoniocardoso / compiling_InsightCAE.md
Last active October 1, 2019 01:14
Installing InsightCAE from sources on archlinux

Dependencies:

yay -S --needed opencascade dxflib freecad imagemagick python2 python2-matplotlib python2-scipy python2-numpy qwt qt5-base paraview swig texlive-core texlive-latexextra gnuplot boost gsl armadillo cmake

/* PID CONTROL ALGORITHM
** /desc Algoritimo para Controlador Proporcional Integrativo Diferencial.
** ref1: https://www.scilab.org/discrete-time-pid-controller-implementation
** ref2: https://scilabdotninja.wordpress.com/scilab-control-engineering-basics/module-4-pid-control/
** /var r é o valor desejado para a saída
** /var y é o valor da saída
** /ret retorna a ação de controle
*/
float pidVo(float r, float y){
// PID SETUP FROM ZNFD METHOD:
@joaoantoniocardoso
joaoantoniocardoso / PI.c
Last active November 24, 2019 01:50
PI CONTROL ALGORITHM - SERIES IMPLEMENTATION
/* PI CONTROL ALGORITHM - SERIES IMPLEMENTATION
** /desc Algoritimo para Controlador Proporcional Integrativo Diferencial.
** ref1: https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/902/PI-controller-equations.pdf
** /var r é o valor desejado para a saída, o 'set-point'.
** /var y é o valor da saída.
** /ret retorna a ação de controle u.
*/
float pi(float r, float y){
// PI CONFIGURATIONS:
const float Kp = 0.08*0.8; // analog series proportional gain
#!/bin/sh
# requires: cloc (https://github.com/AlDanial/cloc)
# Clone all repos:
REPOS=(BOAT19 MT19 MRPC19 MAB19 MCB19 MCS19 MCT19 MFP19 MIC19 MSC19 MVC19 MSWI19 MAM19 FUPCI19)
BASE_URL=https://github.com/ZeniteSolar/
for repo in ${REPOS[*]}; do
git clone $BASE_URL/$repo
done
#include <stdio.h>
void type1(void);
void type2(void);
void type3(void);
void type4(void);
// CFlags for avr-gcc:
// -mmcu=atmega328p -DF_CPU=16000000UL -Os -funsigned-char -funsigned-bitfields
// -fpack-struct -fshort-enums -Wall -Wundef -MMD -MP