LAMPIRAN A /*******************************************************

Size: px
Start display at page:

Download "LAMPIRAN A /*******************************************************"

Transcription

1 42 Program pada mikrokontroler LAMPIRAN A /******************************************************* This program was created by the CodeWizardAVR V3.12 Advanced Project : gelombang Version : Revisi 4 Date : xx/xx/2015 Author : Nisa Company : Fisika s-1 FMIPA USU 2010 Comments: ganbatte ****************************************************** /#include <mega32a.h // I2C Bus functions #include <i2c.h> #include <stdlib.h> #include <delay.h> #include <math.h> // Declare your global variables here // // #define DATA_REGISTER_EMPTY (1<<UDRE) #define RX_COMPLETE (1<<RXC) #define FRAMING_ERROR (1<<FE) #define PARITY_ERROR (1<<UPE)

2 43 #define DATA_OVERRUN (1<<DOR) // USART Receiver buffer #define RX_BUFFER_SIZE 8 char rx_buffer[rx_buffer_size]; #if RX_BUFFER_SIZE <= 256 unsigned char rx_wr_index=0,rx_rd_index=0; #else unsigned int rx_wr_index=0,rx_rd_index=0; #endif #if RX_BUFFER_SIZE < 256 unsigned char rx_counter=0; #else unsigned int rx_counter=0; #endif // This flag is set on USART Receiver buffer overflow bit rx_buffer_overflow; // USART Receiver interrupt service routine interrupt [USART_RXC] void usart_rx_isr(void) char status,data; status=ucsra; data=udr; if ((status & (FRAMING_ERROR PARITY_ERROR DATA_OVERRUN))==0) rx_buffer[rx_wr_index++]=data;

3 44 #if RX_BUFFER_SIZE == 256 // special case for receiver buffer size=256 if (++rx_counter == 0) rx_buffer_overflow=1; #else if (rx_wr_index == RX_BUFFER_SIZE) rx_wr_index=0; if (++rx_counter == RX_BUFFER_SIZE) rx_counter=0; rx_buffer_overflow=1; #endif #ifndef _DEBUG_TERMINAL_IO_ // Get a character from the USART Receiver buffer #define _ALTERNATE_GETCHAR_ #pragma used+ char getchar(void) char data; while (rx_counter==0); data=rx_buffer[rx_rd_index++]; #if RX_BUFFER_SIZE!= 256 if (rx_rd_index == RX_BUFFER_SIZE) rx_rd_index=0; #endif #asm("cli")

4 45 --rx_counter; #asm("sei") return data; #pragma used- #endif // USART Transmitter buffer #define TX_BUFFER_SIZE 8 char tx_buffer[tx_buffer_size]; #if TX_BUFFER_SIZE <= 256 unsigned char tx_wr_index=0,tx_rd_index=0; #else unsigned int tx_wr_index=0,tx_rd_index=0; #endif #if TX_BUFFER_SIZE < 256 unsigned char tx_counter=0; #else unsigned int tx_counter=0; #endif // USART Transmitter interrupt service routine interrupt [USART_TXC] void usart_tx_isr(void) if (tx_counter) --tx_counter; UDR=tx_buffer[tx_rd_index++]; #if TX_BUFFER_SIZE!= 256

5 46 if (tx_rd_index == TX_BUFFER_SIZE) tx_rd_index=0; #endif #ifndef _DEBUG_TERMINAL_IO_ // Write a character to the USART Transmitter buffer #define _ALTERNATE_PUTCHAR_ #pragma used+ void putchar(char c) while (tx_counter == TX_BUFFER_SIZE); #asm("cli") if (tx_counter ((UCSRA & DATA_REGISTER_EMPTY)==0)) tx_buffer[tx_wr_index++]=c; #if TX_BUFFER_SIZE!= 256 if (tx_wr_index == TX_BUFFER_SIZE) tx_wr_index=0; #endif ++tx_counter; else UDR=c; #asm("sei") #pragma used- #endif

6 47 // Standard Input/Output functions #include <stdio.h> // ADDRESS REGISTER VARIABEL SENSOR // #define MPU6050_ADDRESS 0xD0 // Address with end write bit #define MPU6050_RA_XG_OFFS_TC 0x00 //[7] PWR_MODE, [6:1] XG_OFFS_TC, [0] OTP_BNK_VLD #define MPU6050_RA_YG_OFFS_TC 0x01 //[7] PWR_MODE, [6:1] YG_OFFS_TC, [0] OTP_BNK_VLD #define MPU6050_RA_ZG_OFFS_TC 0x02 //[7] PWR_MODE, [6:1] ZG_OFFS_TC, [0] OTP_BNK_VLD #define MPU6050_RA_X_FINE_GAIN 0x03 //[7:0] X_FINE_GAIN #define MPU6050_RA_Y_FINE_GAIN 0x04 //[7:0] Y_FINE_GAIN #define MPU6050_RA_Z_FINE_GAIN 0x05 //[7:0] Z_FINE_GAIN #define MPU6050_RA_SMPLRT_DIV 0x19 #define MPU6050_RA_CONFIG 0x1A #define MPU6050_RA_GYRO_CONFIG 0x1B #define MPU6050_RA_ACCEL_CONFIG 0x1C #define MPU6050_RA_FF_THR 0x1D #define MPU6050_RA_FF_DUR 0x1E #define MPU6050_RA_MOT_THR 0x1F #define MPU6050_RA_MOT_DUR 0x20 #define MPU6050_RA_ZRMOT_THR 0x21 #define MPU6050_RA_ZRMOT_DUR 0x22 #define MPU6050_RA_FIFO_EN 0x23 #define MPU6050_RA_I2C_MST_CTRL 0x24

7 48 #define MPU6050_RA_I2C_SLV0_ADDR 0x25 #define MPU6050_RA_I2C_SLV0_REG 0x26 #define MPU6050_RA_I2C_SLV0_CTRL 0x27 #define MPU6050_RA_I2C_SLV1_ADDR 0x28 #define MPU6050_RA_I2C_SLV1_REG 0x29 #define MPU6050_RA_I2C_SLV1_CTRL 0x2A #define MPU6050_RA_I2C_SLV2_ADDR 0x2B #define MPU6050_RA_I2C_SLV2_REG 0x2C #define MPU6050_RA_I2C_SLV2_CTRL 0x2D #define MPU6050_RA_I2C_SLV3_ADDR 0x2E #define MPU6050_RA_I2C_SLV3_REG 0x2F #define MPU6050_RA_I2C_SLV3_CTRL 0x30 #define MPU6050_RA_I2C_SLV4_ADDR 0x31 #define MPU6050_RA_I2C_SLV4_REG 0x32 #define MPU6050_RA_I2C_SLV4_DO 0x33 #define MPU6050_RA_I2C_SLV4_CTRL 0x34 #define MPU6050_RA_I2C_SLV4_DI 0x35 #define MPU6050_RA_I2C_MST_STATUS 0x36 #define MPU6050_RA_INT_PIN_CFG 0x37 #define MPU6050_RA_INT_ENABLE 0x38 #define MPU6050_RA_DMP_INT_STATUS 0x39 #define MPU6050_RA_INT_STATUS 0x3A #define MPU6050_RA_ACCEL_XOUT_H 0x3B #define MPU6050_RA_ACCEL_XOUT_L 0x3C #define MPU6050_RA_ACCEL_YOUT_H 0x3D #define MPU6050_RA_ACCEL_YOUT_L 0x3E

8 49 #define MPU6050_RA_ACCEL_ZOUT_H 0x3F #define MPU6050_RA_ACCEL_ZOUT_L 0x40 #define MPU6050_RA_TEMP_OUT_H 0x41 #define MPU6050_RA_TEMP_OUT_L 0x42 #define MPU6050_RA_GYRO_XOUT_H 0x43 #define MPU6050_RA_GYRO_XOUT_L 0x44 #define MPU6050_RA_GYRO_YOUT_H 0x45 #define MPU6050_RA_GYRO_YOUT_L 0x46 #define MPU6050_RA_GYRO_ZOUT_H 0x47 #define MPU6050_RA_GYRO_ZOUT_L 0x48 #define MPU6050_RA_EXT_SENS_DATA_00 0x49 #define MPU6050_RA_EXT_SENS_DATA_01 0x4A #define MPU6050_RA_EXT_SENS_DATA_02 0x4B #define MPU6050_RA_EXT_SENS_DATA_03 0x4C #define MPU6050_RA_EXT_SENS_DATA_04 0x4D #define MPU6050_RA_EXT_SENS_DATA_05 0x4E #define MPU6050_RA_EXT_SENS_DATA_06 0x4F #define MPU6050_RA_EXT_SENS_DATA_07 0x50 #define MPU6050_RA_EXT_SENS_DATA_08 0x51 #define MPU6050_RA_EXT_SENS_DATA_09 0x52 #define MPU6050_RA_EXT_SENS_DATA_10 0x53 #define MPU6050_RA_EXT_SENS_DATA_11 0x54 #define MPU6050_RA_EXT_SENS_DATA_12 0x55 #define MPU6050_RA_EXT_SENS_DATA_13 0x56 #define MPU6050_RA_EXT_SENS_DATA_14 0x57 #define MPU6050_RA_EXT_SENS_DATA_15 0x58

9 50 #define MPU6050_RA_EXT_SENS_DATA_16 0x59 #define MPU6050_RA_EXT_SENS_DATA_17 0x5A #define MPU6050_RA_EXT_SENS_DATA_18 0x5B #define MPU6050_RA_EXT_SENS_DATA_19 0x5C #define MPU6050_RA_EXT_SENS_DATA_20 0x5D #define MPU6050_RA_EXT_SENS_DATA_21 0x5E #define MPU6050_RA_EXT_SENS_DATA_22 0x5F #define MPU6050_RA_EXT_SENS_DATA_23 0x60 #define MPU6050_RA_MOT_DETECT_STATUS 0x61 #define MPU6050_RA_I2C_SLV0_DO 0x63 #define MPU6050_RA_I2C_SLV1_DO 0x64 #define MPU6050_RA_I2C_SLV2_DO 0x65 #define MPU6050_RA_I2C_SLV3_DO 0x66 #define MPU6050_RA_I2C_MST_DELAY_CTRL 0x67 #define MPU6050_RA_SIGNAL_PATH_RESET 0x68 #define MPU6050_RA_MOT_DETECT_CTRL 0x69 #define MPU6050_RA_USER_CTRL 0x6A #define MPU6050_RA_PWR_MGMT_1 0x6B #define MPU6050_RA_PWR_MGMT_2 0x6C #define MPU6050_RA_BANK_SEL 0x6D #define MPU6050_RA_MEM_START_ADDR 0x6E #define MPU6050_RA_MEM_R_W 0x6F #define MPU6050_RA_DMP_CFG_1 0x70 #define MPU6050_RA_DMP_CFG_2 0x71 #define MPU6050_RA_FIFO_COUNTH 0x72 #define MPU6050_RA_FIFO_COUNTL 0x73

10 51 #define MPU6050_RA_FIFO_R_W 0x74 #define MPU6050_RA_WHO_AM_I 0x75 // END / // FUNGSI-FUNGSI PADA SENSOR // void nulis_i2c(unsigned char alamatt,unsigned char regg, unsigned char dataa) i2c_start(); i2c_write(alamatt 0); i2c_write(regg); i2c_write(dataa); i2c_stop(); delay_ms(10); char baca_i2c(unsigned char alamat,unsigned char reg) unsigned char baca; i2c_start(); i2c_write(alamat 0); i2c_write(reg); i2c_start(); i2c_write(alamat 1); baca=i2c_read(0); i2c_stop(); return baca;

11 52 void tes_i2c() unsigned char Datax = 0x00; dodatax=baca_i2c(mpu6050_address, MPU6050_RA_WHO_AM_I); if(datax == 0x68) printf("cek berhasil"); else printf("cek gagal"); delay_ms(1000); while(datax!=0x68); //setelah sesuai dengan register who am i kita lanjut ke setting register : void setup_mpu6050() //f sample ratenya 1k karena DPLF aktif 1000/1+1 = 500Hz nulis_i2c(mpu6050_address,mpu6050_ra_smplrt_div,0x01); //Disable FSync, 48Hz DLPF acceleronya bandwith 44 HZ delay 4.9 gyronya bandwith 42Hz delay 4.8Fs 1k

12 53 nulis_i2c(mpu6050_address,mpu6050_ra_config,0x03); //Disable gyro self tests, scale of 250 degrees/s nulis_i2c(mpu6050_address, MPU6050_RA_GYRO_CONFIG, 0x00); //Disable accel self tests, scale of +-2g, no DHPF nulis_i2c(mpu6050_address, MPU6050_RA_ACCEL_CONFIG, 0b ); //Freefall threshold of 0mg nulis_i2c(mpu6050_address, MPU6050_RA_FF_THR, 0x00); //Freefall duration limit of 0 nulis_i2c(mpu6050_address, MPU6050_RA_FF_DUR, 0x00); //Motion threshold of 0mg nulis_i2c(mpu6050_address, MPU6050_RA_MOT_THR, 0x00); //Motion duration of 0s nulis_i2c(mpu6050_address, MPU6050_RA_MOT_DUR, 0x00); //Zero motion threshold nulis_i2c(mpu6050_address, MPU6050_RA_ZRMOT_THR, 0x00); //Zero motion duration threshold nulis_i2c(mpu6050_address, MPU6050_RA_ZRMOT_DUR, 0x00); //Disable sensor output to FIFO buffer nulis_i2c(mpu6050_address, MPU6050_RA_FIFO_EN, 0x00); //i2c MST CLOCK 348 khz divider 23 dari 8Mhz mpu6050 internal clk nulis_i2c(mpu6050_address, MPU6050_RA_I2C_MST_CTRL, 0x00); //Setup AUX I2C slaves nulis_i2c(mpu6050_address, MPU6050_RA_I2C_SLV0_ADDR, 0x00); nulis_i2c(mpu6050_address, MPU6050_RA_I2C_SLV0_REG, 0x00); nulis_i2c(mpu6050_address, MPU6050_RA_I2C_SLV0_CTRL, 0x00);

13 54 nulis_i2c(mpu6050_address, MPU6050_RA_I2C_SLV1_ADDR, 0x00); nulis_i2c(mpu6050_address, MPU6050_RA_I2C_SLV1_REG, 0x00); nulis_i2c(mpu6050_address, MPU6050_RA_I2C_SLV1_CTRL, 0x00); nulis_i2c(mpu6050_address, MPU6050_RA_I2C_SLV2_ADDR, 0x00); nulis_i2c(mpu6050_address, MPU6050_RA_I2C_SLV2_REG, 0x00); nulis_i2c(mpu6050_address, MPU6050_RA_I2C_SLV2_CTRL, 0x00); nulis_i2c(mpu6050_address, MPU6050_RA_I2C_SLV3_ADDR, 0x00); nulis_i2c(mpu6050_address, MPU6050_RA_I2C_SLV3_REG, 0x00); nulis_i2c(mpu6050_address, MPU6050_RA_I2C_SLV3_CTRL, 0x00); nulis_i2c(mpu6050_address, MPU6050_RA_I2C_SLV4_ADDR, 0x00); nulis_i2c(mpu6050_address, MPU6050_RA_I2C_SLV4_REG, 0x00); nulis_i2c(mpu6050_address, MPU6050_RA_I2C_SLV4_DO, 0x00); nulis_i2c(mpu6050_address, MPU6050_RA_I2C_SLV4_CTRL, 0x00); nulis_i2c(mpu6050_address, MPU6050_RA_I2C_SLV4_DI, 0x00); //MPU6050_RA_I2C_MST_STATUS //Read-only //Setup INT pin and AUX I2C pass through nulis_i2c(mpu6050_address, MPU6050_RA_INT_PIN_CFG, 0x00); //Enable data ready interrupt nulis_i2c(mpu6050_address, MPU6050_RA_INT_ENABLE, 0x00); //Slave out, dont care nulis_i2c(mpu6050_address, MPU6050_RA_I2C_SLV0_DO, 0x00); nulis_i2c(mpu6050_address, MPU6050_RA_I2C_SLV1_DO, 0x00); nulis_i2c(mpu6050_address, MPU6050_RA_I2C_SLV2_DO, 0x00); nulis_i2c(mpu6050_address, MPU6050_RA_I2C_SLV3_DO, 0x00); //More slave config

14 55 nulis_i2c(mpu6050_address, MPU6050_RA_I2C_MST_DELAY_CTRL, 0x00); //Reset sensor signal paths nulis_i2c(mpu6050_address, MPU6050_RA_SIGNAL_PATH_RESET, 0x00); //Motion detection control nulis_i2c(mpu6050_address, MPU6050_RA_MOT_DETECT_CTRL, 0x00); //Disables FIFO, AUX I2C, FIFO and I2C reset bits to 0 nulis_i2c(mpu6050_address, MPU6050_RA_USER_CTRL, 0x00); //Sets clock source to gyro reference w/ PLL nulis_i2c(mpu6050_address, MPU6050_RA_PWR_MGMT_1, 0b ); //Controls frequency of wakeups in accel low power mode plus the sensor standby modes nulis_i2c(mpu6050_address, MPU6050_RA_PWR_MGMT_2, 0x00); nulis_i2c(mpu6050_address, MPU6050_RA_FIFO_R_W, 0x00); printf("setup done"); delay_ms(1000); //setelah menulis register-register ini sensor data sensor siap di akuisisi. pertama akusisi data accelero //contoh programnya seperti dibawah: void akusisi_accel() axx_xh = baca_i2c(mpu6050_address,mpu6050_ra_accel_xout_h); axx_xl = baca_i2c(mpu6050_address,mpu6050_ra_accel_xout_l); axx_yh = baca_i2c(mpu6050_address,mpu6050_ra_accel_yout_h);

15 56 axx_yl = baca_i2c(mpu6050_address,mpu6050_ra_accel_yout_l); axx_zh = baca_i2c(mpu6050_address,mpu6050_ra_accel_zout_h); axx_zl = baca_i2c(mpu6050_address,mpu6050_ra_accel_zout_l); axx_x = ((axx_xh<<8) axx_xl)/100; axx_y = ((axx_yh<<8) axx_yl)/100; axx_z = ((axx_zh<<8) axx_zl)/100; axx_sudut_x =(float) *atan((float)axx_y/ sqrt(pow((float)axx_z,2)+pow((float)axx_x,2))); axx_sudut_y =(float) *atan((float)-axx_x/ sqrt(pow((float)axx_z,2)+pow((float)axx_y,2))); axx_sudut_z =(float) *atan(sqrt(pow((float)axx_x,2)+pow((float)axx_y,2))/(float)axx_z); // END // void main(void) // Declare your local variables here // Input/Output Ports initialization // Port A initialization // Function: Bit7=In Bit6=In Bit5=In Bit4=In Bit3=In Bit2=In Bit1=In Bit0=In DDRA=(0<<DDA7) (0<<DDA6) (0<<DDA5) (0<<DDA4) (0<<DDA3) (0<<DDA2) (0<<DDA1) (0<<DDA0); // State: Bit7=T Bit6=T Bit5=T Bit4=T Bit3=T Bit2=T Bit1=T Bit0=T PORTA=(0<<PORTA7) (0<<PORTA6) (0<<PORTA5) (0<<PORTA4) (0<<PORTA3) (0<<PORTA2) (0<<PORTA1) (0<<PORTA0); // Port B initialization // Function: Bit7=In Bit6=In Bit5=In Bit4=In Bit3=In Bit2=In Bit1=In Bit0=In

16 57 DDRB=(0<<DDB7) (0<<DDB6) (0<<DDB5) (0<<DDB4) (0<<DDB3) (0<<DDB2) (0<<DDB1) (0<<DDB0); // State: Bit7=T Bit6=T Bit5=T Bit4=T Bit3=T Bit2=T Bit1=T Bit0=T PORTB=(0<<PORTB7) (0<<PORTB6) (0<<PORTB5) (0<<PORTB4) (0<<PORTB3) (0<<PORTB2) (0<<PORTB1) (0<<PORTB0); // Port C initialization // Function: Bit7=In Bit6=In Bit5=In Bit4=In Bit3=In Bit2=In Bit1=In Bit0=In DDRC=(0<<DDC7) (0<<DDC6) (0<<DDC5) (0<<DDC4) (0<<DDC3) (0<<DDC2) (0<<DDC1) (0<<DDC0); // State: Bit7=T Bit6=T Bit5=T Bit4=T Bit3=T Bit2=T Bit1=T Bit0=T PORTC=(0<<PORTC7) (0<<PORTC6) (0<<PORTC5) (0<<PORTC4) (0<<PORTC3) (0<<PORTC2) (0<<PORTC1) (0<<PORTC0); // Port D initialization // Function: Bit7=In Bit6=In Bit5=In Bit4=In Bit3=In Bit2=In Bit1=In Bit0=In DDRD=(0<<DDD7) (0<<DDD6) (0<<DDD5) (0<<DDD4) (0<<DDD3) (0<<DDD2) (0<<DDD1) (0<<DDD0); // State: Bit7=T Bit6=T Bit5=T Bit4=T Bit3=T Bit2=T Bit1=T Bit0=T PORTD=(0<<PORTD7) (0<<PORTD6) (0<<PORTD5) (0<<PORTD4) (0<<PORTD3) (0<<PORTD2) (0<<PORTD1) (0<<PORTD0); // Timer/Counter 0 initialization // Clock source: System Clock // Clock value: Timer 0 Stopped // Mode: Normal top=0xff // OC0 output: Disconnected TCCR0=(0<<WGM00) (0<<COM01) (0<<COM00) (0<<WGM01) (0<<CS02) (0<<CS01) (0<<CS00);

17 58 TCNT0=0x00; OCR0=0x00; // Timer/Counter 1 initialization // Clock source: System Clock // Clock value: Timer1 Stopped // Mode: Normal top=0xffff // OC1A output: Disconnected // OC1B output: Disconnected // Noise Canceler: Off // Input Capture on Falling Edge // Timer1 Overflow Interrupt: Off // Input Capture Interrupt: Off // Compare A Match Interrupt: Off // Compare B Match Interrupt: Off TCCR1A=(0<<COM1A1) (0<<COM1A0) (0<<COM1B1) (0<<COM1B0) (0<<WGM11) (0<<WGM10); TCCR1B=(0<<ICNC1) (0<<ICES1) (0<<WGM13) (0<<WGM12) (0<<CS12) (0<<CS11) (0<<CS10); TCNT1H=0x00; TCNT1L=0x00; ICR1H=0x00; ICR1L=0x00; OCR1AH=0x00; OCR1AL=0x00; OCR1BH=0x00; OCR1BL=0x00;

18 59 // Timer/Counter 2 initialization // Clock source: System Clock // Clock value: Timer2 Stopped // Mode: Normal top=0xff // OC2 output: Disconnected ASSR=0<<AS2; TCCR2=(0<<PWM2) (0<<COM21) (0<<COM20) (0<<CTC2) (0<<CS22) (0<<CS21) (0<<CS20); TCNT2=0x00; OCR2=0x00; // Timer(s)/Counter(s) Interrupt(s) initialization TIMSK=(0<<OCIE2) (0<<TOIE2) (0<<TICIE1) (0<<OCIE1A) (0<<OCIE1B) (0<<TOIE1) (0<<OCIE0) (0<<TOIE0); // External Interrupt(s) initialization // INT0: Off // INT1: Off // INT2: Off MCUCR=(0<<ISC11) (0<<ISC10) (0<<ISC01) (0<<ISC00); MCUCSR=(0<<ISC2); // USART initialization // Communication Parameters: 8 Data, 1 Stop, No Parity // USART Receiver: On // USART Transmitter: On // USART Mode: Asynchronous // USART Baud Rate: 9600

19 60 UCSRA=(0<<RXC) (0<<TXC) (0<<UDRE) (0<<FE) (0<<DOR) (0<<UPE) (0<<U2X) (0<<MPCM); UCSRB=(1<<RXCIE) (1<<TXCIE) (0<<UDRIE) (1<<RXEN) (1<<TXEN) (0<<UCSZ2) (0<<RXB8) (0<<TXB8); UCSRC=(1<<URSEL) (0<<UMSEL) (0<<UPM1) (0<<UPM0) (0<<USBS) (1<<UCSZ1) (1<<UCSZ0) (0<<UCPOL); UBRRH=0x00; UBRRL=0x47; // Analog Comparator initialization // Analog Comparator: Off // The Analog Comparator's positive input is // connected to the AIN0 pin // The Analog Comparator's negative input is // connected to the AIN1 pin ACSR=(1<<ACD) (0<<ACBG) (0<<ACO) (0<<ACI) (0<<ACIE) (0<<ACIC) (0<<ACIS1) (0<<ACIS0); SFIOR=(0<<ACME); // ADC initialization // ADC disabled ADCSRA=(0<<ADEN) (0<<ADSC) (0<<ADATE) (0<<ADIF) (0<<ADIE) (0<<ADPS2) (0<<ADPS1) (0<<ADPS0); // SPI initialization // SPI disabled SPCR=(0<<SPIE) (0<<SPE) (0<<DORD) (0<<MSTR) (0<<CPOL) (0<<CPHA) (0<<SPR1) (0<<SPR0);

20 61 // TWI initialization // TWI disabled TWCR=(0<<TWEA) (0<<TWSTA) (0<<TWSTO) (0<<TWEN) (0<<TWIE); // Bit-Banged I2C Bus initialization // I2C Port: PORTA // I2C SDA bit: 0 // I2C SCL bit: 1 // Bit Rate: 100 khz // Note: I2C settings are specified in the // Project Configure C Compiler Libraries I2C menu. i2c_init // Global enable interrupts #asm("sei") tes_i2c(); setup_mpu6050(); while (1) akusisi_accel(); (data_raw*16,384/32000)*9,81; printf("%da%db%dc%dd",axx_x,axx_y,axx_z,); delay_ms(10);

21 62 Program tampilan PC dalam Software delphi unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, CPort, DB, ADODB, ExtCtrls, DBCtrls, Grids, DBGrids, RpCon, RpConDS, RpDefine, RpRave, SUIForm, TeEngine, Series, TeeProcs, Chart; type TForm1 = class(tform) ComPort1: TComPort; GroupBox1: TGroupBox; Label1: TLabel; Label2: TLabel; Label3: TLabel; Edit1: TEdit; Edit2: TEdit; Edit3: TEdit; GroupBox2: TGroupBox; Button1: TButton; Button2: TButton; Button4: TButton; Label4: TLabel; ListBox1: TListBox; Edit4: TEdit; Label5: TLabel; Button3: TButton; GroupBox3: TGroupBox; DBGrid1: TDBGrid; DBNavigator1: TDBNavigator; ADOConnection1: TADOConnection; ADOTable1: TADOTable; DataSource1: TDataSource; Label6: TLabel; Label7: TLabel; Timer1: TTimer; Button5: TButton; RvProject1: TRvProject; RvDataSetConnection1: TRvDataSetConnection; suiform1: TsuiForm; Chart1: TChart; Series1: TFastLineSeries; Timer2: TTimer;

22 63 Timer3: TTimer; Button6: TButton; Series2: TFastLineSeries; Series3: TFastLineSeries; Series4: TFastLineSeries; procedure Button4Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure ComPort1RxChar(Sender: TObject; Count: Integer); procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure Timer1Timer(Sender: TObject); procedure Timer2Timer(Sender: TObject); procedure Button5Click(Sender: TObject); procedure Timer3Timer(Sender: TObject); procedure Button6Click(Sender: TObject); private Private declarations public Public declarations var Form1: TForm1; implementation $R *.dfm procedure TForm1.Button4Click(Sender: TObject); comport1.showsetupdialog; procedure TForm1.Button3Click(Sender: TObject); close; //close aplikasi procedure TForm1.FormDestroy(Sender: TObject); //jika form langsung ditutup,comport otomatis nutup sendiri if comport1.connected = true then comport1.connected := false;

23 64 ///////////////////////////////////////////////////////////////////////////////// //////////////////////////INTI PROGRAM/////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////// procedure TForm1.ComPort1RxChar(Sender: TObject; Count: Integer); var A, B, C, D, DataA, DataB, DataC, DataD :string; s :TstringList D,E,F,DataD,DataE,DataF,,dan seterusnya.. cari string 'A', jika ketemu string 'A' maka string SEBELUM 'A' atau data murni akan di taruh dilistbox1 dan string 'A' di delimiter(dihapus). data dilistbox1 akan diambil dan ditampilkan ke edit1, begitu berurutan untuk data setelahnya. kok bisa? ya karena nantinya format pengiriman datanya kan untuk misal 4 sensor suhu LM35 adalah 30A40B50C60D jadi dari format itu kan yg dimasukkan ke edit1 adalah 30 aja,sedangkan string pengenal 'A' masuk ke listbox1 trus dihapus, data sensor berurutan dari A,B,C,D //////////////////SENSOR 1 delimiter string 'A'//////////////////////// ////////////////////////////////////////////////////////////////////// repeat comport1.readstr(a,1); DataA:=DataA+A; until A='A'; s:=tstringlist.create; s.delimiter:='a'; s.delimitedtext:=dataa; listbox1.items:=s; edit1.text:=listbox1.items[0 listbox1.clear; //////////////////////AKHIR UNTUK SENSOR 1/////////////////////////////// //////////////////SENSOR 2 delimiter string 'B'//////////////////////// ////////////////////////////////////////////////////////////////////// repeat comport1.readstr(b,1); DataB:=DataB+B; until B='B'; s:=tstringlist.create; s.delimiter:='b'; s.delimitedtext:=datab;

24 65 listbox1.items:=s; edit2.text:=listbox1.items[0]; listbox1.clear; //////////////////////AKHIR UNTUK SENSOR 2/////////////////////////////// //////////////////SENSOR 3 delimiter string 'C'//////////////////////// ////////////////////////////////////////////////////////////////////// repeat comport1.readstr(c,1); DataC:=DataC+C; until C='C'; s:=tstringlist.create; s.delimiter:='c'; s.delimitedtext:=datac; listbox1.items:=s; edit3.text:=listbox1.items[0]; listbox1.clear; //////////////////////AKHIR UNTUK SENSOR 3/////////////////////////////// //////////////////SENSOR D delimiter string 'D'//////////////////////// ////////////////////////////////////////////////////////////////////// repeat comport1.readstr(d,1); DataD:=DataD+D; until D='D'; s:=tstringlist.create; s.delimiter:='d'; s.delimitedtext:=datad; listbox1.items:=s; edit4.text:=listbox1.items[0]; listbox1.clear; //////////////////////AKHIR UNTUK SENSOR 4/////////////////////////////// adotable1.open; adotable1.app adotable1.fieldbyname('sensor 1').AsString:=edit1.Text; adotable1.fieldbyname('sensor 2').AsString:=edit2.Text; adotable1.fieldbyname('sensor 3').AsString:=edit3.Text; adotable1.fieldbyname('sensor 4').AsString:=edit4.Text; adotable1.fieldbyname('time').asstring:=label7.caption; adotable1.post;

25 66 /////////////////////////////////////////////////////////////////////////// //////////////////////////AKHIR INTI PROGRAM/////////////////////////////// /////////////////////////////////////////////////////////////////////////// procedure TForm1.Button1Click(Sender: TObject); if comport1.connected = false then comport1.connected := true; procedure TForm1.Button2Click(Sender: TObject); if comport1.connected = true then comport1.connected := false; timer3.enabled:=false; procedure TForm1.FormCreate(Sender: TObject); var alamatdb : WideString; alamatdb := ExtractFilePath(Application.ExeName) + 'database.mdb'; with ADOConnection1 do Connected := False; LoginPrompt := False; Mode := cmsharedenynone; ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=' + alamatdb + ';Persist Security Info=False'; ADOConnection1.Connected := True; ADOtable1.Connection:= ADOConnection1; ADOtable1.TableName:='dataTemperature'; ADOtable1.Active:=true; Datasource1.DataSet:= ADOTable1; DBGrid1.DataSource:= DataSource1; RvProject1.ProjectFile:='project1.rav' ; form1.position := podesktopcenter; listbox1.visible := false; label7.caption:=timetostr(time); procedure TForm1.Timer1Timer(Sender: TObject); label7.caption:=timetostr(now); procedure TForm1.Timer2Timer(Sender: TObject); IF LABEL7.Visible Then label7.hide else

26 67 label7.visible:=true; procedure TForm1.Button5Click(Sender: TObject); RvProject1.Execute; RvProject1.ExecuteReport('project1.rav'); procedure TForm1.Timer3Timer(Sender: TObject); var suhu1,suhu2,suhu3:integer; suhu4:real; time:string ; suhu1:=strtoint(edit1.text); chart1.series[0].add(suhu1,time,clgreen); suhu2:=strtoint(edit2.text); chart1.series[1].add(suhu2,time,cllime); suhu3:=strtoint(edit3.text); chart1.series[2].add(suhu3,time,clred); suhu4:=strtofloat(edit4.text); chart1.series[3].add(suhu4,time,clblue); procedure TForm1.Button6Click(Sender: TObject); timer3.enabled:=true;

27 68 LAMPIRAN B Gambar grafik di PC pada sofware delphi7 Gambar alat pada saat pengambilan data

28 69 Gambar wireless receiver Gambar alat secara keseluruhan

29 70 Gambar keseluruhan rangkaian LAMPIRAN C KYL-Rx USB serial

Lampiran. Universitas Sumatera Utara

Lampiran. Universitas Sumatera Utara Lampiran LISTING PROGRAM #include #include // Declare your global variables here char buff[16]; unsigned int frekuensi,x; unsigned int detak; // External Interrupt 0 service routine

More information

// Voltage Reference: AREF pin #define ADC_VREF_TYPE ((0<<REFS1) (0<<REFS0) (0<<ADLAR))

// Voltage Reference: AREF pin #define ADC_VREF_TYPE ((0<<REFS1) (0<<REFS0) (0<<ADLAR)) 44 Lampiran 1 Listing program dari seluruh sistem. /****************************************************** * This program was created by the CodeWizardAVR V3.12 Advanced Automatic Program Generator Copyright

More information

Lampiran 1 Tabel data normalisasi lemari tabung LPG dari alat Konsentrasi Gas LPG Konsentrasi Gas

Lampiran 1 Tabel data normalisasi lemari tabung LPG dari alat Konsentrasi Gas LPG Konsentrasi Gas 52 Lampiran 1 Tabel data normalisasi lemari tabung LPG dari alat Konsentrasi Gas LPG Konsentrasi Gas Waktu (s) Data 1 (ppm) Data 2 (ppm) Data 3 (ppm) LPG Rata-rata (ppm) 10 2640,02 2725,35 2773,96 2713,11

More information

Universitas Sumatera Utara

Universitas Sumatera Utara 55 Lampiran 1. Konfigurasi Program Menghitung Data Komputer (Bahasa C) pada Mikro /******************************************************* This program was created by the CodeWizardAVR V2.60 Standard Automatic

More information

LAMPIRAN A. I. Gambar alat percobaan I.1. Power supply. 1. Rangkaian sekunder 2. Dioda. 3. Heatsink 4. Power supply (keseluruhan)

LAMPIRAN A. I. Gambar alat percobaan I.1. Power supply. 1. Rangkaian sekunder 2. Dioda. 3. Heatsink 4. Power supply (keseluruhan) 100 I. Gambar alat percobaan I.1. Power supply LAMPIRAN A 1. Rangkaian sekunder 2. Dioda 3. Heatsink 4. Power supply (keseluruhan) 101 I.2 Gambar bagian bagian alat pemanas induksi 1. Kumparan Solenoide

More information

LAMPIRAN A PROGRAM UTAMA ROBOT NOMOR 2

LAMPIRAN A PROGRAM UTAMA ROBOT NOMOR 2 LAMPIRAN A PROGRAM UTAMA ROBOT NOMOR 2 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: [Bioloid Premium]-Robot 2 v 2 22: 23: 24: 25: A-1 26: 27: 28: 29: 30: 31: 32: 33: 34: 35:

More information

LAMPIRAN A FOTO Radio Control Helikopter dan Pengendalinya

LAMPIRAN A FOTO Radio Control Helikopter dan Pengendalinya LAMPIRAN A FOTO Radio Control Helikopter dan Pengendalinya Tampak Atas A-1 Tampak Depan A-2 Tampak Samping A-3 Tampak Belakang A-4 Pengendali A-5 LAMPIRAN B PROGRAM PADA MICROSOFT VISUAL BASIC 6 DAN PENGONTROL

More information

LAMPIRAN - A. Instruksi Mikrokontroler

LAMPIRAN - A. Instruksi Mikrokontroler LAMPIRAN - A Instruksi Mikrokontroler /***************************************************** This program was produced by the CodeWizardAVR V1.25.3 Professional Automatic Program Generator Copyright 1998-2007

More information

LAMPIRAN. Universitas Sumatera Utara

LAMPIRAN. Universitas Sumatera Utara LAMPIRAN Program Untuk Mengetes Huruf R Pada Matriks 8x8 /******************************************************* This program was created by the CodeWizardAVR V3.09 Standard Automatic Program Generator

More information

LAMPIRAN A. Foto Alat

LAMPIRAN A. Foto Alat LAMPIRAN A Foto Alat A-1 A-2 Rangkaian Skematik PCB Sistem Monitoring Infus A-3 LAMPIRAN B Program pada Mikrokontroller AVR Atmega16...B-1 Program pada Borlan Delhpi 7.0...B-9 PROGRAM UTAMA /*****************************************************

More information

LAMPIRAN A. Listing Program. Program pada Borland Delphi 7.0 A-1 Program pada CodeVisionAVR C Compiler A-6

LAMPIRAN A. Listing Program. Program pada Borland Delphi 7.0 A-1 Program pada CodeVisionAVR C Compiler A-6 A Listing Program Program pada Borland Delphi 7.0 A-1 Program pada CodeVisionAVR C Compiler A-6 LISTING PROGRAM BORLAND DELPHI 7.0 Inisialisasi ==========================================================

More information

LAMPIRAN A. Universitas Sumatera Utara

LAMPIRAN A. Universitas Sumatera Utara 63 LAMPIRAN A Rangkaian Lengkap Perangkat Keras Rangkaian ini terdiri dari Rangkaian Power Supply (PSA), Mikrokontroller atmega8535, RFID Reader ID 12, Rangkaian Infra Merah Fotodioda, driver max232 dan

More information

LAMPIRAN. 1. Program Alat

LAMPIRAN. 1. Program Alat LAMPIRAN 1. Program Alat This program was produced by the CodeWizardAVR V2.03.4 Standard Automatic Program Generator Copyright 1998-2008 Pavel Haiduc, HP InfoTech s.r.l. http://www.hpinfotech.com Project

More information

Appendix to Vehicle Automation and Security (Matthew Grojean & Nathan Hart) Nathan Hart Professor Zalewski 04/25/2014

Appendix to Vehicle Automation and Security (Matthew Grojean & Nathan Hart) Nathan Hart Professor Zalewski 04/25/2014 Page 1 Appendix to Vehicle Automation and Security (Matthew Grojean & Nathan Hart) Nathan Hart Professor Zalewski 04/25/2014 A1. Overview of Previous Project The goal of the original Vehicle Automation

More information

LAMPIRAN. Program Keseluruhan Sistem Pengontrolan Level Air

LAMPIRAN. Program Keseluruhan Sistem Pengontrolan Level Air LAMPIRAN Program Keseluruhan Sistem Pengontrolan Level Air /***************************************************** This program was produced by the CodeWizardAVR V2.03.4 Standard Automatic Program Generator

More information

Getting Started With the Micro64

Getting Started With the Micro64 1.0 Software Installation Getting Started With the Micro64 1.1 Installing the CodeVisionAVR C Compiler 1. Open the CodeVisionAVR Demo folder on the CD. 5. Click the Next button and the following window

More information

LAMPIRAN A FOTO ALAT

LAMPIRAN A FOTO ALAT LAMPIRAN A FOTO ALAT Gambar A.1. Gambar robot mobil dilihat dari atas Gambar A.2. Gambar robot mobil dilihat dari depan Gambar A.3. Gambar robot mobil dilihat dari samping Gambar A.4. Gambar keseluruhan

More information

RANGKAIAN LENGKAP. Universitas Sumatera Utara

RANGKAIAN LENGKAP. Universitas Sumatera Utara RANGKAIAN LENGKAP Lampiran Program /***************************************************** This program was produced by the CodeWizardAVR V1.25.8 Professional Automatic Program Generator Copyright 1998-2007

More information

// WRITE data to be written to EEPROM

// WRITE data to be written to EEPROM /***************************************************** This program was produced by the CodeWizardAVR V2.03.9 Evaluation Automatic Program Generator Copyright 1998-2008 Pavel Haiduc, HP InfoTech s.r.l.

More information

LAMPIRAN A FOTO ROBOT BERKAKI ENAM

LAMPIRAN A FOTO ROBOT BERKAKI ENAM LAMPIRAN A FOTO ROBOT BERKAKI ENAM A-1 A-2 LAMPIRAN B PROGRAM PADA PENGONTROL ATMEGA16 DAN ATTINY2313 B-1 1. Robot mampu berjalan sesuai dengan langkah dan arah yang dimasukkan melalui keypad. ATMEGA16

More information

LAMPIRAN A List Program CodeVision Generato Data...A-1 List Program CodeVision Multiplexer...A-11 List Program CodeVision Demultiplexer...

LAMPIRAN A List Program CodeVision Generato Data...A-1 List Program CodeVision Multiplexer...A-11 List Program CodeVision Demultiplexer... LAMPIRAN A List Program CodeVision Generato Data...A-1 List Program CodeVision Multiplexer...A-11 List Program CodeVision Demultiplexer...A-14 List Program Codevision Generator Data /****************************************

More information

Gambar A-1 Foto alat prototype infrared thermometer

Gambar A-1 Foto alat prototype infrared thermometer LAMPIRAN A Foto Alat Gambar A-1 Foto alat prototype infrared thermometer A-1 LAMPIRAN A A-2 LAMPIRAN A Daftar Komponen yang digunakan Komponen Aktif Nama komponen Fungsi Jumlah AVR ATMega 8535 Mikrokontroler

More information

ECE477: Team 10 Software Design Considerations, Narrative, and Documentation

ECE477: Team 10 Software Design Considerations, Narrative, and Documentation TABLE OF CONTENTS 1 INTRODUCTION...2 1.1 MASTER DEVICE...2 1.2 SLAVE (SITE) DEVICE...2 1.3 CONNECTING BUS...2 2 MASTER DEVICE...3 2.1 SOFTWARE DESIGN CONSIDERATIONS...3 2.1.1 Memory Considerations...3

More information

19.1. Unit 19. Serial Communications

19.1. Unit 19. Serial Communications 9. Unit 9 Serial Communications 9.2 Serial Interfaces Embedded systems often use a serial interface to communicate with other devices. Serial implies that it sends or receives one bit at a time. µc Device

More information

LAMPIRAN A LIST PROGRAM SERVER DAN CLIENT

LAMPIRAN A LIST PROGRAM SERVER DAN CLIENT 1 LAMPIRAN A LIST PROGRAM SERVER DAN CLIENT 2 KETERANGAN OBJEK KONTROL SERVER (VB.6) OBJEK PROPERTY SETTING Command1 Caption Exit Command2 Caption START Command3 Caption UP Command4 Caption DOWN Command5

More information

LAMPIRAN A GAMBAR SISTEM

LAMPIRAN A GAMBAR SISTEM LAMPIRAN A GAMBAR SISTEM SISTEM OBJEK TAMPAK DALAM SISTEM OBJEK TAMPAK LUAR SISTEM PENERIMA LAMPIRAN B PROGRAM AVR ATMEGA 128 /***************************************************** Chip type : ATmega128L

More information

UJIAN AKHIR SEMESTER TEKNIK INFORMATIKA SEKOLAH TINGGI TEKNOLOGI DUTA BANGSA

UJIAN AKHIR SEMESTER TEKNIK INFORMATIKA SEKOLAH TINGGI TEKNOLOGI DUTA BANGSA UJIAN AKHIR SEMESTER TEKNIK INFORMATIKA SEKOLAH TINGGI TEKNOLOGI DUTA BANGSA Dosen Pembimbing : Dedi W ST,. MM Nama : Elly Sunandy NIM : 13158279 Pemrograman Terstruktur Membuat program dengan Delphi 7

More information

USART Register Description

USART Register Description USART Register Description USART I/O Data Register UDR RXB[7:0] TXB[7:0] Read/Write R/W R/W R/W R/W R/W R/W R/W R/W Initial Value 0 0 0 0 0 0 0 0 UDR (Read) UDR (Write) The USART Transmit Data Buer Register

More information

Ali Karimpour Associate Professor Ferdowsi University of Mashhad

Ali Karimpour Associate Professor Ferdowsi University of Mashhad AUTOMATIC CONTROL SYSTEMS Ali Karimpour Associate Professor Ferdowsi University of Mashhad Reference: Microcontroller Based Applied Digital Control Dogan Ibrahim, John Wiley & Sons Ltd, 2006 Liquid Level

More information

L A M P I R A N UNIVERSITAS KRISTEN MARANTHA

L A M P I R A N UNIVERSITAS KRISTEN MARANTHA L A M P I R A N LAMPIRAN B LISTING PROGRAM MIKROKONTROLER //Simplest universal VGA(20x20)/PAL(38x20) terminal //For sync used Timer0 Timer1 //To avoid flickering while receive UART data,recommend

More information

Set of pulse decoding algorithms for quadrature rotary and linear encoders*

Set of pulse decoding algorithms for quadrature rotary and linear encoders* version 1.2 Set of pulse decoding algorithms for quadrature rotary and linear encoders* (*) Algorithms are likely platform nonindependent in performance comparison. However results are based to the Atmel

More information

uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, ImgList, StdCtrls, Buttons, MPlayer;

uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, ImgList, StdCtrls, Buttons, MPlayer; unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, ImgList, StdCtrls, Buttons, MPlayer; type TForm1 = class(tform) Cenario: TImage;

More information

School of Electrical, Computer and Telecommunications Engineering University of Wollongong Australia

School of Electrical, Computer and Telecommunications Engineering University of Wollongong Australia ECTE333 s schedule ECTE333 Lecture 9 -Timers School of Electrical, Computer and Telecommunications Engineering University of Wollongong Australia Week Lecture (2h) Tutorial (h) Lab (2h) L7: C programming

More information

ADC: Analog to Digital Conversion

ADC: Analog to Digital Conversion ECE3411 Fall 2015 Lecture 5b. ADC: Analog to Digital Conversion Marten van Dijk, Syed Kamran Haider Department of Electrical & Computer Engineering University of Connecticut Email: {vandijk, syed.haider}@engr.uconn.edu

More information

CSCE 236 Embedded Systems, Fall 2017 Homework 5

CSCE 236 Embedded Systems, Fall 2017 Homework 5 CSCE 236 Embedded Systems, Fall 2017 Homework 5 Started: Tuesday, November 7th, 2017 Due: Friday, November 17th, 2017 (5pm) Instructions: This homework is an individual assignment, collaboration is not

More information

UART: Universal Asynchronous Receiver & Transmitter

UART: Universal Asynchronous Receiver & Transmitter ECE3411 Fall 2015 Lecture 2a. UART: Universal Asynchronous Receiver & Transmitter Marten van Dijk, Syed Kamran Haider Department of Electrical & Computer Engineering University of Connecticut Email: {vandijk,

More information

COMP2121: Microprocessors and Interfacing

COMP2121: Microprocessors and Interfacing COMP2121: Microprocessors and Interfacing Lecture 25: Serial Input/Output (II) Overview USART (Universal Synchronous and Asynchronous serial Receiver and Transmitter) in AVR http://www.cse.unsw.edu.au/~cs2121

More information

Software Design Considerations, Narrative and Documentation

Software Design Considerations, Narrative and Documentation Software Design Considerations, Narrative and Documentation Introduction The project under consideration is an automated shopping cart designed to follow a shopper around a simulated supermarket environment.

More information

Serial Communications

Serial Communications 1 Serial Interfaces 2 Embedded systems often use a serial interface to communicate with other devices. Serial Communications Serial implies that it sends or receives one bit at a time. Serial Interfaces

More information

Features 2.4 GHz Carrier Frequency RS232 UART interface with variable baud rate Input supply voltage: 5V to 12V 255 possible Channels frequencies (0 to 255) Programmable Device Address (255 per channel)

More information

Project : Version : Date : 11/04/2016 Author : Freeware, for evaluation and non-commercial use only Company : Comments:

Project : Version : Date : 11/04/2016 Author : Freeware, for evaluation and non-commercial use only Company : Comments: Lampiran 1 Listing program dari seluruh sistem. /***************************************************** This program was produced by the CodeWizardAVR V2.04.9 Evaluation Automatic Program Generator Copyright

More information

ATmega128 USART. Overview

ATmega128 USART. Overview USART Dual USART Overview The Universal Synchronous and Asynchronous serial Receiver and Transmitter (USART) is a highly flexible serial communication device. The main features are: Full Duplex Operation

More information

How2Use DT-AVR ATMEGA168 BMS. By: IE Team. Picture 1 The layout of DT-AVR ATMEGA168 BMS

How2Use DT-AVR ATMEGA168 BMS. By: IE Team. Picture 1 The layout of DT-AVR ATMEGA168 BMS DT-AVR ATMEGA168 BMS Application Note By: IE Team This Application Note (AN) serves as a tutorial of how to use the DT-AVR ATMEGA168 Bootloader Micro System along with its supplementary software. The layout

More information

Serial Compact Flash Serial CF Card Module User Manual

Serial Compact Flash Serial CF Card Module User Manual CUBLOC Peripheral Serial Compact Flash Serial Card Module User Manual 3. Specifications Model -COM5 -COM3 Voltage 4.5~5.5V 2.7~5.5V - 115200 bps: 20KB/s - 115200 bps: 15KB/s Read Speed - 9600 bps: 6KB/s

More information

ATmega328PB. Introduction. Feature. 8-bit AVR Microcontroller DATASHEET SUMMARY

ATmega328PB. Introduction. Feature. 8-bit AVR Microcontroller DATASHEET SUMMARY 8-bit AVR Microcontroller ATmega328PB DATASHEET SUMMARY Introduction The Atmel ATmega328PB is a low-power CMOS 8-bit microcontroller based on the AVR enhanced RISC architecture. By executing powerful instructions

More information

How to use RFpro in Packet Mode

How to use RFpro in Packet Mode How to use RFpro in Packet Mode Jumper Setting Priority Jumper J1 à Configuration Mode Jumper à Higher Priority Jumper J2 à Packet Mode Jumper à Lower Priority When both the jumpers are connected, by default,

More information

Marten van Dijk, Syed Kamran Haider

Marten van Dijk, Syed Kamran Haider ECE3411 Fall 2015 Lecture 3b. Timers 0, 1 & 2 Marten van Dijk, Syed Kamran Haider Department of Electrical & Computer Engineering University of Connecticut Email: vandijk, syed.haider@engr.uconn.edu Based

More information

ATmega32 Reference Guide

ATmega32 Reference Guide ATmega32 Reference Guide 1 ATmega32 Reference Guide Ver. 1.0 9-20-2005 1 Features High-performance, Low-power RISC Architecture 8-bit Microcontroller 32 x 8 General Purpose Working Registers Fully Static

More information

Introduction. Unit 4. Numbers in Other Bases in C/C++ BIT FIDDLING. Microcontrollers (Arduino) Overview Digital I/O

Introduction. Unit 4. Numbers in Other Bases in C/C++ BIT FIDDLING. Microcontrollers (Arduino) Overview Digital I/O 4.1 4.2 Introduction Unit 4 Microcontrollers () Overview Digital I/O The primary way that software controls hardware is by manipulating individual bits We need to learn how to: Set a bit to a 1 Clear a

More information

Embedded Systems and Software. Serial Communication

Embedded Systems and Software. Serial Communication Embedded Systems and Software Serial Communication Slide 1 Using RESET Pin on AVRs Normally RESET, but can be configured via fuse setting to be general-purpose I/O Slide 2 Disabling RESET Pin on AVRs Normally

More information

Supplementary Materials: Fabrication of a Lab on Chip Device Using Material Extrusion (3D Printing) and Demonstration via Malaria Ab ELISA

Supplementary Materials: Fabrication of a Lab on Chip Device Using Material Extrusion (3D Printing) and Demonstration via Malaria Ab ELISA S1 of S10 Supplementary Materials: Fabrication of a Lab on Chip Device Using Material Extrusion (3D Printing) and Demonstration via Malaria Ab ELISA Maria Bauer and Lawrence Kulinsky * 1. Program Code

More information

Topic 11: Timer ISMAIL ARIFFIN FKE UTM SKUDAI JOHOR

Topic 11: Timer ISMAIL ARIFFIN FKE UTM SKUDAI JOHOR Topic 11: Timer ISMAIL ARIFFIN FKE UTM SKUDAI JOHOR Introduction Timer s objective Timer features Timer Registers - Understand function of each bit Initialization Introduction o In micro-p, we use counter

More information

Lampiran I. Rangkaian Lengkap Alat. Universitas Sumatera Utara

Lampiran I. Rangkaian Lengkap Alat. Universitas Sumatera Utara Lampiran I Rangkaian Lengkap Alat Lampiran II Program Pada Alat /***************************************************** This program was produced by the CodeWizardAVR V2.04.9 Evaluation Automatic Program

More information

Embedded Systems and Software

Embedded Systems and Software Embedded Systems and Software Serial Communication Serial Communication, Slide 1 Lab 5 Administrative Students should start working on this LCD issues Caution on using Reset Line on AVR Project Posted

More information

Introduction to the DLL for the USB Interface Board K8061

Introduction to the DLL for the USB Interface Board K8061 K8061.DLL 1 Introduction to the DLL for the USB Interface Board K8061 The K8061 interface board has 8 digital input channels and 8 digital output channels. In addition, there are 8 analogue inputs, 8 analogue

More information

Overview RFSv4.3 is a RF module providing easy and flexible wireless data transmission between devices. It is based on AVR Atmega8 with serial output which can be interfaced directly to PC. Features 2.4

More information

LAMPIRAN A: DDL DATABASE

LAMPIRAN A: DDL DATABASE LAMPIRAN A: DDL DATABASE MySQL-Front 5.1 (Build 2.7) Host: localhost Database: mobil ------------------------------------------------------ Server version 5.0.41-community-nt USE `mobil`; Source for table

More information

How2Use DT-AVR ATMEGA128L BMS. Oleh: IE Team. Picture 1 The layout of DT-AVR ATMEGA128L BMS

How2Use DT-AVR ATMEGA128L BMS. Oleh: IE Team. Picture 1 The layout of DT-AVR ATMEGA128L BMS DT-AVR ATMEGA128L BMS Application Note Oleh: IE Team This Application Note (AN) serves as a tutorial of how to use the DT-AVR ATMEGA128L Bootloader Micro System along with its supplementary software. The

More information

AT90S Bit Microcontroller with 8K bytes Downloadable Flash. AT90S8515 Preliminary. Features. Description. Pin Configurations

AT90S Bit Microcontroller with 8K bytes Downloadable Flash. AT90S8515 Preliminary. Features. Description. Pin Configurations Features Utilizes the AVR Enhanced RISC Architecture 120 Powerful Instructions - Most Single Clock Cycle Execution 8K bytes of In-System Reprogrammable Downloadable Flash - SPI Serial Interface for Program

More information

Kada se pokrene forma da bude plave boje. Dugme Crtaj krugove da iscrtava slučajan broj N krugova istog poluprečnika r (1/4 visine forme) čiji su

Kada se pokrene forma da bude plave boje. Dugme Crtaj krugove da iscrtava slučajan broj N krugova istog poluprečnika r (1/4 visine forme) čiji su Kada se pokrene forma da bude plave boje. Dugme Crtaj krugove da iscrtava slučajan broj N krugova istog poluprečnika r (1/4 visine forme) čiji su centri na neiscrtanom krugu poluprečnika r. Dugme Boji

More information

Topic 11: Interrupts ISMAIL ARIFFIN FKE UTM SKUDAI JOHOR

Topic 11: Interrupts ISMAIL ARIFFIN FKE UTM SKUDAI JOHOR Topic 11: Interrupts ISMAIL ARIFFIN FKE UTM SKUDAI JOHOR Objectives To become familiar with interrupts on the AVR Maskable and non-maskable Initialization Triggers To develop interrupt service routines

More information

PROGRAM BASCOM AVR. ' inisialisasi '

PROGRAM BASCOM AVR. ' inisialisasi ' PROGRAM BASCOM AVR '--------------------------------------- inisialisasi '----------------------- $prog &HFF, &HC4, &HD9, &H00 ' generated. Take care that the chip supports all fuse bytes. $regfile = "m8def.dat"

More information

Delphi Generics.Collections

Delphi Generics.Collections Delphi Generics.Collections Copyright(C) 2008 Embarcadero Technologies, Inc. All Rights Reserved. Delphi Generics.Collections Table of Contents Generics.Collections.TCollectionNotification 1 Generics.Collections.TCollectionNotifyEvent

More information

Design with Microprocessors

Design with Microprocessors Design with Microprocessors Lecture 6 Interfaces for serial communication Year 3 CS Academic year 2017/2018 1 st Semester Lecturer: Radu Dănescu Serial communication modules on AVR MCUs Serial Peripheral

More information

AVR094: Replacing ATmega8 by ATmega88. 8-bit Microcontrollers. Application Note. Features. Introduction

AVR094: Replacing ATmega8 by ATmega88. 8-bit Microcontrollers. Application Note. Features. Introduction AVR094: Replacing by 8 Features Interrupt Vectors Bit and Register s and locations Oscillators and Start up Delay Brown Out Detection USART Control Register access Internal Voltage Reference Programming

More information

TIMSK=0b ; /* enables the T/C0 overflow interrupt in the T/C interrupt mask register for */

