USBDemo, something to learn USB a little bit


Closed Thread
Results 1 to 40 of 279

Hybrid View

  1. #1
    Join Date
    Aug 2008
    Location
    Tucson AZ
    Posts
    3


    Did you find this post helpful? Yes | No

    Default

    Hello,

    First, Mister e This is an outstanding demo. Was able to get running right out of the box on a PIC18f4550.

    I've been trying to add an additonal 8 LEDs to the demo but keep getting overrun errors. Which I'm sure it's caused on the VB side. I'm almost sure the PIC side is ok as i can turn on the original 8 LED or the ones added to PORTD. Can even turn on 4 on PORTB and 4 on PORTD. I'm just unable to get all 16 working at the same time.

    I think my problem is in this part of the VB side code. I was hoping someone could point me back in the proper direction
    Code:
    Private Sub Check1_Click(index As Integer)
        '
        '   Convert PORTB check box to decimal value before sending it
        '   to USB bus.  Result is store in BufferOut(1)
        '
        Dim LoopCheck, PORTB As Byte
        PORTB = 0
        For LoopCheck = 0 to 15                                               ' 0 To 7
            PORTB = PORTB + (Check1(LoopCheck).Value * (2 ^ LoopCheck))
            Next
        BufferOut(1) = PORTB
        WriteSomeData
    End Sub
    Any assistance would be greatly appricated
    Last edited by Philtkp; - 8th August 2008 at 18:59. Reason: Formatting

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Philtkp View Post
    Private Sub Check1_Click(index As Integer)
    '
    ' Convert PORTB check box to decimal value before sending it
    ' to USB bus. Result is store in BufferOut(1)
    '
    Dim LoopCheck, PORTB As Byte
    PORTB = 0
    For LoopCheck = 0 to 15 ' 0 To 7
    PORTB = PORTB + (Check1(LoopCheck).Value * (2 ^ LoopCheck))
    Next
    BufferOut(1) = PORTB
    WriteSomeData
    End Sub
    PortB is a byte value. A byte runs 0-255...
    2 ^ 15 = 32,768 which is greater than 255!

  3. #3
    Join Date
    Aug 2008
    Location
    Tucson AZ
    Posts
    3


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    PortB is a byte value. A byte runs 0-255...
    2 ^ 15 = 32,768 which is greater than 255!
    I tried changing the variable, PortB to an Integer and Long with no positive results

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Philtkp View Post
    I tried changing the variable, PortB to an Integer and Long with no positive results
    Well of course it won't work.
    PortB is a Visual Basic Byte variable (or whatever you want) which gets stored in a Byte Array and sent over the USB to the PIC as a Byte variable stored in a Byte array, which is then stored in the PIC as a Byte variable.
    Code:
    Private Sub Check1_Click(index As Integer)
    '
    ' Convert PORTB check box to decimal value before sending it
    ' to USB bus. Result is store in BufferOut(1)
    '
    Dim LoopCheck, PORTB As Byte
    PORTB = 0
    For LoopCheck = 0 to 15 ' 0 To 7
    PORTB = PORTB + (Check1(LoopCheck).Value * (2 ^ LoopCheck))
    Next
    BufferOut(1) = PORTB
    WriteSomeData
    End Sub

  5. #5
    Join Date
    Aug 2008
    Location
    Tucson AZ
    Posts
    3


    Did you find this post helpful? Yes | No

    Default

    Can this be done using an array of bytes?

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Philtkp View Post
    Can this be done using an array of bytes?
    You ARE sending out an array of bytes...8 of them, unless you've messed with the HID-Maker.
    You have to send out more bytes or figure out a way to 'encode' those bytes you've already got to do more...

Similar Threads

  1. Bits, Bytes Words and Arrays
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 24
    Last Post: - 14th June 2016, 08:55
  2. How to receive stream of bytes using PIC USART
    By unifoxz in forum mel PIC BASIC Pro
    Replies: 34
    Last Post: - 20th June 2009, 11:38
  3. Replies: 9
    Last Post: - 31st July 2008, 09:56
  4. PICBasic newbie problem
    By ELCouz in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 12th February 2008, 01:55
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 02:07

Members who have read this thread : 1

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts