Şimdi Ara

en basit şekilde 18f2550 ile usb kontrolü

Daha Fazla
Bu Konudaki Kullanıcılar: Daha Az
2 Misafir - 2 Masaüstü
5 sn
4
Cevap
1
Favori
2.059
Tıklama
Daha Fazla
İstatistik
  • Konu İstatistikleri Yükleniyor
0 oy
Öne Çıkar
Sayfa: 1
Giriş
Mesaj
  • Device = 18F2550 
    XTAL = 48
    USB_DESCRIPTOR = "USBProjectDESC.inc"
    Symbol USBBufferSizeMax = 8
    Symbol USBBufferSizeTX = 8
    Symbol USBBufferSizeRX = 8
    Dim USBBuffer[USBBufferSizeMax] As Byte
    Dim PP0 As Byte SYSTEM ' USBPOLL status return
    Symbol CARRY_FLAG = STATUS.0 ' high if microcontroller does not have control over the buffer
    Symbol ATTACHED_STATE = 6 ' is USB attached

    TRISB = %00000000
    GoSub AttachToUSB
    ProgramLoop:

    USBBuffer[2] = PORTA
    USBOut 1, USBBuffer, USBBufferSizeTX

    USBIn 1, USBBuffer, USBBufferSizeRX, ProgramLoop
    PORTB = USBBuffer[3]

    GoTo ProgramLoop

    DoUSBIn:
    USBIn 1, USBBuffer, USBBufferSizeRX, DoUSBIn
    Return

    DoUSBOut:
    USBOut 1, USBBuffer, USBBufferSizeTX, DoUSBOut
    Return

    AttachToUSB:
    Repeat
    USBPoll
    Until PP0 = ATTACHED_STATE
    Return




    ' vendor and product IDs 
    Private Const VendorID = 6114
    Private Const ProductID = 2010

    ' read and write buffers
    Private Const BufferInSize = 8
    Private Const BufferOutSize = 8
    Dim BufferIn(0 To BufferInSize) As Byte
    Dim BufferOut(0 To BufferOutSize) As Byte

    Private Sub Command1_Click()

    BufferOut(4) = Val(Text1.Text)
    hidWriteEx VendorID, ProductID, BufferOut(0)
    End Sub


    Private Sub Form_Load()
    ' do not remove!
    ConnectToHID (Me.hwnd)
    End Sub

    Private Sub Form_Unload(Cancel As Integer)
    DisconnectFromHID
    End Sub

    Public Sub OnPlugged(ByVal pHandle As Long)
    If hidGetVendorID(pHandle) = VendorID And hidGetProductID(pHandle) = ProductID Then
    ' ** YOUR CODE HERE **
    End If
    End Sub

    Public Sub OnUnplugged(ByVal pHandle As Long)
    If hidGetVendorID(pHandle) = VendorID And hidGetProductID(pHandle) = ProductID Then
    ' ** YOUR CODE HERE **
    End If
    End Sub

    Public Sub OnChanged()
    Dim DeviceHandle As Long

    DeviceHandle = hidGetHandle(VendorID, ProductID)
    hidSetReadNotify DeviceHandle, True
    End Sub

    Public Sub OnRead(ByVal pHandle As Long)

    ' read the data (don't forget, pass the whole array)...
    If hidRead(pHandle, BufferIn(0)) Then

    End If
    End Sub


    Public Sub WriteSomeData()
    BufferOut(0) = 0 ' first by is always the report ID
    BufferOut(1) = 10 ' first data item, etc etc

    ' write the data (don't forget, pass the whole array)...
    hidWriteEx VendorID, ProductID, BufferOut(0)
    End Sub

    Private Sub Text1_Change()
    If Val(Text1.Text) > 255 Then Text1.Text = ""
    End Sub

    Private Sub Text1_KeyPress(KeyAscii As Integer)
    If KeyAscii = 8 Then Exit Sub
    If IsNumeric(Chr(KeyAscii)) = False Then KeyAscii = 0
    End Sub


    1. adım : proton basic ve içersine easyhid kuruyoruz.
    ardından easyhid simgesinie tıklıyoruz.
    [simage]
     en basit şekilde 18f2550 ile usb kontrolü
    [/simage]

    [simage]
     en basit şekilde 18f2550 ile usb kontrolü
    [/simage]

    [simage]
     en basit şekilde 18f2550 ile usb kontrolü
    [/simage]
    polling zamanları usb nin takılı algılanmasını saglayacak kodların gönderilecegi zaman aralıklarıdır .
    pos power cekilecek max akım degerleri.(500ma üzeri zarar verebilir)
    buffer in / out = gönderilecek veya alınacak data ların byte olarak uzunlugudur .bir defa da max 64 byte veri transferi yapılabiliyor.
    [simage]
     en basit şekilde 18f2550 ile usb kontrolü
    [/simage]
    project name = kayıt klasörünün proje ismi , location proje nin kayıt klasörünün yeri.
    complier = kullanılacak derleyici
    kullanılacak pic
    complier = pc tarafında kullanılacak derleyici basic olur c olur...

    [simage]
     en basit şekilde 18f2550 ile usb kontrolü
    [/simage]

    [simage]
     en basit şekilde 18f2550 ile usb kontrolü
    [/simage]
    [simage]
     en basit şekilde 18f2550 ile usb kontrolü
    [/simage]

    programın oluşturdugu kodlar bunlar . yukarda benim harmanladıgım kodlarla karşılaştıraktan en basit haliyle portb ye 8 bit lik veri gönderebilirsiniz.

    http://hotfile.com/dl/39965682/80745b2/deneme.zip.html

    yukarda deneme yapabileceginiz isis dosyası ve hazır exe mevcuttur.



    < Bu mesaj bu kişi tarafından değiştirildi edi_büdü -- 26 Nisan 2010; 23:52:13 >







  • güzel bilgi. teşekkürler.
  • Gerçekten çok güzel bir konu olacak, paylaşımınızdan dolayı gerçekten, can-ı gönülden sizi tebrik ederim.
  • afiyet olsun arkadaşlar
  • Yapay Zeka’dan İlgili Konular
    Daha Fazla Göster
    
Sayfa: 1
- x
Bildirim
mesajınız kopyalandı (ctrl+v) yapıştırmak istediğiniz yere yapıştırabilirsiniz.