Hola semua.....
Selamat ku ucapkan...
Mencari-cari di dalam internet... Susah benar nak jumpa coding pasal Automatic traffic light using dragon 12 board. So, lepas relax post ni, harap-harap tak susah cari lagi la ye.....
Seperti biasa, nak akhir-akhir sem ni. Ada saja project kena buat. Project terbaru ku iaitu Automatic traffic light. Projek kedua ku selepas FYP yang melibatkan coding. Tetapi coding ni lain sikit sebab coding ni menggunakan High level language.
Dalam erti kata lain coding yang susah manusia nak fahamkan, coding ni berbeza dengan Low level language. Low level language menggunakan coding seperti bahasa English.
Contoh nya.
Untuk membuat coding loop dalam Low level language. Salah satu command yang digunakan ialah dengan menggunakan command while, do dan banyak lagi lah.
Berbeza dengan High level Language. Salah satu command yang digunakan untuk membuat loop ialah dengan menggunakan command BRA, BPL, BRCLR dan sebagainya.
Cuba kita tengok dekat low level language, kita fahamkan apa maksud while. Kalau kita tengok dekat High level language, kita faham tak apa maksud BPL. Inilah bezanya....
Ok2 kita start.
Automatic traffic light.
Must have:
1. Dragon 12 board
2. MiniIDE software
Description:
This project is about designing an automaic traffic light. When the traffic light does not detect a vehicle (using infrared transceiver), the traffic light (RGB LED) will continuously display RED.When a vehicle is detected, the traffic light will blink RED 3 times. before turning to GREEN. By the time it is GREEN, the 7segment DSP1 and DSP2 will display '10' and counting down each second. By the time the counting reaches 5, the traffic light turns form GREEN to YELLOW. The YELLOW will blinks each second until the count reaches 0 and turns RED.
Devices used in dragon 12 boards
1. RGB LED
2. Infrared transceiver
3. 7 segment LED
Dragon 12 board
MiniIDE
Coding use:
#include "c:\miniide\hcs12.inc"
org $2000
movb #$FF, DDRP
bset PTP, $20
bset DDRB, 000011
bset DDRT, 010000
bclr DDRT, 001000
bclr PTT, 010000
loop brclr PTT, 001000,yes ;Detect car, go to yes. If not execute
; istruction below
bset PTP, $20 ;Red light ON
bra loop ;Loop
yes bclr PTP, $20 ;Red light OFF
ldy #500
jsr delayby1ms ;delay 0.5 second
bset PTP, $20 ;Red light ON
ldy #500
jsr delayby1ms ;delay 0.5 second
bclr PTP, $20 ;Red light OFF
ldy #500
jsr delayby1ms ;delay 0.5 second
bset PTP, $20 ;Red light ON
ldy #500
jsr delayby1ms ;delay 0.5 second
bclr PTP, $20 ;Red light OFF
ldy #500
jsr delayby1ms ;delay 0.5 second
bset PTP, $20 ;Red light ON
ldy #500
jsr delayby1ms ;delay 0.5 second
bclr PTP, $20 ;Red light OFF
bset PTP, $40 ;Green light ON
ldaa #1
movb #$FF, DDRB ;Configure Port B pins as output
movb #$F7, DDRP ;Configure Port P pins (PP7,PP6,PP5,
;PP4,PP2,PP1 and PP0) as output
ldx #disp1
seg movb 1,x+,ptb
movb 1,x+,ptp
ldy #10
jsr delayby100ms
cpx #disp1+8
bne seg
ldx #disp2
seg2 movb 1, x+,ptb
movb 1, x+,ptp
ldy #500
jsr delayby1ms
cpx #disp2+20
bne seg2
lbra loop ;End program. Using long loop.
; Go to the loop label
disp1 dc.b $67, $47
dc.b $7F, $47
dc.b $07, $47
dc.b $7D, $47
bne seg2
disp2 dc.b $6D,$67
dc.b $6D,$07
dc.b $66,$67
dc.b $66,$07
dc.b $4F,$67
dc.b $4F,$07
dc.b $5B,$67
dc.b $5B,$07
dc.b $06,$67
dc.b $3F,$27
#include "c:\miniide\delay.asm"
end
Untuk melihat resultnya boleh di klik di sini
Sekian dari ku. Tamat sudah......
Pai pai...
Cin cau...
Knpe ada error coding tu ? Mohon share file .asm
ReplyDeleteapa yang error nya???? lampu tak menyala seperti yang di mahukan ke????
ReplyDeletehai maaf ganggu. saya nak tanya. yang infrared tu apa function dia dalam coding ni? dan ada pakai tak? dan kalau saya nak tambah coding utk switch, agak2 boleh tak? blh tlg ajar? tengs :)
ReplyDeleteYang infrared tu brtindak sebagai sensor. Selagi tak da benda lalu kat sensor tu lampu akn sentiasa red. Jd, infrared ad pakai dlm mini project di atas.
ReplyDeleteEeerrmm klu bab nk tambah coding utk switch tu maaf la, sbb dah lama sgt tinggal bnda di atas, dah samar2 dah coding utk dragon 12 ni..
Ssooorryy... but I think u just need to enable the switch then use the if coding.
kiranya coding utk sensor tu yang ni ke? loop brclr PTT, 001000,yes
ReplyDeleteyup betul...
ReplyDeleteyg #include "c:\miniide\hcs12.inc" tuu file ape? knape bnyk sgt error? harap membantu.
ReplyDeletetu file library tu... mungkin error banyak sebab guna dragon board jenis lain...
ReplyDeleteKenapa lampu Led & seven segment sy tak menyala padahal tak ada error
ReplyDeletesy nak tnya knp lambat sangat ye utk dia tukar kpda green light
ReplyDeletemaaf di atas kelewatan membalas komen di atas. Try check dekat command untuk delay.... mungkin sebab itu.
ReplyDeletelampu led dan seven segment tak menyala.. ce try balik tengok dekat setting untuk dragon board... munkin salah setting...
ReplyDeleteHello. I would like to do this project on the Dragon12-Light. Is it possible? It tried your code, but it is not working.
ReplyDeletepossible because long time ago i use this code to completed my project. maybe u has to change a little bit code.
ReplyDeleteboleh sy minta email ? utk tanya lebih lanjut.
ReplyDeleteMacam mana nak set keypad as input(user tekan data number) & 7 segment as output(display data yang user tekan tadi). Kalau boleh minta email, later nak tanya pasal programming.
ReplyDelete:)
ReplyDeleteIs there an updated code for this program? It will not run on Dragon-12 board. A blue light turns on and that is it
ReplyDeleteEvery dragon 12 board have their own command for the light. U have to know the type of dragon 12 board. The code only can be use as reference. U have to change a little bit code to make it work for other dragon 12 board.
ReplyDeleteapa function LED menyala kat project ni
ReplyDelete