Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Virtual USB-port for AVR
Goto page Previous  1, 2, 3, 4 ... 20, 21, 22  Next
 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
ollopa

Bascom Member



Joined: 03 Sep 2007
Posts: 233
Location: California

usa.gif
PostPosted: Sun Aug 02, 2009 4:07 pm    Post subject: Reply with quote

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 Very Happy

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" ) Wink
Back to top
View user's profile
Netzman

Bascom Expert



Joined: 25 Nov 2005
Posts: 131
Location: Graz

austria.gif
PostPosted: Sun Aug 02, 2009 4:21 pm    Post subject: Reply with quote

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
View user's profile Visit poster's website
ollopa

Bascom Member



Joined: 03 Sep 2007
Posts: 233
Location: California

usa.gif
PostPosted: Sun Aug 02, 2009 5:12 pm    Post subject: Reply with quote

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
View user's profile
Netzman

Bascom Expert



Joined: 25 Nov 2005
Posts: 131
Location: Graz

austria.gif
PostPosted: Sun Aug 02, 2009 5:20 pm    Post subject: Reply with quote

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
View user's profile Visit poster's website
vbb_77

Bascom Member



Joined: 24 Apr 2009
Posts: 14

germany.gif
PostPosted: Sun Aug 02, 2009 10:41 pm    Post subject: Reply with quote

>>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
View user's profile
ollopa

Bascom Member



Joined: 03 Sep 2007
Posts: 233
Location: California

usa.gif
PostPosted: Mon Aug 03, 2009 12:39 am    Post subject: Reply with quote

vbb_77,

The name is "Windows Driver Kit" or WDK.
http://www.microsoft.com/whdc/devtools/wdk/default.mspx

Sign up for free over here http://www.microsoft.com/whdc/win7/default.mspx
Then you can log in to MS Connect and download the latest beta version of WDK for Windows 7. You can also get it off of bittorrent if you know where to look.
Back to top
View user's profile
Netzman

Bascom Expert



Joined: 25 Nov 2005
Posts: 131
Location: Graz

austria.gif
PostPosted: Mon Aug 03, 2009 3:47 am    Post subject: Reply with quote

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
View user's profile Visit poster's website
ollopa

Bascom Member



Joined: 03 Sep 2007
Posts: 233
Location: California

usa.gif
PostPosted: Mon Aug 03, 2009 5:10 am    Post subject: Reply with quote

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
View user's profile
mariusz.dec

Bascom Member



Joined: 25 Feb 2009
Posts: 9

poland.gif
PostPosted: Wed Aug 05, 2009 7:41 pm    Post subject: Remain AVR power for other tasks? Reply with quote

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
View user's profile
ollopa

Bascom Member



Joined: 03 Sep 2007
Posts: 233
Location: California

usa.gif
PostPosted: Thu Aug 06, 2009 1:25 am    Post subject: Reply with quote

mariusz.dec, I think you'd have problems with that. The AVR can spend up to 10ms in the USB interrupt.
Back to top
View user's profile
Netzman

Bascom Expert



Joined: 25 Nov 2005
Posts: 131
Location: Graz

austria.gif
PostPosted: Thu Aug 06, 2009 2:40 am    Post subject: Reply with quote

mariusz, what's about USB keyboards with some USB switches/hubs?

best regards
Back to top
View user's profile Visit poster's website
mariusz.dec

Bascom Member



Joined: 25 Feb 2009
Posts: 9

poland.gif
PostPosted: Thu Aug 06, 2009 7:57 am    Post subject: Reply with quote

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 Smile.
Regards
Mariusz

_________________
mdec
Back to top
View user's profile
ciplukz

Bascom Member



Joined: 08 Aug 2009
Posts: 2

indonesia.gif
PostPosted: Sat Aug 08, 2009 6:37 pm    Post subject: USB HID Mouse Reply with quote

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 Sad 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
View user's profile
ollopa

Bascom Member



Joined: 03 Sep 2007
Posts: 233
Location: California

usa.gif
PostPosted: Sat Aug 08, 2009 10:06 pm    Post subject: Reply with quote

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
View user's profile
ciplukz

Bascom Member



Joined: 08 Aug 2009
Posts: 2

indonesia.gif
PostPosted: Sun Aug 09, 2009 11:12 am    Post subject: Reply with quote

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
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Goto page Previous  1, 2, 3, 4 ... 20, 21, 22  Next
Page 3 of 22

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum