SlideShare uma empresa Scribd logo
1 de 3
Baixar para ler offline
'=====================================================
' Sistim kontrol closed loop dengan pengaturan PID
' berbasis mikrokontroller ATmega8535
' input analog <- ADC kanal 0 pin 40
138
' output PWM -> PWM1a pin 19
'=====================================================
'pada saat simulasi instruksi wait tidak berpengaruh
$sim
'ic mikrokontroller yang dipergunakan
$regfile "m8535.dat"
'kristal yang dipasang 12 MHz.
$crystal = 12000000
'setting baud rate
$baud = 9600
'deklarasi varibel
Dim W As Word , Ts As Single
Dim Dv As Single , Av As Single , E As Single
Dim Kp As Single , Ki As Single , Kd As Single
Dim Ekp As Single , Eki As Single , Ekd As Single
Dim Outp As Single , Outi As Single , Outd As Single
Dim Ekiold As Single , Ekdold As Single
Dim Outiold As Single , Outdold As Single
Dim Outpid As Single
Dim Outpwm As Byte
'konfigurasi ADC
Config Adc = Single , Prescaler = Auto
Start Adc
'konfigurasi PWM
Config Timer1 = Pwm , Pwm = 8 , Compare A Pwm = Clear Down , Compare B
Pwm = Clear Down , Prescale = 1
139
'inisialisasi nilai awal
Ekiold = 0
Outiold = 0
Ekdold = 0
Outdold = 0
'setting point, desired value
Dv = 2
'setting paremeter kontrol
Kp = 1
Ki = 1
Kd = 0
'setting time sampling (Ts) 1 detik
Ts = 1
'algoritma kontrol PID
‘==============================================================
Do
W = Getadc(0)
Av = W * 5
Av = Av / 1023
E = Dv - Av
Outp = E * Kp
Eki = E * Ki
Eki = Eki * Ts
Outi = Outiold + Ekiold
Ekd = E * Kd
Outd = Ekd - Ekdold
Outd = Outd / Ts
Outpid = Outp + Outi
Outpid = Outpid + Outd
If Outpid > 255 Then Outpid = 255
If Outpid < 0 Then Outpid = 0
140
Outpwm = Int(outpid)
Pwm1a = Outpwm
'mengirim data ke komputer melalui RS232
Print Dv ; Chr(9) ; Av ; Chr(9) ; E ; Chr(9) ; Outpwm
Ekiold = Eki
Outiold = Outi
Ekdold = Ekd
Outdold = Outd
Wait Ts
Loop
End

Mais conteúdo relacionado

Mais procurados

Programmation pic 16F877
Programmation pic 16F877Programmation pic 16F877
Programmation pic 16F877Mouna Souissi
 
Compare mysql5.1.50 mysql5.5.8
Compare mysql5.1.50 mysql5.5.8Compare mysql5.1.50 mysql5.5.8
Compare mysql5.1.50 mysql5.5.8Philip Zhong
 
Mysql handle socket
Mysql handle socketMysql handle socket
Mysql handle socketPhilip Zhong
 
Mysql5.1 character set testing
Mysql5.1 character set testingMysql5.1 character set testing
Mysql5.1 character set testingPhilip Zhong
 
The Ring programming language version 1.6 book - Part 55 of 189
The Ring programming language version 1.6 book - Part 55 of 189The Ring programming language version 1.6 book - Part 55 of 189
The Ring programming language version 1.6 book - Part 55 of 189Mahmoud Samir Fayed
 

Mais procurados (8)

Programmation pic 16F877
Programmation pic 16F877Programmation pic 16F877
Programmation pic 16F877
 
Batch processing Demo
Batch processing DemoBatch processing Demo
Batch processing Demo
 
Compare mysql5.1.50 mysql5.5.8
Compare mysql5.1.50 mysql5.5.8Compare mysql5.1.50 mysql5.5.8
Compare mysql5.1.50 mysql5.5.8
 
Mysql handle socket
Mysql handle socketMysql handle socket
Mysql handle socket
 
Ee
EeEe
Ee
 
