Skip to content
View in the app

A better way to browse. Learn more.

Komuniti @PuTeRA

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Sape Tuhu Pasal Pic

Featured Replies

haloo semua,
ade tak sape tau program PIC sbb aku berminat sangat nak blaja bnde ni, ade sape bleh tolong aku tak cara wat aturcara prog cara basic?
  • 3 months later...
lama gak aku xcontribute utk forum putera.
hmm, ko nk tau pasal pe pic ni?
Ko bleh program PIC gune beberapa programming language, antaranya C,Basic dan Assembly..yang penting ada compilernya..biasanya compiler ni bleh download secara percuma di internet.

Kalo ko ada basic pasal C,Basic or Assembly..mudah je..yang penting ko paham operation i/o (input/output)..PIC cuma tahu signal high=1,low=0
pendek kata basic digital..actually basic electrical network pn kena ada jugak..kalo tak susah nak paham sket..

aku bagi contoh mudah
Language : C Code
[code]
main(){
trisa = 0xFF // set semua portA sebagai input (0X = menunjukkan value hex : 0XFF = b11111111)
trisb = 0x00 // set semua portB sebagai output

while 1{
portb = b00001111 //set portb.0 hingga portb.3 sebagai high (b=menunjukkan binary : bit0-bit7).

}

}
}
[/code]

code di atas setkan portb.0 hingga portb.3 sebagai high..maknanya kalo kite sambung LED kat portb.0 hingga portb.3, LED tu akan menyala..kat port yang selebihnya akan off..

kalo ko nak tau lebih lanjut..sila layari microchip.com atau cytron.com.my
Saya pakai PIC18F2550 tuk sume projek yang saya buat kat www.hitkr.com. Kan ape, dapat durian runtuh sbb satu ari tu Farnell tersilap letak harga. :lol: Sempat rembat banyak gak sebelum dia orang sedar. PIC18F2550 ni kire spec die tinggi gak, speed 40MHz siap ngan USB lagi. Apa pun kalu nak tengok projek2 yang dah saye buat, sila lawati www.hitkr.com.
  • 1 month later...
  • Author
neology bleh tolong ajar aku lg x, aku x tau pape nak program pic ni, aku nak blajar pasal i-o die je n pasal delay timer, ko beh tunjuk ajar aku x
[quote name='rahmat700' date='01 August 2010 - 10:37 PM' timestamp='1280673467' post='1043633']
neology bleh tolong ajar aku lg x, aku x tau pape nak program pic ni, aku nak blajar pasal i-o die je n pasal delay timer, ko beh tunjuk ajar aku x
[/quote]

kalo delay, xsilap aku dlm c compiler ada dlm header file dia..

[code]
#include <pic.h>

__delay_us(1000) // utk delay 1000 microseconds
__delay_ms(1000) // utk delay 1000 miliseconds
[/code]
atau ko bleh buat function delay sendiri dgn gune kaedah looping

[code]
void delay(int count){
int i;

for(i=0;i<1023405*count;i++){
//do nothing
//value 102345 tu kena buat calculation sket..
//depend pada freq yg diguna
}

return;
}
[/code]
  • Author
saye x paham lg ar pasal delay ni, tunjukkan aku plzz, ade tak buku rujukan utuk program pic ni,
delay ni adalah mcm ko buang masa melakukan sesuatu yang tak berguna..

contoh macam loop yg aku bagi..

loop tu akan run sebanyak 102345 kali dengan count yang diset tanpa membuat apa2..setiap microcontroller, dia akan ada time execution utk setiap instruction dalam processor nya..so, semasa looping tu, processor xbuat ape2..dan ini yang dikatakan delay tu..

maknanya processor dalam mode 'tidur' atau 'tidak bekerja' selama beberapa detik, bergantung kepada berapa banyak loop yang dibuat..lagi bnyk loop, lagi lama la dia tido..

perumpamaannya mudah..

katakan utk execute satu code/instruction mengambil masa 2us..
kemudian code/instruction tu diulang sebanyak 1000 kali...

so , 2us x 1000 = 2ms

