Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

connecting USB device

Status
Not open for further replies.

chintan_jagani

New Member
I want to build a design to be able to connect a USB device to a RS232 port or a PS/2 port. Can I accomplish this using the USB compatible 18F series of PICs?
In other words, I want to have a two-way conversion b/w RS232 & USB ports
rather than a one way conversion, i.e.RS232 to USB, as is described in the PIC18F datasheets & application notes. Can anybody help me out?
 
Since you also emailed this question to me separately, I'll post more of a response here:

You need to specify what exactly you mean. Are you talking about connecting a PIC to both an RS232 port, and the USB port of a computer? This would be no problem.

Or, are you talking about connecting a PIC to an RS232 port, and connecting some other USB device to the PIC, and having it act as a translator/adapter in between? This is NOT possible with a PIC, because a PIC CANNOT act as a USB host to another device, it can ONLY be a device itself. You'd have to be familiar with the details of USB to understand, but the job of a host is far, far more complicated than the job of a device. You would need to look to other, more advanced microcontrollers and probably some separate USB host controller IC's, and the whole thing would be beyond the realm of PICs.
 
Last edited:
eblc1388 said:
The short answer is yes.

Looks here for CDC COM port emulation:

**broken link removed**


I want to connect a USB device to my computer through an RS232 port.
This information is not available on the link suggested by u. Can u provide any solution to this?
 
evandude said:
Since you also emailed this question to me separately, I'll post more of a response here:

You need to specify what exactly you mean. Are you talking about connecting a PIC to both an RS232 port, and the USB port of a computer? This would be no problem.

Or, are you talking about connecting a PIC to an RS232 port, and connecting some other USB device to the PIC, and having it act as a translator/adapter in between? This is NOT possible with a PIC, because a PIC CANNOT act as a USB host to another device, it can ONLY be a device itself. You'd have to be familiar with the details of USB to understand, but the job of a host is far, far more complicated than the job of a device. You would need to look to other, more advanced microcontrollers and probably some separate USB host controller IC's, and the whole thing would be beyond the realm of PICs.
Yes, I want to connect a PIC to an RS232 port, and connecting some other USB device to the PIC, and having it act as a translator/adapter in between.
I have a bit idea that the enumeration & other processes for a USB device are difficult. Can't I use my kit only as a medium for interconection b/w USB device & RS232 cable and let the computer be the USB host which acts at the RS232 port(through software changes), of the computer by making proper level changes for RS232 & USB compatibility?
As I am still a student, please bear with me.
 
chintan_jagani said:
I want to connect a USB device to my computer through an RS232 port.

That I know of no way to implement using a PIC as an USB HOST, see also comments by evandude above.
 
chintan_jagani said:
I have a bit idea that the enumeration & other processes for a USB device are difficult. Can't I use my kit only as a medium for interconection b/w USB device & RS232 cable and let the computer be the USB host which acts at the RS232 port(through software changes), of the computer by making proper level changes for RS232 & USB compatibility?
As I am still a student, please bear with me.

To do that, you would have to implement your own custom version of the USB stack in software on the PC. I think it's safe to say that that's way beyond the realm of a hobbyist. In addition, the serial port would have to actually be fast enough - even low-speed USB is 1.5Mbps, which is faster than I have ever seen a serial port run, and that's even assuming you were bit-banging to avoid the extra overhead of the serial packets... And also assuming that your USB device is made for low-speed, which is often not the case unless it's a mouse or something simple like that. Even worse than that, the USB protocol has to implement things like acknowledge bits and things like that in every packet, so you couldn't just buffer the data and send it out slowly over serial, you have to do it real-time. RS232 is very simple, there's almost no protocol to it, just a start bit, stop bit, and some data. USB very complicated and has TONS of protocol, with a LOT more communication going on than just the data. You would pretty much have to be sending all the USB data through the serial port at full USB speed, which it is totally not made for. Quite simply, USB is much faster than serial ports which is why it replaces them in so many applications, so it shouldn't seem surprising that the older, slower serial port cannot be used for USB.

It is just NOT a realistic project.
 
Last edited:
Then, I am in a big problem now.
I have registered this as my final year project.

Is there any way out? Like can I use a microcontroller which can act as a USB host and through it connect to my RS232 port?
 
chintan_jagani said:
Then, I am in a big problem now.
I have registered this as my final year project.

Did you not consider the difficulties involved before registered it?, surely you looked in to the practicallity of it before deciding on it?.

Is there any way out? Like can I use a microcontroller which can act as a USB host and through it connect to my RS232 port?

Presumably a final year project has to be fairly difficult?, I suggest you get googling and try and find some information on it.

Although, to be honest, the whole idea seems flawed? - whats the point trying to connect a fast USB device to a slow serial port?.
 
Sorry to say it, but I agree with Nigel, it is NOT a good idea to commit yourself to a project before you even research it enough to know if you can actually handle it.

As I mentioned, you can purchase chips that can act as USB hosts. You can find a few on a list at **broken link removed**

Complexity is a huge problem though. Just for an example, the AT43USB370 comes in a 100-pin package, if that gives you any indication. Not only would you have to do a TON of work to write your own firmware for this thing, including a driver for the particular USB device you plan to interface it with, but you probably won't have the benefit of any example code, tutorials, projects, or anything like that to help you get started because I don't believe I've ever seen a hobbyist actually do this before... which should be another good indication of how hard it is. Plus, for proprietary, advanced chips like that you may not even be able to get free development software, you might need some expensive, proprietary software package.

To actually succeed you would need a very good understanding of the USB protocol, to be a very experienced programmer, and be very familiar with microcontrollers and computer architecture and things of that nature. This is not even CLOSE to being a reasonable school project. I would go so far as to call it downright impossible, given the typical time frame of such projects, and the fact that you don't have the required experience (if you did, you wouldn't have needed to ask these questions) Your time would be better spent convincing your instructor to let you change your project, than on trying to make this work.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top