PIC USB to VB.NET


Closed Thread
Results 1 to 40 of 54

Hybrid View

  1. #1
    Join Date
    Aug 2008
    Location
    Portugal
    Posts
    240

    Default Re: PIC USB to VB.NET

    HI;

    To send data from PIC to PC, you must do something like this ( Allready posted in the code of the post #1 )

    Code:
    ARRAYWRITE USBTXBuffer, [Value0, Value1, PORTA.2,PORTA.3, PORTA.4, PORTA.5,0,0]
    You don't have to worry about the first byte be equal to 0, only ont the PC to PIC side.

    If you want to send from PC to PIC, you must do something like this ( Allready posted in the code of the post #1 )

    Code:
    PublicSub WriteSomeData()
    ' Use to send data to the USB bus.
    ' data must be store in BufferOut array
    '
    ' Actual structure:
    ' -----------------
    BufferOut(0) = 0    ' first by is always the report ID
    BufferOut(1) = 127 ' value from 1º slider
    BufferOut(2) = 255 ' value from 2º slider
    BufferOut(3) = 10
    BufferOut(4) = 100
    BufferOut(5) = 178
    BufferOut(6) = 0
    BufferOut(7) = 0
    BufferOut(8) = 0
    hidWriteEx(VendorID, ProductID, BufferOut(0)) ' send it
    EndSub
    
    Thanks and Regards;
    Gadelhas

  2. #2
    Join Date
    Feb 2004
    Location
    Michigan, USA
    Posts
    305

    Default Re: PIC USB to VB.NET

    Are the values in BufferOut(1) through BufferOut(5) decimal? Are they bytes or words?

    How do I receive these values and put them into VAR BYTES?

    Do I always need to send the 8 values of BufferOut or can I send say just BufferOut(3)?

    Can I send BufferOut(1) = "text here" for example?



    Thank you!!

  3. #3
    Join Date
    Aug 2008
    Location
    Portugal
    Posts
    240

    Default Re: PIC USB to VB.NET

    Quote Originally Posted by jmgelba View Post
    Are the values in BufferOut(1) through BufferOut(5) decimal? Are they bytes or words?

    How do I receive these values and put them into VAR BYTES?

    Do I always need to send the 8 values of BufferOut or can I send say just BufferOut(3)?

    Can I send BufferOut(1) = "text here" for example?



    Thank you!!
    Hi, you are not reading the code that i posted.
    If you read the code carfully you see that in VB the BufferOut Array is declared asbyte, so you can only send bytes.
    Code:
    Dim BufferOut(BufferOutSize) AsByte
    On the PIC side you receive the bytes on the USBRXBuffer array, and then you do what you want with those bytes.
    Code:
      ARRAYREAD  USBRXBuffer,[PORTB, DUTY1.LowByte, DUTY1.HighByte, DUTY2.LowByte, DUTY2.HighByte]
    On the VB side you receive tte bytes on BufferIn array, and then you do what you want with thise bytes.
    Code:
    Dim BufferIn(BufferInSize) AsByte
    Since the Define of the USB_INSIZE and USB_OUTSIZE are equal to 8, you can only send and receive 8 bytes. You can change this, to multiples values, like 16, 32, 64. YOu need always to send all th ebytes that are defined. You you Define 8, you must send 8 bytes, if you define 16 you must send 16 bytes. For instance, if you have only 10 bytes to send, you must define you USB_sizes equal to 16, and complete the array with 0's.

    Can I send BufferOut(1) = "text here" for example?
    You cannot do that, because it excedes the number of bytes. BufferOut(1) is one byte only. You cand o just this, BufferOut(1)="t", or
    BufferOut = "0abcdefgh".

    I think that you should read both PIC and VB code that i posted and review review some principles of the PBP manual.
    Thanks and Regards;
    Gadelhas

  4. #4
    Join Date
    Feb 2004
    Location
    Michigan, USA
    Posts
    305

    Default Re: PIC USB to VB.NET

    Ok, then I think I've found a problem. My buffer size is set to 16 in and out but I'm only rx/tx'ing 8.

    When receiving empty bytes, how do I deal with them? Say I only ever need to send 3 bytes, the left overs will always be empty. Do I just assign unused VAR Bytes to those incoming bytes?

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default Re: PIC USB to VB.NET

    You just need to parse/test them on both side. Treat USB like any proper serial communication and you should be fine. Your milleage may vary though.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Join Date
    Feb 2004
    Location
    Michigan, USA
    Posts
    305

    Default Re: PIC USB to VB.NET

    Thanks guys. I think I've found my issues.

    One more question for now though, is the data within the byte transmitted msb first or lsb first from VB?

  7. #7
    Join Date
    Aug 2008
    Location
    Portugal
    Posts
    240

    Default Re: PIC USB to VB.NET

    Quote Originally Posted by jmgelba View Post
    Thanks guys. I think I've found my issues.

    One more question for now though, is the data within the byte transmitted msb first or lsb first from VB?

    The answer to your question is in the code in post #1 and #2.
    Thanks and Regards;
    Gadelhas

  8. #8
    Join Date
    Feb 2007
    Posts
    37

    Default Re: PIC USB to VB.NET

    Hi.

    I have tried to compile the source code that is present on the first page of this thread and I obtain the following error message:

    Code:
    Error[118]   C:\PIC\MEL\PBP3061\18F4550\USB\PICUSB\PICUSB.ASM 301 : Overwriting previous address contents (0000)
    Error[118]   C:\PIC\MEL\PBP3061\18F4550\USB\PICUSB\PICUSB.ASM 301 : Overwriting previous address contents (0001)
    Error[118]   C:\PIC\MEL\PBP3061\18F4550\USB\PICUSB\PICUSB.ASM 302 : Overwriting previous address contents (0000)
    Error[118]   C:\PIC\MEL\PBP3061\18F4550\USB\PICUSB\PICUSB.ASM 302 : Overwriting previous address contents (0001)
    Error[118]   C:\PIC\MEL\PBP3061\18F4550\USB\PICUSB\PICUSB.ASM 303 : Overwriting previous address contents (0002)
    Error[118]   C:\PIC\MEL\PBP3061\18F4550\USB\PICUSB\PICUSB.ASM 303 : Overwriting previous address contents (0003)
    Error[118]   C:\PIC\MEL\PBP3061\18F4550\USB\PICUSB\PICUSB.ASM 304 : Overwriting previous address contents (0002)
    Error[118]   C:\PIC\MEL\PBP3061\18F4550\USB\PICUSB\PICUSB.ASM 304 : Overwriting previous address contents (0003)
    Error[118]   C:\PIC\MEL\PBP3061\18F4550\USB\PICUSB\PICUSB.ASM 305 : Overwriting previous address contents (0004)
    Error[118]   C:\PIC\MEL\PBP3061\18F4550\USB\PICUSB\PICUSB.ASM 305 : Overwriting previous address contents (0005)
    Error[118]   C:\PIC\MEL\PBP3061\18F4550\USB\PICUSB\PICUSB.ASM 306 : Overwriting previous address contents (0006)
    Error[118]   C:\PIC\MEL\PBP3061\18F4550\USB\PICUSB\PICUSB.ASM 306 : Overwriting previous address contents (0007)
    the content of the file into the working directory is:

    Code:
    24/01/2011  02:45            22.213 DT_HID260.pbp
    04/11/2009  11:41            28.721 DT_INTS-18.bas
    04/04/2013  10:03             7.665 firmware.zip
    04/04/2013  11:52            84.061 PICUSB.ASM
    04/04/2013  11:52             1.368 PiCUSB.ERR
    04/04/2013  11:52         1.112.440 PiCUSB.LST
    04/04/2013  11:52            10.855 PICUSB.MAC
    04/04/2013  11:52             4.917 PiCUSB.pbp
    21/06/2012  03:06            96.199 usb_dev.asm
    21/06/2012  03:06             6.290 usb_dev.inc
    21/06/2012  03:06            26.203 usb_hid.asm
    21/06/2012  03:06             6.378 usb_hid.inc
    21/06/2012  03:06             6.403 usb_mem.asm
    I'm using:
    Win 7 Ultimate
    A 18F4550 that will be run on the PICDEM FSUSB
    PBP 3.0.6.1
    MCS 5.0.0.3

    I have the trial version (15 gg left - I'm waiting to solve some administrative trouble before buy the upgrade)

    Attached please find the Directory contents.

    Any suggestion will be more appreciate.

    Ciao

    Leo
    Attached Files Attached Files

  9. #9
    Join Date
    Aug 2006
    Posts
    20

    Default Re: PIC USB to VB.NET

    Hi all,

    I'm trying to use TMR0 however USB does not seem to communicate. I saw in past threads that TMR0 was used for USB polling, I've been examining all files related DT-INTS, DT-HID and soforth, TMR0 does not appear, so I don't know why using this timer would stop things. I'm not using DT-INTS on overflow just monitoring the int flag. By itsself i.e. no USB this little routine works fine. I'm outputing a 50msec (mark) pulse on portB then a second delay of around 300 msec (space). Goal is to adjust the space to vary stepper motor speed.

    advice appreciated

    Cheers

    John

Members who have read this thread : 0

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

Posting Permissions

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