Beginning USB How to/Whats needed to use it.


Closed Thread
Results 1 to 10 of 10
  1. #1
    Join Date
    Dec 2012
    Location
    Tennessee
    Posts
    262

    Default Beginning USB How to/Whats needed to use it.

    I would like to start interfacing PICs to my PC, I can program VB.NET applications and it has a serial output in that software, so if I can turn my usb on and have it act like a serial port I should be able to interface with the PIC.

    First though we need to get a breakdown of whats all needed and identify some of the terms and definitions used. second is what is our limits, what kind of data can we send/receive, third what is needed in code to turn on USB, etc...
    4th project ideas.

    Number 1
    What is HID?
    In MicroCode Studio (I have version 4) there is a "Easy HID Maker" Should we use this or is there a better way?
    Does enabling USB just place a new COM Port on the PC?
    If its not a COM Port then how do we communicate?
    As far as schematics and electrical layout, I will be using a 18F4550, D+ & D- are tied to those pins, vUSB is tied to power/capacitor etc. there are numerous layouts online for the electrical side. So this shouldnt be a problem, but if anyone has special notes or ideas, put them in.
    If Ive missed anything for number 1 just add it in.

    Now for Number 2
    How much data can we send in a single stream?
    can we send text? like a "Hello World" to a LCD?
    Does the USB have to sync with PC on regular basis or just act like a one-shot?
    Other ideas?

    And Number 3
    Ive seen some articles that list a few DEFINEs for USB, Is there a minimum or are all required and what are they?
    How do you store the info that is to be sent or received from USB?
    Do you just transmit/receive like serial, example USBIN USBOUT?

    Number 4, Ideas?
    I would like to control several Servos, LEDs, interface with multiple ADC's for readings, be able to read the I/O states, Etc...
    What have other people used USB for?\


    now I may have left some stuff out, this is just a list of stuff that comes to mind right now. I did several searches for USB and didnt find great info on begining USB. The idea though is to list everything to get USB to run and bits of code for interfacing it.
    Chris


    Any man who has accomplished anything in electronics at one time or another has said... " STOP! WAIT! NOOO! Dangit.... Oh Well, Time to start over..."

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


    Did you find this post helpful? Yes | No

    Default Re: Beginning USB How to/Whats needed to use it.

    http://www.picbasic.co.uk/forum/showthread.php?t=5418

    I would start by going through that.

    Robert

  3. #3
    Join Date
    Dec 2012
    Location
    Tennessee
    Posts
    262


    Did you find this post helpful? Yes | No

    Default Re: Beginning USB How to/Whats needed to use it.

    Ive read through it some, and i unerstand a bit of it, but most of its based on the first code/project and making a few modifications to it, I understood darrels a bit better, but was hopeing to get a from scratch point of view, you know what is the minimum code/hid requirements and then list some items you can add to it. For instance, I have 1 project right now, uses only 2 pins of a 4550 chip, a ADC input and a single I/O output, it takes a reading and outputs based on reading, now I need to randomly make changes to what the output changes to on a flexible scale, think of something like a oven, you might want it on at 300 degres for 10 minutes but the next day you want it at 400 for 1 hour. the computer can take the reading and tell the output pin when to go high. another progect I need to control say 16 servos with the computer... and yet another is a audio controller circuit that controld 4 volumes via spi, also needs to work with bass treble lcd display, and led matrix. but to begin with I thought I would start with just taking a ADC reading , send to computer , computer makes desision on what to do and sends a 1 or 0 to PIC to output to other device.

    There is alot of extra stuff I dont need in those other examples some of its outdated anyways, and am unsure of what to cull from code.
    Chris


    Any man who has accomplished anything in electronics at one time or another has said... " STOP! WAIT! NOOO! Dangit.... Oh Well, Time to start over..."

  4. #4
    Join Date
    Dec 2012
    Location
    Tennessee
    Posts
    262


    Did you find this post helpful? Yes | No

    Default Re: Beginning USB How to/Whats needed to use it.

    just an example of code that I am starting with

    Code:
    '*  Notes   : Using 18F4550                                     *
    '*          :                                                   *
    '****************************************************************
    DEFINE ADC_BITS 10 ' A/D number of bits
    DEFINE ADC_CLOCK 1 ' Use A/D internal RC clock
    DEFINE ADC_SAMPLEUS 50 ' Set sampling time in us
    
    TRISA = 1           ' PORTA.0 is Analog Input
    TRISB = 0           ' PORTB is Output
    
    Analog VAR WORD     ' Stores the 16bit Result from ADC0
    UnitON VAR Bit      ' Stores the state that output should be
    UnitON = 0          ' Initial state
    
    MainLoop:
    ADCIN 0, Analog     ' Saves 16bit Analog reading to Variable
    
    'Code for sending Analog reading to PC
    'Code for receiving the state needed to send to output port.
    
    PORTB.0 = UnitON
    pause 100
    goto mainloop
    
    END
    Chris


    Any man who has accomplished anything in electronics at one time or another has said... " STOP! WAIT! NOOO! Dangit.... Oh Well, Time to start over..."

  5. #5
    Join Date
    Dec 2011
    Location
    IO93ok
    Posts
    190


    Did you find this post helpful? Yes | No

    Default Re: Beginning USB How to/Whats needed to use it.

    Any idea where I can download Easy HID Maker as the site throws up a 404 error ?

  6. #6


    Did you find this post helpful? Yes | No

    Default Re: Beginning USB How to/Whats needed to use it.

    Chris I'm not familiar with that chip but don't you mean TRISA = 255 for all inputs?

  7. #7
    Join Date
    Dec 2012
    Location
    Tennessee
    Posts
    262


    Did you find this post helpful? Yes | No

    Default Re: Beginning USB How to/Whats needed to use it.

    tasmod try this
    EASY HID

    peter, this chip has to set up the buts with some kind of special binary its weird, you would think trisa = 255 or %11111111, but it doesnt. %00000001 = just porta.0 is adc, but to get more theres a chart, so if your just neededing 1 adc, then porta = 1 works.
    Chris


    Any man who has accomplished anything in electronics at one time or another has said... " STOP! WAIT! NOOO! Dangit.... Oh Well, Time to start over..."

  8. #8
    Join Date
    Dec 2011
    Location
    IO93ok
    Posts
    190


    Did you find this post helpful? Yes | No

    Default Re: Beginning USB How to/Whats needed to use it.

    Thanks Chris,

    Unfortunatey that's the site where the download link throws up the 404 error.

    Rob

  9. #9
    Join Date
    Dec 2012
    Location
    Tennessee
    Posts
    262


    Did you find this post helpful? Yes | No

    Default Re: Beginning USB How to/Whats needed to use it.

    Sorry Tazmod,
    Heres a working link
    Chris


    Any man who has accomplished anything in electronics at one time or another has said... " STOP! WAIT! NOOO! Dangit.... Oh Well, Time to start over..."

  10. #10
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: Beginning USB How to/Whats needed to use it.

    Or you could use an FT232RL at about $4.50 USD with absolutely ZERO headaches or brain damage, which is what those Arduino thingies do.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Similar Threads

  1. PIC USB in and USB Out
    By koossa in forum General
    Replies: 2
    Last Post: - 9th February 2013, 09:00
  2. Missing chars at beginning of LCD display
    By jimbostlawrence in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 20th November 2009, 00:13
  3. 12F629 beginning
    By Davidpower in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 1st October 2007, 22:37
  4. Program returns to beginning at interupt
    By BGreen in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 25th April 2005, 11:20

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