TIMSK=0b ; /* enables the T/C0 overflow interrupt in the T/C interrupt mask register for */ The codes below which help in better understanding of timers and counters. I have tested this code for atmega32. I have taken reference from www.avrfreaks.net. Hope you all will find this useful. Darsh

More information

Microcomputer/Controller Featuring the ATmega64 or the ATmega128

Microcomputer/Controller Featuring the ATmega64 or the ATmega128 Microcomputer/Controller Featuring the ATmega64 or the ATmega128 FEATURES Small size complete computer/controller with I/O less than 1.5 cubic inches (1.5 x 2.1 x 0.52 ) Low power only 275 mw typical Dual

More information

12.1. Unit 12. Exceptions & Interrupts

12.1. Unit 12. Exceptions & Interrupts 12.1 Unit 12 Exceptions & Interrupts 12.2 Disclaimer 1 This is just an introduction to the topic of interrupts. You are not meant to master these right now but just start to use them We will cover more

More information

AN703. Micro64/128. Accessing the 36k of SRAM 12/3/04

AN703. Micro64/128. Accessing the 36k of SRAM 12/3/04 AN703 Micro64/128 Accessing the 36k of SRAM 12/3/04 Introduction: Micro64/128 has a total of 36k of SRAM. 4 k of SRAM is built into the processor an additional 32k of SRAM is available inside the Micro64/128

