• AVR Freaks

Helpful ReplyHow to create a composite HID device?

Author
Rajini100
New Member
  • Total Posts : 11
  • Reward points : 0
  • Status: offline
2011/03/22 02:03:03 (permalink)
0

How to create a composite HID device?

Hello friends,
                    I am able to develop a HID mouse and a HID keyboard. I want to merge them now, I mean both mouse as well as keyboard should work simultaneously. I have attached my code of HID mouse and HID keyboard. Can you suggest me how to go about it?

HID keyboard is presently 4x4 scan matrix. HID mouse is a joystick, and I have used ADC pins for conversion and mapping them into corresponding mouse movements. I have used PIC18F4550 for this purpose. Actually the code I have attached is downloaded from the internet. Here is the link to that site:-

http://sites.google.com/s.e/ytsnew/home/pic18f4550

The above site contains the changes required to make a composite device but it is not working.
Please refer that website for any more further details.

Thank you.

With regards,
Rajinikanth
#1
chinzei
Super Member
  • Total Posts : 2250
  • Reward points : 0
  • Joined: 2003/11/07 12:39:02
  • Location: Tokyo, Japan
  • Status: offline
Re:How to create a composite HID device? 2011/03/22 15:30:59 (permalink) ☄ Helpful
0

The above site contains the changes required to make a composite device but it is not working.

Did you test the zip file at the bottom of above site?
4550_Mouse_Key.zip
http://sites.google.com/s...Key.zip?attredirects=0

With quick look, this one seems fine, though I didn't run it yet.wink
The description on the web page may too short to follow it as is.

Anyway, this method is called multiple TLC (Top-Level Collection), not exactly a composite device. It is another way to realize two or more HID functions on single USB HID device. The point is that multiple TLC is simpler than HID composite device.

Tsuneo
#2
Rajini100
New Member
  • Total Posts : 11
  • Reward points : 0
  • Status: offline
Re:How to create a composite HID device? 2011/03/22 20:02:42 (permalink)
0
Thank you for your reply Tsuneo.

The information what you provided was new for me. I tried the code provided in the zip file but didnt work for me. I made the changes as provided in the website, but it is not working for me. Well, in fact the code provided in the zip file was already edited in accordance with the website.

I have read in the forum about this earlier in some topic but it was not completed, but I was able to make out that I need to go for two interface descriptors. I need to know whether is it the right way to go for it? If it is right, please guide me in this regard.

If you think we can go ahead and make some more changes in the code given in the website. Please suggest me what other changes should I do.

Thank you.

With regards,
Rajinikanth
#3
yts
Super Member
  • Total Posts : 601
  • Reward points : 0
  • Joined: 2005/09/06 17:45:30
  • Status: offline
Re:How to create a composite HID device? 2011/03/23 05:21:53 (permalink)
0
Thank you, Tsuneo, for teaching me that the method I have used is called a multiple TLC (Top-Level Collection). I will use this term, hereafter.

Hi. Rajinikanth;

4550_Mouse_Key.zip works well on my personal computer.

If it does not, please try to uninstall your PIC18F4550 device with VID 0x04D8 and PID 0x0000 from PC (personal computer), and reconnect to PC. In order to uninstall your device, USBDeview, which xiaofan has introduced us at http://www.microchip.com/...?m=562435&high=PID , is good.

I hope that someone uploads a firmware for a real(?) HID mouse + HID keyboard composite device for us.

#4
yts
Super Member
  • Total Posts : 601
  • Reward points : 0
  • Joined: 2005/09/06 17:45:30
  • Status: offline
Re:How to create a composite HID device? 2011/03/24 05:14:02 (permalink)
0
I confirmed that my firmware contained some bugs. Please wait for a while. I will fix it.
#5
Rajini100
New Member
  • Total Posts : 11
  • Reward points : 0
  • Status: offline
Re:How to create a composite HID device? 2011/03/25 04:12:40 (permalink)
0
Thank you for your reply yts.

I am looking forward for a corrected code soon from you.

By the way, can you let me know what are the bugs present in "main.c" file?

