0% found this document useful (0 votes)
3 views14 pages

Trường Đại Học Công Nghệ Tp. Hồ Chí Minh: Ngành: Lớp

The document is a practical report from the Ho Chi Minh University of Technology focusing on automotive engineering. It includes multiple code snippets for controlling LED displays and reading temperature data using ADC in embedded systems. The report outlines various configurations and conditions for displaying temperature readings and controlling outputs based on temperature thresholds.

Uploaded by

phamtuan23000
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views14 pages

Trường Đại Học Công Nghệ Tp. Hồ Chí Minh: Ngành: Lớp

The document is a practical report from the Ho Chi Minh University of Technology focusing on automotive engineering. It includes multiple code snippets for controlling LED displays and reading temperature data using ADC in embedded systems. The report outlines various configurations and conditions for displaying temperature readings and controlling outputs based on temperature thresholds.

Uploaded by

phamtuan23000
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

BỘ GIÁO DỤC VÀ ĐÀO TẠO

TRƯỜNG ĐẠI HỌC CÔNG NGHỆ TP. HỒ CHÍ MINH

BÁO CÁO THỰC HÀNH VI ĐIỀU KHIỂN

Ngành: CÔNG NGHỆ KỸ THUẬT Ô TÔ

Lớp: 22DOTB4

Giảng viên hướng dẫn:Nguyễn Trọng Huân

Tên: Phạm Võ Bảo Phi MSSV: 2188900731 LỚP:


22DOTB4

Tên: MSSV: LỚP: 22DOTB4

Tp.HCM, ngày 29 tháng 12 năm 2024


BÀI 3.1

#include <main CÁI NÀY NÈ.h>

#fuses NOWDT, HS, NOPUT, NOPROTECT, NODEBUG, NOBROWNOUT, NOLVP

#use delay(clock=8M)

int8 LED7S[10] = {0x03, 0x9f,0x25,0x0d,0x99,0x49,0x41,0x1f,0x01,0x09};

int8 LED7S1[10] = {0X02, 0X9e,0X24,0X0c,0X98,0X48,0X40,0X1e,0x00,0x08};

int8 data_led[4] = {0xFF,0XFF,0XFF,0XFF};

int8 control_led[4] = {0xF7,0XFB,0XFD,0XFE};

int8 tram,chuc,dvi;

int16 temp;

float volt;

#INT_TIMER0

void qled()

for (int8 i=0;i<4;i++)

output_d(0xFF);

output_b(data_led[i]);

output_d(control_led[i]);

delay_ms(2);

void main (void)

enable_interrupts(GLOBAL);
enable_interrupts(INT_TIMER0);

setup_timer_0(RTCC_DIV_128|RTCC_INTERNAL);

// cau hinh ADC

setup_adc(ADC_CLOCK_INTERNAL);

setup_adc_ports(AN0);

set_adc_channel(0);

while(1)

temp = read_adc();

volt = (float) (temp)*5/10.23;

temp = (int16)volt;

chuc = temp/10;

dvi = temp%10;

data_led[0] = LED7S[chuc];

data_led[1] = LED7S[dvi];

data_led[2] = 0x39;

data_led[3] = 0x63;

}
BÀI 3.3

#fuses NOWDT, HS, NOPUT, NOPROTECT, NODEBUG, NOBROWNOUT, NOLVP

#use delay(clock=8M)

#define D9 PIN_C2

#define D10 PIN_C3

int8 LED7S[10] = {0x03, 0x9f,0x25,0x0d,0x99,0x49,0x41,0x1f,0x01,0x09};

int8 LED7S1[10] = {0X02, 0X9e,0X24,0X0c,0X98,0X48,0X40,0X1e,0x00,0x08};

int8 data_led[4] = {0xFF,0XFF,0XFF,0XFF};

int8 control_led[4] = {0xF7,0XFB,0XFD,0XFE};

int8 tram,chuc,dvi;

int16 temp;

float volt;

#INT_TIMER0
void qled()

for (int8 i=0;i<4;i++)

output_d(0xFF);

output_b(data_led[i]);

output_d(control_led[i]);

delay_ms(2);

void main (void)

enable_interrupts(GLOBAL);

enable_interrupts(INT_TIMER0);

setup_timer_0(RTCC_DIV_128|RTCC_INTERNAL);

// cau hinh ADC