More information

WEATHER STATION WITH SERIAL COMMUNICATION

WEATHER STATION WITH SERIAL COMMUNICATION WEATHER STATION WITH SERIAL COMMUNICATION Written by: Wenbo Ye, Xiao Qu, Carl-Wilhelm Igelström FACULTY OF ENGINEERING, LTH Digital and Analogue Projects EITF11 Contents Introduction... 2 Requirements...

More information

4. Application Programming

4. Application Programming 4. Application Programming 4.1 Writing an Application The C programming language, not C++, is utilized to develop the applications that are uploaded to the microcontroller used in this project. However,

More information

Atmel AVR Timers and Interrupts

Atmel AVR Timers and Interrupts 1 P a g e Atmel AVR Timers and Interrupts Reading The AVR Microcontroller and Embedded Systems using Assembly and C) by Muhammad Ali Mazidi, Sarmad Naimi, and Sepehr Naimi Chapter 10: AVR Interrupt Programming

More information

The MC9S12 Timer Output Compare Function Making an event happen at specific time on the HC12 The MC9S12 Output Compare Function

The MC9S12 Timer Output Compare Function Making an event happen at specific time on the HC12 The MC9S12 Output Compare Function The MC9S12 Timer Output Compare Function Making an event happen at specific time on the HC12 The MC9S12 Output Compare Function o Registers used to enable the output compare function o Using the MC9S12

More information

Capturing the Time of an External Event Input Capture Subsystem

Capturing the Time of an External Event Input Capture Subsystem Capturing the Time of an External Event Input Capture Subsystem One way to determine the time of an external event is to wait for the event to occur, the read the TCNT register: For example, to determine

More information

Introduction to the MC9S12 Hardware Subsystems

Introduction to the MC9S12 Hardware Subsystems Setting and clearing bits in C Using pointers in C o Program to count the number of negative numbers in an area of memory Introduction to the MC9S12 Hardware Subsystems o The MC9S12 timer subsystem Operators

More information

C-CODE EXAMPLE FOR SCP1000-D01 PRESSURE SENSOR

C-CODE EXAMPLE FOR SCP1000-D01 PRESSURE SENSOR C-CODE EXAMPLE FOR SCP1000-D01 PRESSURE SENSOR 1 INTRODUCTION The objective is to set up SPI communication between VTI Technologies' digital pressure sensor component and an MCU of an application device.

More information

Marten van Dijk Department of Electrical & Computer Engineering University of Connecticut

Marten van Dijk Department of Electrical & Computer Engineering University of Connecticut ECE3411 Fall 2016 Wrap Up Review Session Marten van Dijk Department of Electrical & Computer Engineering University of Connecticut Email: marten.van_dijk@uconn.edu Slides are copied from Lecture 7b, ECE3411