Was there something wrong with the descriptors?

Thank you.

With regards,
Rajinikanth
#6
yts
Super Member
  • Total Posts : 601
  • Reward points : 0
  • Joined: 2005/09/06 17:45:30
  • Status: offline
Re:How to create a composite HID device? 2011/03/25 06:03:03 (permalink) ☄ Helpful
0
>By the way, can you let me know what are the bugs present in "main.c" file?

Please replace
if(HIDTxHandleBusy(lastTransmission) == 0 && i==0) //552nd line from the top
with
if(i==0)
in main.c, or download 4550_Mouse_Key.zip again. I hope that this firmware works well.

Problem was the value of HIDTxHandleBusy(lastTransmission, that is, a busy flag.  The busy flag may be set just after Emulate_Mouse(). In this case, the keyboard data are ignored because of the sentence of “if(HIDTxHandleBusy(lastTransmission) == 0 && i==0)”.

#7
Rajini100
New Member
  • Total Posts : 11
  • Reward points : 0
  • Status: offline
Re:How to create a composite HID device? 2011/03/25 20:36:07 (permalink)
0
Thank you for your reply yts.

I tried the latest zip file of your site. There is some problem in the strategy I guess i.e mouse started to work and once it enters the  keyboard section, control stays there forever. The second observation is that sometimes the control stays is in the mouse loop forever.

I got this idea : Cant we use any interrupts of the PIC to enable the mouse section to work only when there is a change in the ADC value and disable the keyboard section? I think we can go ahead and try to implement this logic because a person most of the times does not use the mouse and the keyboard at once. So there has to be switching between the two devices keyboard and mouse.

Will there be any issue if we go ahead and use this logic?

Looking forward to hear from you.

With regards,
Rajinikanth
#8
yts
Super Member
  • Total Posts : 601
  • Reward points : 0
  • Joined: 2005/09/06 17:45:30
  • Status: offline
Re:How to create a composite HID device? 2011/03/26 05:47:30 (permalink)
0
Hello Rajinikanth;

>I tried the latest zip file of your site. There is some problem in the strategy I guess i.e mouse started to work and once it enters the keyboard section, control stays there forever. The second observation is that sometimes the control stays is in the mouse loop forever.

Thank you for your information. My firmware works well on some personal computer but it does not on the others. This means that the strategy is not good as you pointed out. Sorry about this. But I think that the firmware is enough to show you the possibility of a multiple TLC. I will solve this problem on the higher level.

>Cant we use any interrupts of the PIC to enable the mouse section to work only when there is a change in the ADC value and disable the keyboard section?

I cannot answer your question “now”. Please try to use. The trial and error is the best way to develop something new (including software), I think.

YTS
#9
Rajini100
New Member
  • Total Posts : 11
  • Reward points : 0
  • Status: offline
Re:How to create a composite HID device? 2011/03/26 21:17:44 (permalink)
0
Thank you for your reply YTS.

>But I think that the firmware is enough to show you the possibility of a multiple TLC.
  Yes, YTS. I have noticed it. For me, multiple TLC is a completely new concept and you have implemented very nicely.

> I will solve this problem on the higher level.
   I hope you get your strategy right soon.
   Looking forward for your corrected strategy.

>I cannot answer your question “now”. Please try to use. The trial and error is the best way to develop something new (including software), I think.
 Yes, YTS. I will definitely try using interrupts for merging mouse and keyboard. I will upload it if I get it working. But I am afraid that I might fail as I am not that experienced in using PIC mcs. But I will give my best.

Thank you.


With regards,
Rajinikanth
#10
yts
Super Member
  • Total Posts : 601
  • Reward points : 0
  • Joined: 2005/09/06 17:45:30
  • Status: offline
Re:How to create a composite HID device? 2011/04/02 23:22:57 (permalink)
0
I made a firmware for a composite devise (HID keyboard + HID mouse) for PIC18F4550.

This firmware totally depends on the following posts .
chinzei and MDreamer: http://www.microchip.com/...525&high=composite
Pic_worker34 and chinzei: http://www.microchip.com/...319&high=composite
chinzei: http://www.microchip.com/...=composite&mpage=2
Thank you very much for these persons.

#38 pin is pulled up by the firmware. When you contact this pin to GND, characters would appear ( chattering may occur). Mouse cursor draws a circle.

I started from "USB Device - HID - Mouse - C18 - PICDEM FSUSB" to make the firmware. The lines I changed are indicated by //YTS.

 
post edited by yts - 2011/04/04 23:25:32
#11
yts
Super Member
  • Total Posts : 601
  • Reward points : 0
  • Joined: 2005/09/06 17:45:30
  • Status: offline
Re:How to create a composite HID device? 2011/04/03 00:53:34 (permalink)
0
The above firmware works when I connect PIC  to PC via HUB. But it  does not work when I connect PIC directly to PC.  Sorry about this. Does anyone know the reason why ?


post edited by yts - 2011/04/03 01:24:01
#12
m_gray
Starting Member
  • Total Posts : 39
  • Reward points : 0
  • Joined: 2010/06/15 03:14:34
  • Location: Lille, France
  • Status: offline
Re:How to create a composite HID device? 2011/04/03 08:13:44 (permalink)
0
@ YTS This might actually a hardware design mistake. The denominations of the PIC USB input is leading to a confusion most of the time.
I had the exact same problem, if I remember correctly, it has to do with the VUsb pin, that has to be connected to 3.3 V and not 5V.

In case it comes from the firmware, I know I had some timing issues at startup switching from XP to Seven; meaning that I had to wait until the USB is connected before doing my check-up routine.

Hope this helps.
post edited by m_gray - 2011/04/03 08:17:56

--
Paul

** www.tildesign.com ** (under construction)
** my blog **
#13
chinzei
Super Member
  • Total Posts : 2250
  • Reward points : 0
  • Joined: 2003/11/07 12:39:02
  • Location: Tokyo, Japan
  • Status: offline
Re:How to create a composite HID device? 2011/04/03 08:59:36 (permalink)
0

The above firmware works when I connect PIC  to PC via HUB. But it  does not work when I connect PIC directly to PC.

You've posted the schematic on your first post.
http://sites.google.com/s.e/ytsnew/home/pic18f4550

It seems self-powered configuration, supplied from JP3.

If you didn't change your circuit, try these tests.
a) Power up the PIC after connecting USB to the PC / hub port.
OR
b) Make the PIC bus-powered - ie. supply from USB VBUS (5V) pin.
- also, add around 10uF capacitor across VBUS and GND.

