v-usb with atmega328p/attiny85 disconnections

Hello everyone,

I have made 2 usb IR receivers to control my Gnu/Linux computer with a standard IR remote.
Those devices use the library v-usb from https://obdev.at/products/vusb/index.html

The first one I made uses an attiny85 uC and I even wrote an instructable:

The second one I made uses an atmega328p uC since I needed extra gpio to control an IR led that I installed to turn off/on the TV.

Both used to work pretty well for months, but then I started having random disconnections from both remotes (it could be after upgrading the operating system, but I am not sure about that).
Now it happens that the devices work well for a random amount of time, then they become not responsive and I need to pull out the device and plug it in again.

lsusb before and after the device becomes not responsive shows up no difference at all (it seems always connected)
dmesg or direct inspection of /var/log/syslog do not evidence any state change at all.

My configuration has decoupling filter caps for the usb power lines (10uF and 0.1uF), 2 zener diodes (3.6V .05W) and the 68R resistors.
This is the schematics that I used for the attiny85 version:
https://cdn.instructables.com/FIK/5Z54/IYV9IWTR/FIK5Z54IYV9IWTR.LARGE.jpg?auto=webp&width=792
The atmega328p version is pretty much the same.

This is the code for the attiny85 version:

This is the code for the atmega328p:

It is like those devices fall in some kind of suspended mode, but I do not know how to get them up and running.

I really hope that someone could give me a hand with this issue, this is a very interesting project in which I have invested a big amount of time and I see lots of uses for it.

Thanks in advance.

Have I got this right?
Your attiny/atmega328p systems interprets IR signals and, by emulating a USB keyboard, send corresponding data to, say, a Linux system.

The classic arduino chip for such a use would be the atmega32U4 which has a built-in usb interface.

If both your devices exhibit the same behaviour, and this has happened recently, it may be that the USB interface on your Linux system does not now (as a result of an upgrade as you have suggested) like what you are doing. I guess you have isolated the problem to the usb driver part of your development and been able to exclude the IR part.

Thanks for your response.
You got it right, I have considered using the atmega32U4, as you suggested that is the optimal solution.

It so happens that I have many atmega328p and attiny85 as I use them in many projects and they are very cheap unlike the atmega32U4.
I'm also very fond of those two microcontrollers and I would like to solve the issues that I've encountered before giving up and look up for another micro.

I'm not really sure what is happening with those devices though, until yesterday I thought that the usb part was the main issue, but then I attached an FT232RL to monitor the serial port and I have noticed that when the device become not responsive, it starts to send garbage through the serial port.
That got me thinking that maybe there was something else with the micro and I thought that as a temporary solution I could use the watchdog timer to reset the board after an specific amount of time.
I don't really like this because I still do not comprehend what is going on with the board, but at the end of the day it is a dirty solution that seems to work.

I look forward to any other ideas or suggestions :slight_smile:

About to give up.
Even with the periodic board reset the device failed. It's very odd, the whole board becomes not responsive, not only the usb part, I have installed also an infrared led to turn on/off the tv and that do not work also once the board fails.

Usual suspect from a software perspective for unexpected crashes is memory problems.
2)
From a hardware perspective, I would suspect power problems.

As you did not post schematics or code it's difficult to judge.

Any pointers in dmesg as to happens with the port when your device fails?

I've seen USB devices fail in ways that seem to require that the upstream hub be reset (power-cycled) before they re-appear to the host. And those were proper USB hardware, not the V-USB hack (which seems to be less-and-less compatible with hosts as time goes by.)

sterretje:
1)
Usual suspect from a software perspective for unexpected crashes is memory problems.
2)
From a hardware perspective, I would suspect power problems.

As you did not post schematics or code it's difficult to judge.

Any pointers in dmesg as to happens with the port when your device fails?

This are the schematics for the atmega328p version:

This are the schematics for the Attiny85 version:

https://cdn.instructables.com/FIK/5Z54/IYV9IWTR/FIK5Z54IYV9IWTR.LARGE.jpg

I'm no sure it is a hardware issue since both devices worked flawlessly in the past. I also attached an external led to monitor power failures, but the led stays always on, even after the device becomes not responsive.

westfw:
I've seen USB devices fail in ways that seem to require that the upstream hub be reset (power-cycled) before they re-appear to the host. And those were proper USB hardware, not the V-USB hack (which seems to be less-and-less compatible with hosts as time goes by.)

Power cycling the usb port could be a solution (I tried with a board reset but it didn't work).
Anyway, I have lost the confidence in this device since I see no future for them.

At the end I have bought an atmega32u4 and with a minimal change in my sketch, one 100 Ohm resistor, one IR led and the TSOP31238, I have my remote working again. Not too funny as a project but works very well.

Thanks all for your kind help.

Hi,

very interesting project. But I'm wondering how it was possible to compile the V-USB libraries with the latest Arduino IDE - I will get always errors ... Do you have modified the Arduino V-USB libraries too?

hwhardsoft:
Hi,

very interesting project. But I'm wondering how it was possible to compile the V-USB libraries with the latest Arduino IDE - I will get always errors ... Do you have modified the Arduino V-USB libraries too?

Yes, first of all you need to download the library for arduino:

https://code.google.com/archive/p/vusb-for-arduino/downloads

Then you need to modify a few files, follow the step 5 of this instructable:

Those modifications were made to be compatible with the attiny85, but it works also for atmega328p.