PIC18f2550 Usb comunication

Discussion in 'Embedded Systems and Microcontrollers' started by Kiyoshi7, Mar 9, 2016.

  1. Kiyoshi7

    Thread Starter New Member

    Mar 9, 2016
    4
    0
    Hi, I'm looking for some orientation. I want to set up a pic to be a HID and communicate/receive instructions from my computer. For example I want to write a program on my computer and send the instruction to the mcu, via usb, for it to do something (like read the temperature of the room) then give me a return to my computer,via usb. I need the entire program NOT to be on the pic it must follow the instructions that it receives from the usb port.

    can someone point me in the right direction to do this?
     
  2. NorthGuy

    Active Member

    Jun 28, 2014
    603
    121
    HID device is definitely the right direction.

    You can get Microchip USB stack, or you can write your own, or you can use a third party code, which you can find using Google. I wrote my own code and it was a good decision for me. I also used PIC16F1454, which is newer, better, smaller, and cheaper than yours.
     
  3. nigelwright7557

    Senior Member

    May 10, 2008
    487
    71
  4. Picbuster

    Member

    Dec 2, 2013
    373
    50
    write a command interpreter on you pic use a ftdi usb device to hook-up to pc.
    eq send [soh][Xn?][etx] [chksum] from pc the pic will send all information collected.
    when [soh][T1?][etx] [chksum] is received it will send temperature 1.
    You will write this Command interpreter in a few hours collecting the data depending on what you want to collect and how many different type of sensors are being used.
     
  5. Kiyoshi7

    Thread Starter New Member

    Mar 9, 2016
    4
    0
    NorthGuy: Thanks it's good to hear that I'm not making a huge mistake. I've been trying to find out about how to write a usb stack but I can't find much other than 3rd party core. as for the pic... I'm using the 18f2550 cause I got 20 of them for free.

    Nigel: thanks I'll take a look.

    Picbuster: I would prefer not to use and 'extra' device
     
  6. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    Ever since Microchip upgraded their libraries I have been lost following them, though really I have not tried much. These things used to be simple to spin off from their example programs.

    For something like this I would use a COM class, which gives you a virtual serial port most any program can grab to send and receive data.

    HID devices are things like mice and keyboards, which strike me a the wrong choice for your data format.
     
  7. NorthGuy

    Active Member

    Jun 28, 2014
    603
    121
    ... or PICKit3 :)
     
  8. Kiyoshi7

    Thread Starter New Member

    Mar 9, 2016
    4
    0
    Can you explain com class to me? Or tell me where I can get more information?
     
  9. Kiyoshi7

    Thread Starter New Member

    Mar 9, 2016
    4
    0
    Northguy what kind of input does the mcu expect?
     
  10. NorthGuy

    Active Member

    Jun 28, 2014
    603
    121
    USB has some structure. It does packet exchange between entities called endpoints. You tell the host computer how many endpoints you have and what they are. Then a USB driver on the host can send/receive packets through endpoints.

    HID is a USB class designed to use endpoints to exchange so-called reports.

    CDC (what ErnieM has suggested) is a USB class designed to use endpoints to organize bi-directional stream.

    You need to get some book on USB, or relay on somebody else's working code.
     
Loading...