Tsuneo
#14
yts
Super Member
  • Total Posts : 601
  • Reward points : 0
  • Joined: 2005/09/06 17:45:30
  • Status: offline
Re:How to create a composite HID device? 2011/04/03 21:39:33 (permalink)
0
Thank you very much, m_gray and Tsuneo. Please keep suggesting me. Your suggestions are very helpful and important for me. I can watch the problems from another point of view.

I have made a mistake. I should have removed the USB information stored in PC for VID/PID (0x04D8/0x0000). As I used the same VID/PIC that I used before, I could not connect PIC to PC. After removal of the information, the connection succeeds in Windows XP professional SP3 at least. When I connected PIC to PC via HUB, another VID/PID might be assigned (or some other reason) and the connection succeeded, I guess.

Hello m_gray;
************************************
In case it comes from the firmware, I know I had some timing issues at startup switching from XP to Seven; meaning that I had to wait until the USB is connected before doing my check-up routine.
************************************
You are right. The waiting is sometimes needed.


Hello Tsuneo;
************************************
If you didn't change your circuit, try these tests.
a) Power up the PIC after connecting USB to the PC / hub port.
OR
b) Make the PIC bus-powered - ie. supply from USB VBUS (5V) pin.
- also, add around 10uF capacitor across VBUS and GND.
************************************

I have not tried these tests yet. Though I (hardware) reset PIC, the problem was not solved (before removing the information of PID/VID).
 

post edited by yts - 2011/04/03 22:02:07
#15
Jump to:
© 2019 APG vNext Commercial Version 4.5