V-USB Circuit works on breadboard, but not on Veroboard?

Go To Last Post
23 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm building an HID Joystick with V-USB and an AtMega8-16PU (not AtMega8A).

I'm using 2 diodes in series between incoming +5v and my circuit's power rails to drop the voltage (but I'm wondering, would just using a 3.3v regulator be better? I didn't see much explanation as to why these diodes are needed but they work in the breadboard...)

I have a 12 MHz Oscillator, 2 x 68-ohm resistors (D+ to PD2/INT0, and D- to PD4), and the 1.5k pull-up on the other side of the 68 ohm resistor for D-.

A couple of random caps (ceramic and polarized) to provide steady power to the device.

I have internal pull-ups turned on for all IO pins except for PD2/PD4 which I let V-USB manage. (I'm making an arcade style stick, this approach lets me just wire up two wires to each button so that pressing one just shorts it to ground -- this works on the breadboard...)

I've checked and double checked all traces with a multimeter, Ive tried cutting the pathes of D-/D+ to be super short (and the crystal's path as well)...

I've examined the circuit under a 10x monocle...

I redid the circuit on verboard with a different layout, previous was stripboard, this one is sets of 3 pads, with bus lines running between them (very similar to breadboard...) from radio shack, again, same results.

I can program the device in these circuits, and verify them, but when I plug them into the PC, they don't even give meaningful error data, just a simple "Hey, this thing don't work, unplug it already."

I considered that I may have heat damaged the Oscillator, and screwed up it's timing or something -- so I unsoldered it, plugged it into my breadboard and tried, and the damn thing worked -- I've tried multiple chips, plug them into breadboard, they work, plug them into soldered circuit, they program and pass all the tests, but V-USB fails...

I feel like there must be some n00bism that I'm screwing up, but what is it?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you are not using the same Atmega8, did you perhaps forget to change the fuse settings?

I assume you hae a real 12MHz oscillator and not a crystal, if it is a crystal, then keep in mind dat those cheap experimantal boards have a terrible capasitive load. I once made a 8MHz crystal run at exactly 8MHz without using an external cap. So perhaps your 12MHz is de-tuned(if crystal ofcoarse)

It might be a grounding problem, or still even a supply problem. If your Mega8 does not answer fast enough after setting the 1K5 pull-up then the PC also could reject it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm setting the fuses properly, it's part of my programming routine -- also same chips work in the breadboard but not in the soldered board...

Low is 0xBF, High is 0xC9. This gives it the full 64 ms stabilization time for the oscillator.

As for crystal vs non-crystal, I thought crystal was the highest accuracy timing component, am I mistaken?

This is the part I am using:
https://www.sparkfun.com/product...

I've unsoldered one from one of my boards and put it in the breadboard (never before inserted into breadboard) and it seems to be working. I have 10pf caps between each leg and ground -- but their presence doesn't seem to matter at all in the breadboarded circuit...

Are you saying the value of the capacitors I use on the crystal is important? Since I give it 64 ms to start up (via fuses), shouldn't it just start off rocky and then slowly stabilize?

If I can't match the value exactly, should I go over or should I go under? or should I just try to get as close as possible?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well damn. Some major good news, but bottom line: problem persists.

I did some digging on V-USB website and found a couple of projects that used the internal R/C at 8 MHz plus "tuning" to get it really close to 12.8 MHz (within tolerance) -- the code works, in my breadboard I can now remove the oscillator all together (freeing up two additional I/O pins and reducing my part count. It takes a little longer to show up in the enumerator, but so what...)

I flash the same fuses/program to one of the chips plugged into a board (it still has the oscillator soldered down, but the fuses turn that into an IO port so that should be okay... tested on the breadboard, seems fine....) -- but it does the same damn thing... no love.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I suggest that you use a proper 3.3V regulator chip if you want to produce 3.3V.

The standard V-USB schematic allows your AVR to run at 3.3V - 5V while the clamp zeners keep the D+, D- lines within spec.

If you know your load current, using diode Vak junction voltage drops is fairly effective. But first off, you need to look up those Vak curves. You will be surprised at how low the drop is for small currents.

The same applies to the zeners on the D+, D- lines. Look up the voltage-current curves for your part number.

All the same, most AVR crystal oscillators will work fine on a breadboard, stripboard or whatever. Ideally you use short wiring, avoid stray capacitance, noise etc.

V-USB will work with a calibrated RC oscillator. I would only advise it for a hobby project.