More information

Microcontroller basics

Microcontroller basics FYS3240 PC-based instrumentation and microcontrollers Microcontroller basics Spring 2017 Lecture #4 Bekkeng, 30.01.2017 Lab: AVR Studio Microcontrollers can be programmed using Assembly or C language In

More information

Interrupt vectors for the 68HC912B32. The interrupt vectors for the MC9S12DP256 are located in memory from 0xFF80 to 0xFFFF.

Interrupt vectors for the 68HC912B32. The interrupt vectors for the MC9S12DP256 are located in memory from 0xFF80 to 0xFFFF. Interrupts The Real Time Interrupt Interrupt vectors for the 68HC912B32 The interrupt vectors for the MC9S12DP256 are located in memory from 0xFF80 to 0xFFFF. These vectors are programmed into Flash EEPROM

More information

8-bit Microcontroller. Application Note. AVR033: Getting Started with the CodeVisionAVR C Compiler

8-bit Microcontroller. Application Note. AVR033: Getting Started with the CodeVisionAVR C Compiler AVR033: Getting Started with the CodeVisionAVR C Compiler Features Installing and Configuring CodeVisionAVR to Work with the Atmel STK500 Starter Kit and AVR Studio Debugger Creating a New Project Using

More information

DatasheetDirect.com. Visit to get your free datasheets. This datasheet has been downloaded by

