Show Posts
Pages: 1 [2]
16  Using Arduino / Microcontrollers / Duplicating chips with USBasp? on: July 31, 2012, 12:56:33 pm
So I'm about to make a small production run of a kit project, and I find myself wondering what the best way to go about duplicating the chips will be.  So far it has been fairly straightforward if tedious - burn optiboot on to the chip, then use optiboot to load the compiled hex through the Arduino interface through a FTDI cable.  It works, but it's no good for shipping a bunch of copies around to friends and family.  I have a USBasp available, so I'm suspecting that if I do something like this with the master chip:

Code:
avrdude -c usbasp -p m328 -U hfuse:r:hfuse.hex:i
avrdude -c usbasp -p m328 -U lfuse:r:lfuse.hex:i
avrdude -c usbasp -p m328 -U efuse:r:efuse.hex:i
avrdude -c usbasp -p m328 -U flash:r:flash.hex:i

I'll get 4 files that contain the contents of the master.  Once I have those files, can I just drop them on a fresh chip with something like:

Code:
avrdude -c usbasp -p m328 -U hfuse:w:hfuse.hex
avrdude -c usbasp -p m328 -U lfuse:w:lfuse.hex
avrdude -c usbasp -p m328 -U efuse:w:Efuse.hex
avrdude -c usbasp -p m328 -U flash:w:flash.hex

Or am I missing something simpler?  Or is it more complex than that?  I'm just starting to step out of the Arduino toolchain, so any assistance would be greatly appreciated!
17  Using Arduino / Programming Questions / Re: DS1307 reading time on: July 02, 2012, 11:15:23 am

I use this https://github.com/davidhbrown/RealTimeClockDS1307 library and am very happy with it, though I'm not so happy with the accuracy of the DS1307 (mine looses 7.6 seconds per day but have found a clunk way to improve it).

Yeah, I've mucked around with a bunch of them, and that's the one I eventually settled on as well.  The DS1307 library that Adafruit uses (forked from JeeLabs) is a decent start, but I seem to remember running into limitations fairly quickly.  IIRC the time setting code was weird?  It's been a while.

The DS3231 is nice and relatively straightforward plugin replacement for the 1307, but depending on your budget, the 1307 and supporting crystal/battery/etc can be had for under $2.  If you're designing a new PCB, swapping a TH 1307 for a SMD 3231 is no big deal, but if you need to adapt it to protoboard and have to buy a $15 Chronodot or similar, the price differential starts to add up.  The 1307 is accurate enough for most applications.  Within reason.
18  Using Arduino / Programming Questions / Multiple independent libraries? on: July 01, 2012, 11:58:53 pm
So, if I want to keep a library local to the code (say I adjusted BUFFER_SIZE in twi.h and BUFFER_LENGTH in Wire.h because whoo-eee, they were using ~10% of the 328's ram in buffers if I'm reading the object dump correctly), is there a convenient way to have the compiler _only_ use the library defined in the #include, without descending into the standard libpath?  Right now if I do something like copy Wire.h local to the sketch and

#include "Wire.h"

versus

#include <Wire.h>

The compiler seizes up on duplicate object definitions & other similar complaints because Wire.h is in the libpath twice, I imagine.

More generally I find myself having libraries scattered around with my code because more often than not I end up tweaking one thing or another and I can't generalize it out.  Jimmie Rodger's Charliplexing library, for example.  Every array ends up needing a different ledMap, so Charliplexing.cpp and Charliplexing.h end up duplicated in every single source directory which is messy and hard to maintain at best.

At worst, since I trimmed the HardwareSerial buffers to free up space for my current project (memory is at a bit of a premium), some sketches like ArduinoISP just mysteriously fail to work until I remember my edit and revert it for ArduinoISP.  If I could duplicate HardwareSerial and keep the changes local to the sketch that depends on smaller buffers while other sketches used the system default, I'd be in heaven.

Or does this end up being one of those things that ends up forcing a transition from the Arduino environment and into a more traditional Makefile/compiler/linker process?

I've looked around http://www.arduino.cc/en/Hacking/BuildProcess and it basically confirms what I'm experiencing.  Ultimately, I guess the question is whether there's any way to declare the libraries that reside with the sketch to be the official ones (for that sketch, obviously), and to ignore everything in the outlying path?
19  Using Arduino / General Electronics / Re: USB Powering projects on: May 21, 2012, 10:52:03 am
Quote
1) A PTC acting as a fuse in series to prevent a short from cooking off my USB port.

This makes people feel better but in practice it doesn't help as much as you think. PTC's are very "loose" devices and a 500mA PTC won't trip until about 1A or so. The Bourns MF-MSMF050 says it will take 0.15 seconds to trip at 8A -- that's more than enough time to cook the USB port.

Well, my feeling is that it's also intended to protect the project in the event the USB power source isn't fused.  Thirty cents of insurance, anyway.

Quote
Quote
2) A cap bridging 5V and GND to smooth out the load.

That's fine too, but don't go too high else the inrush current that occurs when you first plug in might just look like an overcurrent event to the PC.


Ah, good point.

Quote

Of bigger concern is that you are not supposed to draw more than 100mA from a USB port when you plug in, until the "USB chip" on your board (none for yours, but PC's expect that there is one) enumerates and identifies the board as needing 500mA. Again, you might get the nasty dialog message telling you you're drawing excessive current.

Ladyada has pretty good technical discussion on this: http://www.ladyada.net/make/mintyboost/icharge.html


And I'll admit that I need to sit down and test my current consumption.  Very rough back of the envelope calculations suggest that my typical projects come in under 100mA, but I suspect that if my USB ports are strictly following the enumeration requirement and I'm requiring more than 100mA, my project will just continually reset when it hits the current ceiling.  Annoying, but not catastrophic.  And I don't know how much enumeration USB wall warts do.  I guess I'm more concerned about smoke testing my circuit or burning down my house than failing to work.

Ultimately the problem that I've been running into while researching this is that there are any number of projects for providing USB power to your phones and other devices, there doesn't seem to be too much about using USB to power your projects. smiley-grin
20  Using Arduino / General Electronics / USB Powering projects on: May 21, 2012, 09:16:54 am
So as I progress with my standalone projects, I'm coming to the conclusion that I tend to have USB power available everywhere, while providing > 7V to a 7805 means a specialty wall wart.  And even when I'm away from my PC, USB wall adapters can be purchased at the corner store while 7V supplies are less commonly available.

My stuff generally has low power demands (charlieplexed LEDs, the occasional sensor), so the 500mA cap isn't a problem.  But I imagine it's not simply a matter of soldering a USB jack onto my board and there's my 5V and GND.  So far I'm figuring on the following:

1) A PTC acting as a fuse in series to prevent a short from cooking off my USB port.
2) A cap bridging 5V and GND to smooth out the load.

Are there other best practices?  Passive components I can use to ensure I'm getting the full 500mA?  Additional safety or filtering components?

Or is this just a Bad Idea, and it doesn't work as reliably and universally as it seems like it should?
Pages: 1 [2]