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

    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?

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

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

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

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

  6. #6
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172

    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

  7. #7
    Join Date
    Feb 2007
    Posts
    37

    Default Re: PIC USB to VB.NET

    Hi,

    I have commented all of that:
    Code:
    ;--- if you un-comment these, you must comment the ones in the .inc file ---
    'ASM  ; 18F2550/4550, 8mhz crystal
    ' commented all to run , otherwize some error arise
    '   __CONFIG    _CONFIG1L, _PLLDIV_2_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
    '   __CONFIG    _CONFIG1H, _FOSC_HSPLL_HS_1H
    '   __CONFIG    _CONFIG2L, _PWRT_ON_2L & _BOR_OFF_2L & _VREGEN_ON_2L
    '   __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
    '   __CONFIG    _CONFIG3H, _PBADEN_OFF_3H
    '   __CONFIG    _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
    'ENDASM
    and all begin to work.

    But there are some conceptual doubt that I have explained on a different thread:

    http://www.picbasic.co.uk/forum/showthread.php?t=17877
    Last edited by Wirecut; - 7th April 2013 at 01:50. Reason: typo error
    Leo

  8. #8
    Join Date
    Feb 2007
    Posts
    37

    Default Re: PIC USB to VB.NET

    Hi,

    thanks to the suggestion of Henrik Ollson on the thread:

    http://www.picbasic.co.uk/forum/show...740#post119740

    I have substitute the ASM/ENDASM to #CONFIG/#ENDCONFIG as:
    Code:
    #CONFIG  ; 18F4550, 20mhz crystal 
       __CONFIG    _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
       __CONFIG    _CONFIG1H, _FOSC_HSPLL_HS_1H
       __CONFIG    _CONFIG2L, _PWRT_ON_2L & _BOR_OFF_2L & _VREGEN_ON_2L
       __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
       __CONFIG    _CONFIG3H, _PBADEN_OFF_3H
       __CONFIG    _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
    #ENDCONFIG
    and now "automagically" all works! GREATH!!!!
    Leo

  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

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

    Default Re: PIC USB to VB.NET

    Getting back to USB basics after a 3 year absence. I cant seem to get the code in the first post to run on a 18F2550. I get: ERROR Line 25: Bad BANK number. (DT_HID260.pbp) Apparently this issue didn't exist the first time I ran the code all that time ago.

    Any pointers?

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