DatasheetDirect.com. Visit  to get your free datasheets. This datasheet has been downloaded by DatasheetDirect.com Your dedicated source for free downloadable datasheets. Over one million datasheets Optimized search function Rapid quote option Free unlimited downloads Visit www.datasheetdirect.com

More information

SquareWear Programming Reference 1.0 Oct 10, 2012

SquareWear Programming Reference 1.0 Oct 10, 2012 Content: 1. Overview 2. Basic Data Types 3. Pin Functions 4. main() and initsquarewear() 5. Digital Input/Output 6. Analog Input/PWM Output 7. Timing, Delay, Reset, and Sleep 8. USB Serial Functions 9.

More information

Color 7 click. PID: MIKROE 3062 Weight: 19 g

Color 7 click. PID: MIKROE 3062 Weight: 19 g Color 7 click PID: MIKROE 3062 Weight: 19 g Color 7 click is a very accurate color sensing Click board which features the TCS3472 color light to digital converter with IR filter, from ams. It contains

More information

NEAR EAST UNIVERSI FACULTY OF ECONOMICS AND ADMINISTRATIVE SCIENCES DEPARTMENT OF COMPUTER INFORMATION SYSTEMS

NEAR EAST UNIVERSI FACULTY OF ECONOMICS AND ADMINISTRATIVE SCIENCES DEPARTMENT OF COMPUTER INFORMATION SYSTEMS NEAR EAST UNIVERSI FACULTY OF ECONOMICS AND ADMINISTRATIVE SCIENCES DEPARTMENT OF COMPUTER INFORMATION SYSTEMS 2007/2008 FALL TERM CIS 200 (Graduation Project) Film&Music Center Automation System Submitted