setup_adc(ADC_CLOCK_INTERNAL);

setup_adc_ports(AN0);

set_adc_channel(0);

while(1)

temp = read_adc();

volt = (float) (temp)*5/10.23;

temp = (int16)volt;

chuc = temp/10;
dvi = temp%10;

data_led[0] = LED7S[chuc];

data_led[1] = LED7S[dvi];

data_led[2] = 0x39;

data_led[3] = 0x63;

if (temp<=20)

output_d(0xFF);

output_b(0x03);

output_low(D9);

output_low(D10);

if (temp>20 && temp<30)

output_d(0xFF);

output_b(0x03);

output_high(D9);

output_low(D10);

if (temp>30 && temp<35)

output_d(0xFF);
output_b(0x03);

output_low(D9);

output_high(D10);

if (temp>35)

output_d(0xFF);

output_b(0x03);

output_low(D9);

output_low(D10);

delay_ms(100);

output_toggle(D9);

output_toggle(D10);

delay_ms(100);

}
Baif 3.4

#include <main344.h>

#fuses NOWDT, HS, NOPUT, NOPROTECT, NODEBUG, NOBROWNOUT, NOLVP

#use delay (clock=8M)

#include <lcd.c>

int8 tram,chuc,donvi;

int16 temp;

int8 temp1,temp2;

float volt;

#INT_TIMER0

void qled()

{
setup_ADC(AN0);

SETUP_ADC(ADC_CLOCK_INTERNAL);

SET_ADC_CHANNEL(0);

void main (void)

lcd_init();

enable_interrupts(GLOBAL);

enable_interrupts(INT_TIMER0);

setup_timer_0(RTCC_DIV_128|RTCC_INTERNAL);

//cau hinh ADC

setup_adc(ADC_CLOCK_INTERNAL);

setup_adc_ports(AN0);

set_adc_channel(0);

lcd_gotoxy(1,1);

printf(lcd_putc,"Nhiet Do");

delay_ms(3);

while (TRUE)

temp = read_adc();

delay_ms(3);

volt = (float)(temp)*5/10.23;

temp=(int16)volt;

temp1=temp%100;
LCD_gotoxy(1,2);

printf (Lcd_putc,"%02U",temp1);

lcd_gotoxy(4,2);

printf(lcd_putc,"do C");

Baif 3.5

#include <3.5.h>

#fuses NOWDT, HS, NOPUT, NOPROTECT, NODEBUG, NOBROWNOUT, NOLVP

#use delay (clock=8M)

#define D9 PIN_C2
#define D10 PIN_C3

#include <lcd.c>

int8 tram,chuc,donvi;

int16 temp;

int8 temp1,temp2;

float volt;

#INT_TIMER0

void qled()

setup_ADC(AN0);

SETUP_ADC(ADC_CLOCK_INTERNAL);

SET_ADC_CHANNEL(0);

void main (void)

lcd_init();

enable_interrupts(GLOBAL);

enable_interrupts(INT_TIMER0);

setup_timer_0(RTCC_DIV_128|RTCC_INTERNAL);

//cau hinh ADC

setup_adc(ADC_CLOCK_INTERNAL);

setup_adc_ports(AN0);

set_adc_channel(0);
lcd_gotoxy(1,1);

printf(lcd_putc,"Nhiet Do");

delay_ms(3);

while (TRUE)

temp = read_adc();

delay_ms(3);

volt = (float)(temp)*5/10.23;

temp=(int16)volt;

temp1=temp%100;

delay_ms(3);

volt = (float)(temp)*5/10.23*100;

temp=(int16)volt;

temp2=temp%100;

LCD_gotoxy(1,2);

printf (Lcd_putc,"%02U.%02U",temp1,temp2);

lcd_gotoxy(6,4);

printf(lcd_putc,"do C");

if (temp<=20)

output_d(0xFF);
output_b(0x03);

output_low(D9);

output_low(D10);

if (temp>20 && temp<30)

output_d(0xFF);

output_b(0x03);

output_high(D9);

output_low(D10);

if (temp>30 && temp<35)

output_d(0xFF);

output_b(0x03);

output_low(D9);

output_high(D10);

if (temp>35)

output_d(0xFF);

output_b(0x03);
output_low(D9);

output_low(D10);

delay_ms(100);

output_toggle(D9);

output_toggle(D10);

delay_ms(2);

You might also like