Skip to content

Instantly share code, notes, and snippets.

View komponenrobot's full-sized avatar

komponenrobot

View GitHub Profile
@komponenrobot
komponenrobot / 8bitto16bit
Created May 14, 2019 08:43
Konversi 8bit to 16bit
uint16_t data16bit;
uint8_t data8bit[2];
// data8bit[0]
// data bagian atas / HIGH
// data8bit[1]
// data bagian bawah / LOW
data16bit = ((data8bit[0] << 8) & 0xFF00) | data8bit[1];
@komponenrobot
komponenrobot / kalibrasi sensor
Created May 14, 2019 22:35
kalibrasi sensor
Persamaan dari excel
y = 0,0009x2 + 0,9856x + 0,2964
x ==> data dari sensor
y ==> data keluaran kalibrasi
Persamaan di Bahasa C
y = 0.0009*x*x + 0.9856*x + 0.2964;
/*******************************************************
This program was created by the CodeWizardAVR V3.36
Automatic Program Generator
© Copyright 1998-2019 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com
Project : LCD 16x2
Version :
Date : 17/05/2019
Author : Robotik Indonesia
int dataInteger=10;
char buff[33];
// untuk menghapus semua tampilan
lcd_clear();
// untuk memilih koordinat awal tulisan
lcd_gotoxy(0,0);
// untuk menampilkan string
@komponenrobot
komponenrobot / Hitung Timer CV AVR
Created May 24, 2019 13:36
Hitung Timer CV AVR
Clock Value = Clock Source / Pre Scaler
TCNT = Max Counter-(Clock Value/ (1 / timer yang diinginkan)-1)
Max Counter ==> Tergantung bit
8 bit ==> 255
16 bit ==> 65535
Timer yang diinginkan dalam satuan Second
// Timer 0 overflow interrupt service routine
interrupt [TIM0_OVF] void timer0_ovf_isr(void)
{
// Place your code here
TCNT0=0x64;
}
dan
@komponenrobot
komponenrobot / settingTimer
Created May 28, 2019 12:30
settingTimer pada STM32
// enable TIM4
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE);
// mengatur timer 40ms = 0,04s (25Hz)
// clock / (prescale +1)
// 72.000.000/ (7199+1) = 10.000
// Periode = (10.000 / 25 )-1=400-1=399
TIM_TimeBaseInitTypeDef ST;
ST.TIM_Prescaler = 7199;
ST.TIM_Period = 399;
@komponenrobot
komponenrobot / Hitung Timer STM32
Created May 28, 2019 12:33
Cara hitung prescaler dan periode timer pada stm32
mengatur timer 40ms = 0,04s (25Hz)
clock / (prescale +1)
72.000.000/ (7199+1) = 10.000
Periode = (10.000 / 25 )-1=400-1=399
==> nilai timer yang diinginkan dijadikan dalam satuan frekuensi (Hz)
==> nilai prescaler kita tentuin sendiri, terserah.
@komponenrobot
komponenrobot / timer stm32 full
Created May 28, 2019 12:34
gabungan semua coding
#include "stm32f10x.h"
#include "stm32f10x_tim.h"
int hitung=0;
void TIM4_IRQHandler(){
if(TIM_GetITStatus(TIM4, TIM_IT_Update)){
hitung++;
// taruh sini koding untuk sampling data
TIM_ClearITPendingBit(TIM4, TIM_IT_Update);
}
/*******************************************************
This program was created by the CodeWizardAVR V3.36
Automatic Program Generator
© Copyright 1998-2019 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com
Project :
Version :
Date : 13/06/2019
Author : Robotik Indonesia