More information

Interrupt Controlled UART

Interrupt Controlled UART AVR306 Design Note: Using the AVR UART in C Features Setup and Use the AVR UART Code Examples for Polled and Interrupt Controlled UART Compact Code C-Code Included for AT90S8515 Description This application

More information

ADC: Analog to Digital Conversion

ADC: Analog to Digital Conversion ECE3411 Fall 2015 Lecture 5a. ADC: Analog to Digital Conversion Marten van Dijk, Syed Kamran Haider Department of Electrical & Computer Engineering University of Connecticut Email: {vandijk, syed.haider}@engr.uconn.edu

More information

APPLICATION NOTE: KONSTANTER LSP32K Interface Protocol

APPLICATION NOTE: KONSTANTER LSP32K Interface Protocol APPLICATION NOTE: KONSTANTER LSP32K Interface Protocol 1 Interface Type At the DB9 connector the LSP32K Power Supply device offers a serial data interface with TTL logic level for remote control and readout

More information

Addressing scheme to address a specific devices on a multi device bus Enable unaddressed devices to automatically ignore all frames

Addressing scheme to address a specific devices on a multi device bus Enable unaddressed devices to automatically ignore all frames 23. USART 23.1 Features Full-duplex operation Asynchronous or synchronous operation Synchronous clock rates up to 1/2 of the device clock frequency Asynchronous clock rates up to 1/8 of the device clock

