PIC18f2550 Usb comunication

Thread Starter

Kiyoshi7

Joined Mar 9, 2016
6
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?
 

NorthGuy

Joined Jun 28, 2014
611
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.
 

Picbuster

Joined Dec 2, 2013
1,047
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?
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.
 

Thread Starter

Kiyoshi7

Joined Mar 9, 2016
6
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
 

ErnieM

Joined Apr 24, 2011
8,377
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.
 

NorthGuy

Joined Jun 28, 2014
611
Northguy what kind of input does the mcu expect?
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.
 
Top