I suspect you have some very messy soldering.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Mikey83 wrote:
I'm using 2 diodes in series between incoming +5v and my circuit's power rails to drop the voltage
All of my V-USB HID projects and experiments use a design similar to the 'redKontroll' HID project, linked from the V-USB HID projects page. In other words, I use two 3.6V Zener diodes which tie the USB D+/D- lines to ground. FWIW, I successfully use 22 pF capacitors on my 12 MHz crystal (which is essentially the same as the Sparkfun one you linked to) on both my breadboarded V-USB projects and on my PCB-based V-USB projects.

My suggestion would be to try using one of the USB interface designs that use 3.6V Zener diodes or one that uses a 3.3V regulator (whichever is easier / quicker / cheaper for you).

Short version of a long story, in case it helps: I once found that use of 3.3V Zener diodes with a breadboarded ATMega16 V-USB HID project worked fine for months but when I created the identical circuit on another breadboard, simply switching from the ATMega16 to an ATMega168, it was incredibly unreliable until I swapped the two 3.3V Zener diodes for two 3.6V Zener diodes.

One of these days, just for fun, I will have to try that '2 ordinary diodes in series' technique to see how functional/reliable it is.

Hope some of that helps a little....

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

From http://www.vishay.com/docs/81857/1n4148.pdf data sheet, the Vf is 500mV @ 100uA, 600mV @ 1mA, 750mV @ 10mA, 900mV @ 100mA.

A 1N4001 1A rectifier is not specified at very low currents but the 10mA / 100mA values are roughly 700mV / 750mV.

In fact regular PN junctions have almost the same voltage transfer curves at low currents. It is only at high currents that the resistance becomes significant.

If you intend your AVR consumption to be a steady 10mA e.g. no sleeping, two diodes of any type will drop you 1400mV or so. However you want to drop 1700mV to produce 3.3V ----- so two is too little and three is too much.

Three diodes @ 1mA is roughly 1800mV and a pretty good match.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Upon further thought, assuming he's using the circuit at the bottom of this page, I don't think the OP should use any "2 (or 3) diodes in series" technique to drop the voltage to 3.3V.

The only (non-'A' variant) ATMega8 datasheet that I have shows that it requires a 4.5-5.5V supply.

So, basically, my recommendation is still the same. :smile:

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

But that circuit basically drops the 5V to 3.6V via those two diodes. Providing the ATtiny2313 is always taking 10mA or so, you get 3.6V. The whole caboodle runs at the 'dropped' voltage eliminating any concerns of level-shifting. However some older AVRs cannot run at 12MHz with less than 4.5V.

This is the absolute limit for D+, D- in the USB spec. If the AVR does not take enough current, you violate the USB spec.

The OP says that he is using an ATmega8. This is supposed to run at 5V if you use a 12MHz crystal.

So you would use the standard V-USB schematic with zeners clamping the D+, D- lines.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:
The OP says that he is using an ATmega8. This is supposed to run at 5V if you use a 12MHz crystal.
That was my entire point :!: Unless I'm missing something, it seems like the bulk of your post is just reiterating what I said. :?

In fact, my data sheet shows that the non-A variant of the ATMega8 requires 4.5-5.5V at any/all clock speeds.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

My Vusb has a 2k2 connected up to Vcc from PB0. I also use 2 x 3.6V zeners across INT0/PB0 to ground. Then I can run from 5V.Not tried to build it at 3v3 but I suspect a mega8 won't like running at12M @3v3....
Also running in int. RC is gonna fall over sooner or later.It's chronically unstable even for driving UARTS, let alone the super critical timing in VUSB
Maybe a HID doesn't need the 2k2 ?
PS this is using Mega8....

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

meteor wrote:
Upon further thought, assuming he's using the circuit at the bottom of this page, I don't think the OP should use any "2 (or 3) diodes in series" technique to drop the voltage to 3.3V.

The only (non-'A' variant) ATMega8 datasheet that I have shows that it requires a 4.5-5.5V supply.

So, basically, my recommendation is still the same. :smile:

Yes, I was using that circuit. Running the chip at the correct voltage and doing the level conversion with 3.6v Zener diodes (NTE134A) did the trick. It now works in BOTH the breadboard AND the stripboard.