More information

The MC9S12 Timer Input Capture Function

The MC9S12 Timer Input Capture Function The MC9S12 Timer Input Capture Function o Capturing the time of an external event o The MC9S12 Input Capture Function o Registers used to enable the Input Capture Function o Using the MC9S12 Input Capture

More information

Programming Microcontroller Assembly and C

Programming Microcontroller Assembly and C Programming Microcontroller Assembly and C Course Number CLO : 2 Week : 5-7 : TTH2D3 CLO#2 Student have the knowledge to create basic programming for microcontroller [C3] Understand how to program in Assembly

More information

Timers and Interrupts. Mark Neil - Microprocessor Course

Timers and Interrupts. Mark Neil - Microprocessor Course Timers and Interrupts 1 Example Product: Signal Generator A Signal Generator should be programmable. A user can use the the LCD display and the keyboard to change the: Frequency scale Amplitude scale Offset

More information

The Atmel ATmega328P Microcontroller

The Atmel ATmega328P Microcontroller Ming Hsieh Department of Electrical Engineering EE 459Lx - Embedded Systems Design Laboratory 1 Introduction The Atmel ATmega328P Microcontroller by Allan G. Weber This document is a short introduction

More information

AFRecorder 4800R Serial Port Programming Interface Description For Software Version 9.5 (Last Revision )

AFRecorder 4800R Serial Port Programming Interface Description For Software Version 9.5 (Last Revision ) AFRecorder 4800R Serial Port Programming Interface Description For Software Version 9.5 (Last Revision 8-27-08) Changes from Version 9.2 1. The communication baud rate is raised to 9600. 2. Testing with

More information

Unit 14 Timers and Counters 14.1

Unit 14 Timers and Counters 14.1 Unit 14 Timers and Counters 14.1 14.2 Counter/Timers Overview ATmega328P has two and one counters. Can configure to count at some frequency up to some value (a.k.a. ), generate an and counkng again, if

More information

Design and development of embedded systems for the Internet of Things (IoT) Fabio Angeletti Fabrizio Gattuso

Design and development of embedded systems for the Internet of Things (IoT) Fabio Angeletti Fabrizio Gattuso Design and development of embedded systems for the Internet of Things (IoT) Fabio Angeletti Fabrizio Gattuso Microcontroller It is essentially a small computer on a chip Like any computer, it has memory,

More information

Marten van Dijk, Syed Kamran Haider

Marten van Dijk, Syed Kamran Haider ECE3411 Fall 2015 Wrap Up Review Session Marten van Dijk, Syed Kamran Haider Department of Electrical & Computer Engineering University of Connecticut Email: vandijk, syed.haider@engr.uconn.edu Pulse Width

More information

UART. Embedded RISC Microcontroller Core Peripheral

UART. Embedded RISC Microcontroller Core Peripheral Features New Enhanced Baud Rate Generator Generates Any Required Baud Rate Maximum 6 Mbps (0.35 µm) High Baud Rates at Low Crystal Clock Frequencies 6-, 7-, 8- or 9-bit Data Noise Filtering and Noise Error

More information

Features Utilizes the AVR Enhanced RISC Architecture AVR - High Performance and Low Power RISC Architecture 118 Powerful Instructions - Most Single Cl

Features Utilizes the AVR Enhanced RISC Architecture AVR - High Performance and Low Power RISC Architecture 118 Powerful Instructions - Most Single Cl Features Utilizes the AVR Enhanced RISC Architecture AVR - High Performance and Low Power RISC Architecture 118 Powerful Instructions - Most Single Clock Cycle Execution 8K bytes of In-System Programmable

More information

Accel 5 click. PID: MIKROE 3149 Weight: 24 g

Accel 5 click. PID: MIKROE 3149 Weight: 24 g Accel 5 click PID: MIKROE 3149 Weight: 24 g Accel 5 click features an ultra-low power triaxial accelerometer sensor, labeled as the BMA400. This Click board allows linear motion and gravitational force

More information

ATmega Interrupts. Reading. The AVR Microcontroller and Embedded Systems using Assembly and C) by Muhammad Ali Mazidi, Sarmad Naimi, and Sepehr Naimi

ATmega Interrupts. Reading. The AVR Microcontroller and Embedded Systems using Assembly and C) by Muhammad Ali Mazidi, Sarmad Naimi, and Sepehr Naimi 1 P a g e ATmega Interrupts Reading The AVR Microcontroller and Embedded Systems using Assembly and C) by Muhammad Ali Mazidi, Sarmad Naimi, and Sepehr Naimi Chapter 10: AVR Interrupt Programming in Assembly

More information