View previous topic :: View next topic |
Author |
Message |
ollopa
Joined: 03 Sep 2007 Posts: 233 Location: California
|
Posted: Sun Aug 02, 2009 4:07 pm Post subject: |
|
|
OK, some more cool news to share.
I thought I would try to put together a device that makes a virtual COM port, as Glen asked for. That raises an issue, though, because the only way to do that 100% plug-and-play is to make a Communications Device Class (CDC) device. That requires 2 bulk endpoints and 1 interrupt IN endpoint. Bulk endpoints are forbidden in low-speed devices and CDC also specifies one too many endpoints for low-speed devices. The result is hit-or-miss compatibility with different OS's, not to mention a lot of hacking up the usb firmware.
So I decided to go the other route and implement a virtual com port via USB control messages and a custom windows driver. I have compiled a windows driver once before, but never actually learned how to create one. Nevertheless, I have a measure of success to share today! The most recent Windows Driver Kit comes with some very useful templates and examples. One of them is a virtual com port that pretends to be a modem and echos back whatever is sent to it. Another is a sort of tutorial on writing USB drivers. I was able to combine the two and attach the driver to my AVR usb device. When I plug my USB test setup into my computer, the driver loads and creates the virtual comport. I can then open the port with a terminal emulator and talk to it. The driver also opens a control pipe to the USB device. I've tested on Windows 7 and XP. All I have to do now is write in a few lines of code to bridge the control pipe to the virtual serial port and then that will be done
I'm getting very close to the initial release of the software. My Digikey order is due to arrive in three days and then I can test with different parts and possibly update the library to support other clock speeds. I will, of course, make the serial port driver code available as well, once it is finished.
Finally, here is a screenshot:
(Excuse the Japanese... I'm uh, "excentric" ) |
|
Back to top |
|
|
Netzman
Joined: 25 Nov 2005 Posts: 127 Location: Graz
|
Posted: Sun Aug 02, 2009 4:21 pm Post subject: |
|
|
very nice work!
i think the virtual serial port is the most demanded feature...
what about a standalone firmware which you just have to program into the avr and it provides a serial interface and some i/o ports?
should be possible since you can define several usb devices in one endpoint and you already wrote your own driver?
best regards |
|
Back to top |
|
|
ollopa
Joined: 03 Sep 2007 Posts: 233 Location: California
|
Posted: Sun Aug 02, 2009 5:12 pm Post subject: |
|
|
Netzman, can you elaborate on that? I don't think I completely understand your idea.
Do you mean you want to be able to read and write ports on the AVR via commands sent from the PC on the virtual serial port ? |
|
Back to top |
|
|
Netzman
Joined: 25 Nov 2005 Posts: 127 Location: Graz
|
Posted: Sun Aug 02, 2009 5:20 pm Post subject: |
|
|
yes, exactly. i mean "black box" avr like th I/O Warrior ( http://www.codemercs.com/index.php?id=64&L=1 ), that would be a cheap solution for almost every USB communication.
i'm not too deep in USB specs, so i don't know if that's possible with your functions, driver etc.
best regards |
|
Back to top |
|
|
vbb_77
Joined: 24 Apr 2009 Posts: 14
|
Posted: Sun Aug 02, 2009 10:41 pm Post subject: |
|
|
>>I have a measure of success to share today! The most recent
>>Windows Driver Kit comes with some very useful templates
@ollopa
What is the name of the "windows driver kit" ? |
|
Back to top |
|
|
ollopa
Joined: 03 Sep 2007 Posts: 233 Location: California
|
|
Back to top |
|
|
Netzman
Joined: 25 Nov 2005 Posts: 127 Location: Graz
|
Posted: Mon Aug 03, 2009 3:47 am Post subject: |
|
|
sorry, i think i didn't explain that very well...
Following the USB specs, you can define several interfaces in one physical device. One would be your serial port, which forwards it to the USART of the AVR. Another one would be the I/O port control, using command pipes.
Maybe an I²C interface etc...
So you just have to program a mega8, for example, with this firmware and you have almost everything you need to communicate with the PC over USB, and your main µC don't have to care about USB. Like you said, much CPU time is spend for the USB communication.
I hope you can understand what i mean. What do you think about this solution?
best regards |
|
Back to top |
|
|
ollopa
Joined: 03 Sep 2007 Posts: 233 Location: California
|
Posted: Mon Aug 03, 2009 5:10 am Post subject: |
|
|
Netzman,
It is a good idea. I initially planned to do something similar with my project where the device appears to the computer as two separate devices, even though it is only one. In practice, however, this solution is not very good for low speed USB devices. Low speed devices are limited to only 4 endpoints according to the spec. It sounds like enough, but endpoints are unidirectional. The control endpoint, at address 0, is bidirectional which means that it takes up 2 of the 4 available endpoints. That only leaves two unidirectional endpoints.
It sounds like you want a kind of multi-protocol I/O breakout board connected to the PC so you could do things like talk over the serial port or send data from a program and have the board convert it to a multitude of protocols. I think I'm starting to understand the concept. So here is how I would do that: The AVR and the PC would talk to each other over interrupt IN and OUT pipes using a custom defined protocol. The driver would expose a virtual serial port and perhaps even a virtual parallel port, if that were useful to anybody. Additionally, there would be a DLL that talks to the driver via custom IOCTLs. The driver would take care of translating data to the custom protocol and routing incoming data to the appropriate application.
There's no need to actually have multiple interfaces and drivers or alternate configurations.
I think that's a cool idea. I will put that on my to-do list for later. |
|
Back to top |
|
|
mariusz.dec
Joined: 25 Feb 2009 Posts: 9
|
Posted: Wed Aug 05, 2009 7:41 pm Post subject: Remain AVR power for other tasks? |
|
|
Hi Ollopa,
I see great work. Congratulations!!!.
Currently I am working over the project where I need a lot of keyboards (up to 16) connected to the PC via Virtual Comm Port on USB.
Question is if in your solution there will be enough power to serve so many PS/2 keyboards while servicing USB?
I think that it will impossible, but I would like to be in "error state"...
Regards
Mariusz _________________ mdec |
|
Back to top |
|
|
ollopa
Joined: 03 Sep 2007 Posts: 233 Location: California
|
Posted: Thu Aug 06, 2009 1:25 am Post subject: |
|
|
mariusz.dec, I think you'd have problems with that. The AVR can spend up to 10ms in the USB interrupt. |
|
Back to top |
|
|
Netzman
Joined: 25 Nov 2005 Posts: 127 Location: Graz
|
Posted: Thu Aug 06, 2009 2:40 am Post subject: |
|
|
mariusz, what's about USB keyboards with some USB switches/hubs?
best regards |
|
Back to top |
|
|
mariusz.dec
Joined: 25 Feb 2009 Posts: 9
|
Posted: Thu Aug 06, 2009 7:57 am Post subject: |
|
|
Hi,
This is of course possible but I am working over multi kbd cross-platform solution for Java. I have to identify each kbd as well - this is quite complicated in any OS.
I have written very, very low lovel libraries for Windows, but I have no experience in Mac and Linux.
Therefore I need a black-box between kbd's and pure Java, WITHOUT any JNI interfaces.
I love Bascom and AVR and... everything clear .
Regards
Mariusz _________________ mdec |
|
Back to top |
|
|
ciplukz
Joined: 08 Aug 2009 Posts: 2
|
Posted: Sat Aug 08, 2009 6:37 pm Post subject: USB HID Mouse |
|
|
Hii ollopa...
I already bookmark this post...
What a great work anyway ^^,
Keep it work ollopa ^^
I'm currently working over my project for final assignment on my university. I want to develop a wireless 3D mouse by combining 3axis accelero+RF Trensceiver+AVR over USB protokol.
At first, i think by using FTDI chips for bridging to USB can help me to get my project done. but i got that its different between RS232 and USB protocol. Emulating USB as virtual com was not the solution, because i cant integrate my mouse to PC without custom driver The reason why Im using USB is for its versatile plug and play. But i cant get it by using FTDI.
I need to get my mouse work with the HID class on PC, but by emulating USB to RS232 i cant get it. And i also didnt allow to use AT90USB as the microcontroller.I've try vUSB anyway, but i still in learning curve on its since im new to C language. Basic is may fave language...
I develop my project by using ADXL335 + ATMega128 + Zigbee as the transceiver. But i still got difficulties to get my project access HID class over USB. Do You have any betas or release candidate for your work ollopa? Or, would You post any examples project about HID USB mouse using regular AVR?
Sorry for my bad english, Im Indonesian...
Thanks...
Best regards.. |
|
Back to top |
|
|
ollopa
Joined: 03 Sep 2007 Posts: 233 Location: California
|
Posted: Sat Aug 08, 2009 10:06 pm Post subject: |
|
|
ciplukz,
I'm leaving in a week so I will release something soon. I want to add support for other clock speeds before I do.
I'll try to do a HID mouse example. The joystick was very easy to do. What is the 3rd axis for, though? Scrolling? |
|
Back to top |
|
|
ciplukz
Joined: 08 Aug 2009 Posts: 2
|
Posted: Sun Aug 09, 2009 11:12 am Post subject: |
|
|
Thanks ollopa...
I'll be waiting for Your release...
Hmm.. 3 Axis Accelero are use for sensing tilt and motion of the mouse in x y, so in case this will subtitute the use of common optical mouse. z axis is used for reference motion sensing, for a smooth pointer movement. For scrolling i want to use optocouple to detect each scrolls...
Hopefully You would release an example codes for USB HID mouse soon, so i can used it as reference of my projects. Ill be waiting for Your release...
Thanks ollopa..
Good Luck ^^ |
|
Back to top |
|
|
|