Meteor, you're my mother fucking hero. Just wish I'd asked for help sooner! This board has seen so much rework, and solder removal, about half the strips have a fine silver coating now -- and my poor AT Mega has been pulled and reinserted so many times one of his pins broke off! :(

I patched him up good as new though with the lead from a clipped resistor. :D

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Glad to hear that you got it working! V-USB can be tricky sometimes, as I indicated with my previous story about 3.3V versus 3.6V Zener diodes. (BTW, I've been successfully using 1N747A [3.6V] Zener diodes, for anyone else interested in V-USB circuits.)

Mikey83 wrote:
I patched him up good as new though with the lead from a clipped resistor. :D
Clever repair! And here I thought I was the resident "cheap bastard". :wink:

And thanks for following up with your final results. (A lot of posters here fail to do so and it often adds to the frustration of those providing help.)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Here's a gallery of the semi-final results, it's all working great, but for the moment I've ripped it back apart to do some wood filling, sanding & painting, anyways, thanks again guys (esp meteor!), I appreciate the help. :-)

http://www.flickr.com/photos/brainslugs83/sets/72157629322069325/


Edit: FYI, I ended up using the second board (the radioshack perf board one, not the bigger veroboard one) but that IS the rescued ATMega8, very proud of that save! (heh, I was so ecstatic with how good it turned out I rushed to show it to my girlfriend, who looked at the chip cocked and eyebrow and went back to her Facebook with a "That's nice honey.")

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Mikey83 wrote:
Here's a gallery of the semi-final results
Cool project! Thanks for sharing the photos. It reminds me of Rob 'CmdrTaco' Malda (of Slashdot fame) and his MAME cabinet project.
Mikey83 wrote:
but that IS the rescued ATMega8, very proud of that save! (heh, I rushed to show it to my girlfriend, who looked at the chip cocked and eyebrow and went back to her Facebook with a "That's nice honey.")
Why, oh why can't those mysterious beings with 2 'X' chromosomes seem to appreciate the finer things in life? :D

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

meteor wrote:
Cool project! Thanks for sharing the photos. It reminds me of Rob 'CmdrTaco' Malda (of Slashdot fame) and his MAME cabinet project.

Yeah, the homebrew MAME cabinet scene is what inspired me to make my joystick -- been wanting to make a whole cabinet for a long time (10 years at least...) but it just seems like a huge investment (space, time, parts... I don't mind buying a screen for it, but I mind sacrificing one to it permanently, you know...? -- and again, space, where the heck would I put the thing... let alone build it! :shock:)

So this is my little "as close as I plan on getting" for now.

meteor wrote:
Why, oh why can't those mysterious beings with 2 'X' chromosomes seem to appreciate the finer things in life?
Tell me about it! She was all excited about me building a reprap until I started building it... now it's just "when are you going to get that thing out of the living room?" -- at least she likes the joystick though... for now. XD

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

EDIT: What the ....? The post I'm replying to seems to have been deleted in the interim. Arrgggghhh!!!

Metalsutton wrote:
Sorry for the Thread revive, but I am experiencing the exact same problem. V-Usb, works on breadboard, not on stripboard. [...]
It looks to me like your stripboard schematic is not right. It shows Vcc and GND on MCU pins 8 and 9, not 7 and 8.

Having said that, a cursory inspection seems to show that you wisely didn't make the same mistake on your actual wiring. :) But with that mistaken stripboard diagram, it's making it slightly harder to cross-check things (not to mention calling into question your attention to detail :wink:).

And, just to be sure, are you using an ATMega8 or some other 28-pin MCU? And are you using the same physical MCU in the breadboard as you are in the stripboarded circuits (i.e. thereby removing fuse and firmware issues)?

As for the USB portion of that reference circuit, I successfully use a very similar design with one of my V-USB circuits, so I'm not as convinced as you seem to be that the design is wrong, at least not without further evidence.

My working ATMega168 V-USB circuit (made into a PCB) has the following differences (which may or may not be important):

  • I use 2.2k-ohm (not 1.5k-ohm) for the USB 'D-' pullup resistor
  • I use 82-ohm (not 68-ohm) resistors on the USB data lines
  • I use 22 pF (not 27 pF) capacitors for the 12 MHz crystal
  • I keep the 10 uF capacitor close to the USB connector, not the MCU
  • I use a 0.1-uF capacitor near MCU Vcc/GND pins
Are you sure your Zener diodes are all good?

You may want to isolate debugging to specific portions of the circuit. For example, try flashing an LED using that 12 MHz crystal to be sure that your system clock is correct. Divide and conquer, as the saying goes.

Oh, and the fact that you flipped your "A" and "B" boards along different axes when taking the top and bottom photos isn't helping! :wink:

If I see (or think of) something else, I'll jump in again, but right now, I'm out of ideas. Hope some of what I've said is helpful....

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What's your experience so far, is V-USB fast/reliable enough to handle all those furious button presses in Metal Slug?

The Dark Boxes are coming.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Svofski: I'm not sure if your question was directed at me or Mikey83, but my V-USB circuit is not used in a MAME situation, so I have no useful feedback on "furious button presses". In my case, buttons like "autopilot disconnect" and "GPS display zoom/unzoom" just aren't ever that furious. :wink: Having said that, I've had no complaints about V-USB's performance or reliability so far. Hopefully Mikey83 will see this and give you some useful feedback.

To the rest of the people who wonder what happened with my previous out-of-the-blue post in this thread:

'Metalsutton' posted with his problem asking for help and referring to this description, with photo links, on reddit. Before I had a chance to post my detailed reply (above), he apparently fixed his problem, posted a message to that effect on reddit, and deleted the post he'd made here. :evil:

Ignoring any time I spent trying to decipher his wiring and posting my suggestions (above), I find it mildly annoying that, having learned what was broken in his circuit, he simply deleted his post here rather than posting about the solution, for others (myself included) to learn about.

So, to summarize and conclude: Metalsutton used a V-USB circuit with a 1.5k-ohm pullup resistor on the USB 'D-' line, based on this NES/SNES adapter project by Raphaël Assénat. Mettalsutton's wiring of this project worked on the breadboard but not when he soldered it onto either of 2 stripboards. As it turned out, it seems to have started working when he swapped the 1.5k-ohm pullup resistor for a 2.2k-ohm resistor, which is what someone on reddit had suggested and was also the 1st difference (mentioned in my post above) between my working V-USB circuit and his non-working one.

I hope that my documenting this solution will prevent any future V-USB users who might happen to use that circuit from running into the same problem.

Metalsutton: Since you get help on this forum, please be sure to return the favor in the future by providing feedback and documenting your problems' solutions with a post.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@meteor: my question was directed to Mikey83. I once built a MAME control board like his, but it was in the days when I barely knew how to hold a soldering iron and I just rewired an existing keyboard controller. My personal V-USB experience is limited to a CDC device (it's a clock that sits on USB port and to set it up you access it via terminal), and I have noticed that V-USB, when active, takes quite a lot of CPU cycles. So I'm curious about responsiveness of the console: in arcade games a smallest lag can ruin all the fun.

For the record, in my circuit I used ATmega8 at 5V, 2k2 pullup to +5V on D-, 3.3V zeners and 100Ω resistors between D+,D- and AVR pins.

The Dark Boxes are coming.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi all,

Sorry I only just checked this topic after a few days. It has only come to my attention that someone had replied to my post (and a lengthy one at that), I seem to have been misrepresented as a person that doesn't value good honest help and I assure you this is not the case. I thank you for your help with this.

However after my problem was solved by swapping a single resistor I instantly came back here to remove my post before anyone spent their time to reply. When I came back to remove the comment there was no replies (I had literialy posted it on Reddit only a few hours before here), and this is proven because there is no way to delete out a post unless it is the very most recent post on a thread. So maybe I had deleted it as you were replying.

I am sorry if this is the case and I do appreciate your help, it was just bad timing from both sides, and I was a little late to check back here only because I thought the post didn't exist anymore, so noone would have replied to it.

Sorry for the trouble involved! If anything I shouldn't have tried to source help from multiple communities.

EDIT: Oh, and you are the only person who has pointed out to me (now that I have seen this post!), that the schematic that I drew in Powerpoint is wrong! How did I not pick up on that?!? I may have rushed that drawing and thats something I should not have done. So even though a few people did offer advice over IRC, Reddit and here, your post was definaly the most helpful of them all :) I just wish I saw it before the others!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Please note that my point is the same even if nobody had replied to your post or spent any time analyzing your problem: It would have been helpful if, after posting about your problem, you had posted about the solution. Even if you'd simply left your original post and added a 1-line follow-up post saying: "Solved -- see Reddit link." that would have been better. That way I and any future readers of the thread can learn something.

And please don't take my previous words (or my "evil" icon) too seriously. I don't mean to sound intimidating or mean. I just would prefer that this information is shared to the widest extent possible. When I first found out about AVRFreaks, I learned a ton simply by reading old threads. As such, when I make a post, I generally try to load it with as much information as possible (including useful URLs where pertinent), especially information that would aid someone in the future who takes the time to search before asking. Those searchers should be rewarded for their efforts. In fact, you are one of those people because you presumably found this thread while searching about your own issue.

Metalsutton wrote:
(...) it was just bad timing from both sides, (...)
Agreed. No hard feelings here. :)

All I'm saying is, in the future, please don't cheat me (and future thread readers) out of the chance to learn something new. I'm dumb enough as it is. :)

Regards,
Bill

EDIT: re: your edit :) Glad you found some value in my earlier post. Again, no hard feelings here.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I thought I was causing more issue by reviving an old thread on a subject that someone had already solved, just for me to revive and post a similar fix that was mentioned before then.

I'm new here and usually use forums where reviving dead and buried threads is usually frowned upon. I forget about the knowledge searchers such as myself... i'll learn eventually.