Mysql5.1 character set testing
Mysql5.1 character set testingMysql5.1 character set testing
Mysql5.1 character set testing
 
GenServer in action
GenServer in actionGenServer in action
GenServer in action
 
The Ring programming language version 1.6 book - Part 55 of 189
The Ring programming language version 1.6 book - Part 55 of 189The Ring programming language version 1.6 book - Part 55 of 189
The Ring programming language version 1.6 book - Part 55 of 189
 

Semelhante a Sistem kontrol closed loop dengan pengaturan PID berbasis mikrokontroller ATmega8535

Semelhante a Sistem kontrol closed loop dengan pengaturan PID berbasis mikrokontroller ATmega8535 (11)

FPGA Tutorial - LCD Interface
FPGA Tutorial - LCD InterfaceFPGA Tutorial - LCD Interface
FPGA Tutorial - LCD Interface
 
VLSI Sequential Circuits II
VLSI Sequential Circuits IIVLSI Sequential Circuits II
VLSI Sequential Circuits II
 
Module nco rtl
Module nco rtlModule nco rtl
Module nco rtl
 
To designing counters using verilog code
To designing counters using verilog codeTo designing counters using verilog code
To designing counters using verilog code
 
c++ program for Canteen management
c++ program for Canteen managementc++ program for Canteen management
c++ program for Canteen management
 
Direct analog
Direct analogDirect analog
Direct analog
 
Verilog code
Verilog codeVerilog code
Verilog code
 
Cs262 2006 lecture6
Cs262 2006 lecture6Cs262 2006 lecture6
Cs262 2006 lecture6
 
R tist
R tistR tist
R tist
 
PWM based motor speed control using LPC 1768
PWM based motor speed control using LPC 1768PWM based motor speed control using LPC 1768
PWM based motor speed control using LPC 1768
 
Digital System Design-Synchronous Sequential Circuits
Digital System Design-Synchronous Sequential CircuitsDigital System Design-Synchronous Sequential Circuits
Digital System Design-Synchronous Sequential Circuits
 

Mais de Weldan Kusuf

Bahan bacaan 3 _2 meka
Bahan bacaan 3 _2 mekaBahan bacaan 3 _2 meka
Bahan bacaan 3 _2 mekaWeldan Kusuf
 
Listing program 4 1
Listing program 4 1Listing program 4 1
Listing program 4 1Weldan Kusuf
 
Listing program 4-1
Listing program 4-1Listing program 4-1
Listing program 4-1Weldan Kusuf
 
Listing program 4 1
Listing program 4 1Listing program 4 1
Listing program 4 1Weldan Kusuf
 
Penggunaan tipe data dan variabel
Penggunaan tipe data dan variabelPenggunaan tipe data dan variabel
Penggunaan tipe data dan variabelWeldan Kusuf
 
Aplikasi komunikasi serial mikrokontroller
Aplikasi komunikasi serial mikrokontrollerAplikasi komunikasi serial mikrokontroller
Aplikasi komunikasi serial mikrokontrollerWeldan Kusuf
 
Script serial bab 4
Script serial bab 4Script serial bab 4
Script serial bab 4Weldan Kusuf
 

Mais de Weldan Kusuf (13)

Bahan bacaan 3 _2 meka
Bahan bacaan 3 _2 mekaBahan bacaan 3 _2 meka
Bahan bacaan 3 _2 meka
 
Bahan bacaan 3 3
Bahan bacaan 3 3Bahan bacaan 3 3
Bahan bacaan 3 3
 
Bahan bacaan 3.2
Bahan bacaan 3.2Bahan bacaan 3.2
Bahan bacaan 3.2
 
Bahan bacaan 2 2
Bahan bacaan 2 2Bahan bacaan 2 2
Bahan bacaan 2 2
 
Bahan bacaan 3 2
Bahan bacaan 3 2Bahan bacaan 3 2
Bahan bacaan 3 2
 
Listing program 4 1
Listing program 4 1Listing program 4 1
Listing program 4 1
 
Listing program 4-1
Listing program 4-1Listing program 4-1
Listing program 4-1
 
Listing program 4 1
Listing program 4 1Listing program 4 1
Listing program 4 1
 