jadi, processor hanya mengulang instruction loop sebanyak 1000 kali dan tidak membuat operasi lain selama 2ms..maka, itu la yang dikatakan delay 2ms..kalo 1000 tu dikali dengan pekali 5, maka sudah menjadi 10ms..
  • Author
list p=16F84A ; list directive to define processor
#include <p16F84A.inc> ; processor specific variable definitions

__CONFIG 0X3FF2

; '__CONFIG' directive is used to embed configuration data within .asm file.
; The lables following the directive are located in the respective .inc file.
; See respective data sheet for additional information on configuration word.




;***************** VARIABLE DEFINITIONS************************

D1 EQU 0X20 ;FOR DELAY
D2 EQU 0X21 ;FOR DELAY
D3 EQU 0X22 ;FOR DELAY



;**********************************************************************
ORG 0x000 ; processor reset vector
goto main ; go to beginning of program

main

; initialize of your PIC, setting the general I/O in TRIS

BSF STATUS,5 ;SWITCH TO BANK 1
CLRF TRISB ;SET PORTB AS OUTPUT
BSF TRISA,2 ;SET RA2 AS INPUT
BSF TRISA,3 ;SET RA3 AS INPUT
BSF TRISA,4 ;SET RA4 AS INPUT
BCF STATUS,5 ;BANK 0

MOVLW B'11111111'
MOVWF PORTB ;SET ALL 8 PIN IN PORTB TO HIGH(1)

;the main program begin here

START
BTFSS PORTA,2 ;check signal at pushbutton1, if press then goto following line, else skip the following line
CALL RED ;button1 pressed, program execute the operation in subroutine RED
BTFSS PORTA,3 ;check signal at pushbutton2, if press then goto following line, else skip the following line
CALL GREEN ;button2 pressed, program execute the operation in subroutine GREEN
BTFSS PORTA,4 ;check signal at pushbutton3, if press then goto following line, else skip the following line
CALL YELLOW ;button3 pressed, program execute the operation in subroutine YELLOW
GOTO START ;no any button being pressed, program keep looping to check the pushbuttons' signal

RED
BSF PORTB,4 ;ON YELLOW LED
BSF PORTB,5 ;ON GREEN LED
BSF PORTB,6 ;ON RED LED
BCF PORTB,6 ;OFF RED LED
RETURN

GREEN
BSF PORTB,4 ;ON YELLOW LED
BSF PORTB,5 ;ON GREEN LED
BSF PORTB,6 ;ON RED LED
BCF PORTB,5 ;OFF GREEN LED
RETURN

YELLOW
BSF PORTB,4 ;ON YELLOW LED
BSF PORTB,5 ;ON GREEN LED
BSF PORTB,6 ;ON RED LED
BCF PORTB,4 ;OFF YELLOW LED
RETURN


;*******************************DELAY SUBROUTINE*****************************

DELAY MOVLW D'200' ;PAUSE FOR ABOUT 500mS (u can change the 200, 3, 1 value to obtain different delay timing)
MOVWF D3
MOVLW D'3'
MOVWF D2
MOVLW D'1'
MOVWF D1
DECFSZ D1
GOTO $-1
DECFSZ D2
GOTO $-5
DECFSZ D3
GOTO $-9
RETURN


END ; directive 'end of program'



kalau mcm yg saye bg ni mcm mane plak, command utk delay die asal lain?
config tu nak dapat dr mane kod die
ni assembly language..memang code dia lain..tapi concept dia sama je..

psal value __CONFIG tu..depend pada manufacturer microcontroller tu..Setting ni disediakan oleh manufacturer utk user define mcm mana microcontroller tu digunakan..apa function/feature yg nak digunakan..ni bleh dirujuk pada datasheet microcontroller yg ko pkai..
  • Author
ohh, jadi kene refer data sheet die la, assembly language tu memang dah ditetapkan oleh pic ke?
  • 6 months later...
[quote name='rahmat700' timestamp='1280851460' post='1043875']
ohh, jadi kene refer data sheet die la, assembly language tu memang dah ditetapkan oleh pic ke?
[/quote]

tgk kat dlm datasheet dia..bhagian instruction set..sng je nk faham.. :D :D

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.