PIC USB to VB.NET


Closed Thread
Results 1 to 40 of 54

Hybrid View

  1. #1
    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!!

  2. #2
    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

  3. #3
    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?

  4. #4
    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.

  5. #5
    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?

  6. #6
    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

  7. #7
    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

  8. #8
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,154

    Default Re: PIC USB to VB.NET

    Search for OVERWRITING, you get a ton of threads. Start with this one:

    http://www.picbasic.co.uk/forum/show...ht=overwriting

    Robert

  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

  10. #10
    Join Date
    Aug 2006
    Posts
    20

    Default Re: PIC USB to VB.NET

    Heres some of the code, this all works fine using simple delay or other timer

    Main:
    ; Check for incomming USB data while waiting
    @ ON_USBRX_GOSUB _HandleRX
    lcdout $FE, 1, dec Size
    pause 2000
    if portB.0=1 OR Run=1 then
    high porta.3
    T0CON.7=1 'start TMR0
    mark:
    if not match01 then goto mark 'match01 var INTCON.2 '50msec delay
    T0CON.7=0 'stop timer
    match01=0 'clear interupt flag
    INTCON.5=0 'set interupt enable to 0
    low porta.3
    if plugged then ARRAYWRITE USBTXBuffer, [Size,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] ;send position
    GOSUB WaitToSend
    time=time+1
    lcdout $FE, 1, dec time 'use to check whats happening here
    TMR0H=$C9 '300msec
    TMR0L=$10
    T0CON.7=1 'start TMR0
    space:
    if not match01 then goto space
    T0CON.7=0 'stop timer
    match01=0 'clear interupt flag
    INTCON.5=0 'set interupt enable to 0
    TMR0H=$F6 '50msec pulse
    TMR0L=$D8
    endif
    goto Main

Members who have read this thread : 1

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