4 1
4 14 1
4 1
 
4 1a
4 1a4 1a
4 1a
 
Penggunaan tipe data dan variabel
Penggunaan tipe data dan variabelPenggunaan tipe data dan variabel
Penggunaan tipe data dan variabel
 
Aplikasi komunikasi serial mikrokontroller
Aplikasi komunikasi serial mikrokontrollerAplikasi komunikasi serial mikrokontroller
Aplikasi komunikasi serial mikrokontroller
 
Script serial bab 4
Script serial bab 4Script serial bab 4
Script serial bab 4
 

Último

Industrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.pptIndustrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.pptNarmatha D
 
Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating SystemRashmi Bhat
 
Vishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsVishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsSachinPawar510423
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
Mine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxMine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxRomil Mishra
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Solving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.pptSolving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.pptJasonTagapanGulla
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionMebane Rash
 
Indian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptIndian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptMadan Karki
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substationstephanwindworld
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catcherssdickerson1
 
Class 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm SystemClass 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm Systemirfanmechengr
 
Energy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxEnergy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxsiddharthjain2303
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating SystemRashmi Bhat
 
System Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingSystem Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingBootNeck1
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 

Último (20)

Industrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.pptIndustrial Safety Unit-IV workplace health and safety.ppt
Industrial Safety Unit-IV workplace health and safety.ppt
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating System
 
Vishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsVishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documents
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
Mine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxMine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptx
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
Solving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.pptSolving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.ppt
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of Action
 
Indian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptIndian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.ppt
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substation
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
 
Class 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm SystemClass 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm System
 
Energy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxEnergy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptx
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating System
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
System Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingSystem Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event Scheduling
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 

Sistem kontrol closed loop dengan pengaturan PID berbasis mikrokontroller ATmega8535

  • 1. '===================================================== ' Sistim kontrol closed loop dengan pengaturan PID ' berbasis mikrokontroller ATmega8535 ' input analog <- ADC kanal 0 pin 40 138 ' output PWM -> PWM1a pin 19 '===================================================== 'pada saat simulasi instruksi wait tidak berpengaruh $sim 'ic mikrokontroller yang dipergunakan $regfile "m8535.dat" 'kristal yang dipasang 12 MHz. $crystal = 12000000 'setting baud rate $baud = 9600 'deklarasi varibel Dim W As Word , Ts As Single Dim Dv As Single , Av As Single , E As Single Dim Kp As Single , Ki As Single , Kd As Single Dim Ekp As Single , Eki As Single , Ekd As Single Dim Outp As Single , Outi As Single , Outd As Single Dim Ekiold As Single , Ekdold As Single Dim Outiold As Single , Outdold As Single Dim Outpid As Single Dim Outpwm As Byte 'konfigurasi ADC Config Adc = Single , Prescaler = Auto Start Adc
  • 2. 'konfigurasi PWM Config Timer1 = Pwm , Pwm = 8 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down , Prescale = 1 139 'inisialisasi nilai awal Ekiold = 0 Outiold = 0 Ekdold = 0 Outdold = 0 'setting point, desired value Dv = 2 'setting paremeter kontrol Kp = 1 Ki = 1 Kd = 0 'setting time sampling (Ts) 1 detik Ts = 1 'algoritma kontrol PID ‘============================================================== Do W = Getadc(0) Av = W * 5 Av = Av / 1023 E = Dv - Av Outp = E * Kp Eki = E * Ki Eki = Eki * Ts Outi = Outiold + Ekiold Ekd = E * Kd
  • 3. Outd = Ekd - Ekdold Outd = Outd / Ts Outpid = Outp + Outi Outpid = Outpid + Outd If Outpid > 255 Then Outpid = 255 If Outpid < 0 Then Outpid = 0 140 Outpwm = Int(outpid) Pwm1a = Outpwm 'mengirim data ke komputer melalui RS232 Print Dv ; Chr(9) ; Av ; Chr(9) ; E ; Chr(9) ; Outpwm Ekiold = Eki Outiold = Outi Ekdold = Ekd Outdold = Outd Wait Ts Loop End