USBDemo, something to learn USB a little bit


Closed Thread
Results 1 to 40 of 279

Hybrid View

  1. #1
    Join Date
    Aug 2008
    Posts
    3


    Did you find this post helpful? Yes | No

    Default

    i want to use usbdemo to count rpm of motor and display the rpm in computer. how to do that?

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


    Did you find this post helpful? Yes | No

    Default

    Begin small, begin by finding a way to count the RPM, show it on a lcd or via a serial communication... once you have it done, port your to code to USBDemo.
    Steve

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

  3. #3
    Join Date
    Aug 2008
    Posts
    3


    Did you find this post helpful? Yes | No

    Default

    i use 8 slot encoder.
    after googling few minutes. i add this code into usbdemo
    Code:
         COUNT PORTA.2,100,speed
         speed = speed * 10 * 60 / 8
         rpm[0] = speed / 1000 // 10
         rpm[1] = speed / 100 // 10
         rpm[2] = speed / 10 // 10
         rpm[3] = speed // 10
         rpm[4] = 0
         rpm[5] = 0
         rpm[6] = 1
         rpm[7] = 1
         
    @   SendUSB _rpm

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    With the release of PBP version 2.60, mister-e's USBdemo (or any other program derived from EasyHID) will no longer compile (without some changes).

    The new way of doing USB with PBP is really nice.
    So here's a modification to Steve's program that will allow it to be compiled with PBP 2.60, and hopefully show how much easier it is to do USB.<hr>
    . If you haven't already ... download and extract the USBDemo from the beginning of this thread.

    . Then create a new folder (USBDemo260) and copy the USBDemo.pbp file from Steve's archive into the new folder.
    That is the only file that is valid with 2.60, so don't copy any of the others.

    . Download the USBDEMOdesc.bas.txt (descriptor) file attached to this post and place it in the same folder. Remove the .txt extension.

    . In the USB18 folder, inside your PBP folder ...
    Copy the following files to the project ...

    usb_dev.asm
    usb_dev.inc
    usb_hid.asm
    usb_hid.inc
    usb_mem.asm


    . Add this line to the USBDemo.PBP program ... and compile.
    Code:
      INCLUDE "USBDEMOdesc.bas"
    And away you go, with a little Ding-Dong ... Or maybe a Dong-Ding. <hr>
    Make sure you change the configs if you're not using a 4Mhz crystal.
    And comment out the UCFG EXT variable since it's not needed anymore.

    The Visual Basic part of mister-e's demo is the same.
    You can use the pre-compiled program, or modify it as desired.
    Attached Files Attached Files
    DT

  5. #5
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378


    Did you find this post helpful? Yes | No

    Default One statement causes compile error

    Quote Originally Posted by Darrel Taylor View Post
    . If you haven't already ... download and extract the USBDemo from the beginning of this thread.

    . Then create a new folder (USBDemo260) and copy the USBDemo.pbp file from Steve's archive into the new folder.
    That is the only file that is valid with 2.60, so don't copy any of the others.

    . Download the USBDEMOdesc.bas.txt (descriptor) file attached to this post and place it in the same folder. Remove the .txt extension.

    . In the USB18 folder, inside your PBP folder ...
    Copy the following files to the project ...

    usb_dev.asm
    usb_dev.inc
    usb_hid.asm
    usb_hid.inc
    usb_mem.asm


    . Add this line to the USBDemo.PBP program ... and compile.
    Code:
      INCLUDE "USBDEMOdesc.bas"
    Darrel, I followed steps you listed explicitly and then tried to compile with PBP 2.6. Got the following error:
    " ERROR line 81: Redefinition of VAR. USBDemo.pbp]"
    which I don't understand since the UCFG variable is not declared anywhere else in the code...just this line where the code occurs.
    The error applies to the statement
    "UCFG VAR BYTE EXT ' include UCFG register... Yeah Melabs didn't ("

    I went to manual on 2.6 compiler to check syntax of this statement. I guess I don't understand the use of EXT at the end of the statement....manual doesn't explain that.

    Can you tell me what might be wrong and why this won't compile?? I would really like to get this USBDemo going for my 18F4550.

    Also don't understand why Steve's schematic that you posted varies from the hardware description in the USBDemo260 code:
    Here is the Hardware description from the code:
    Hardware:
    ' ---------
    ' 4 Push Buttons on PORTA<5:2> with pull-down resistors
    ' 2 Trim pot on PORTA<1:0>
    ' 8 LEDs attach between PORTB and GND
    ' 2 LEDs attach to CCP<2:1> pins
    ' 4 MHZ crystal & all the usual USB stuff
    Yet the schematic shows no pushbuttons on PORTA <5:2>, no trim pota on PORTA <1:0>, no LEDS on PORTB or CCP, and a 20 MHz crystal rather than 4 MHz. Can you advise me of the correct hardware hookups for the USBDemo260 code...the schematic or the code description??

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by jellis00 View Post
    Darrel, I followed steps you listed explicitly...The error applies to the statement "UCFG VAR BYTE EXT
    Quote Originally Posted by Darrel Taylor View Post
    ... And comment out the UCFG EXT variable since it's not needed anymore. ...
    Steve wrote that program when 2.46 was the latest and greatest.
    At that time UCFG VAR EXT was missing from the PIC18EXT.bas file.
    But with 2.60, the oversight has been corrected, so you don't need that line anymore.
    Well actually, you didn't need it then either, it's handled by the USB routines.
    So not sure why he put it there to begin with.

    The schematic is the one you requested.
    It was originally from Mecanique, and I'm sure he was showing how to hook up the USB stuff.
    And probably assumed the user would know how to connect LED's and switches on their own.
    <br>
    DT

  7. #7
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378


    Did you find this post helpful? Yes | No

    Default Compiles OK now!

    Quote Originally Posted by Darrel Taylor View Post
    At that time UCFG VAR EXT was missing from the PIC18EXT.bas file.
    But with 2.60, the oversight has been corrected, so you don't need that line anymore.<br>
    Thanks, Darrel. That fixed it and it now compiles. Sorry I didn't read your comment more closely about commenting out this statement.
    My next step, now that it will compile, is to configure my hardware on an EasyPic6 and then program the 18F4550 and run the program.

    One question: Do I need to run the VB6 program on my PC with the USB cable connected before I turn on power to the 18F4550 and run its code??

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