Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Re: printf() Command on Graphic LCD? on: February 23, 2011, 06:55:32 pm
Well, you can use printf() if you initialize it with fdevopen() first.

This very simple example will work for printing on a single line.  You could extend it to keep a line buffer, interpret CR & LF, and scroll the screen up.

Code:
#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);

int lcd_putc( char c, FILE * )
{
  lcd.write( c );
  return 0;
}

void setup(void)
{
  ...
  fdevopen( &lcd_putc, NULL );
  ...
}
2  Using Arduino / Motors, Mechanics, and Power / Re: Fried my Atmega328 using L298 to drive step motor ... what to blame? on: February 22, 2011, 12:14:57 pm
I am curious as to how you found the one you did? For a while I was looking for Multiwatt15 heatsinks, until I found some that would work at a local electronics junkyard (Apache Reclamation here in Phoenix, AZ) - I could find only certain things listed online for such heatsinks, but no pictures to see that they would actually work. Really, you could probably get away with a piece of bent and drilled aluminum stock. Remember to add heatsink grease, whatever your use!

Well, this one was pretty easy.  I try to buy everything from Mouser.com, to simplify my purchasing.  When I searched Mouser for Multiwatt heatsinks, thinks is the the only one that came up!

Thanks for the tip on the grease, I will do that.  I'm pretty sure that's available at the local electronics store.
3  Development / Other Software Development / Re: new library - MCP23016 IO expander on: February 20, 2011, 04:26:15 pm
Ok, I should have been a lot more specific about my latches comment.  Consider the following sequence of events:

1. Set port 0 to outputs, port 1 to inputs
2. Write B11111111 to port 0.  This will also writes 0 to port 1, but that's pr'y OK.
3. Read port 1.  This will also read GP0 into the 'port0' member variable.  Now 'port0' contains WHATEVER the GP0 register had in it.
4. Try to write a 0 to the LSB of port 0.

You would EXPECT this to write B11111110 to port 0.  But in my experience this may or may not happen.  In step 3, you filled the 'port0' member with the contents of GP0 as a side-effect of filling the 'port1' member from GP1, which is what you were really trying to do. 

The GPx registers seem not to reliably contain the last value written to output pins.  The OLATx registers do, so in my code I always read from the latches when I need the values last set to the pins.  Now in your code, you buffer the values in RAM so you wouldn't really need to go to the latches at all.  Instead, when you read, you could just remove any bits that were set to outputs, so you'd only update 'port0' and 'port1' for bits whose corresponding pins were set to inputs.

WRT the internal-pullups, yes I am reading the 23016 datasheet, and I see it is a much simpler chip.  I use the pullups all the time, to avoid having to add resistor networks to the system for the same purpose.
4  Using Arduino / Motors, Mechanics, and Power / Re: Fried my Atmega328 using L298 to drive step motor ... what to blame? on: February 20, 2011, 02:32:57 pm
Thanks, Magician.  Okay, that makes sense.  I also am not at all certain the L298 is to blame.  if I posted it on the general board, they'd be like, "Well what were you DOING with the Arduino?  And post it there..."  ESD problems seems like a pretty good stab at an explanation, especially given that I was handling the Arduino+shield unit quite a bit the first day.  I have been running the same system using the replacement Atmega since I posted the original, and the replacement chip is not fried.  Perhaps this will be a good lesson in bullet-proofing, as you say.  And zener diodes.  I've seen those, I'll have to learn about them.

Btw, the cat feeder is working flawlessly. smiley-grin  The enclosed circuits are separated from the cat by about 3 feet of cable, although I suppose the motor and wires are exposed, so she could static those things up good if she was motivated.  I have some writing and picture-taking to do, and then I'll post that one on the gallery.
5  Development / Other Software Development / Re: new library - MCP23016 IO expander on: February 20, 2011, 02:12:10 pm
I use the MCP23018 extensively, so I'll give this a try.

A couple suggestions...

  • Definitely agree on previous post that the library should be named for the specific chip family.
  • Any chance you could host on github or something like that?  Would make it much easier to submit patches.
  • Abstract the Wire.begin/send/end stuff into a private function to avoid so much duplication.
  • Is it a good idea to call Wire.begin() from a chip-specific driver?  If you have a handful of different drivers EACH making a begin() call, will that mess something up?  In my own code, I call Wire.begin() in setup(), and then each driver's own begin() afterward.
  • Why take only a 'bool' for pinModePort?  Seems like an artificial constraint that an entire port be either input or output.  The chip supports some 'pins' being input and others output, why not support this in software?
  • When you READ the port values you store them in (portX), which is the same place you're use when WRITING to them.  Yet you are reading from the ports themselves, not the latches.  I think this will give inconsistent results.  To reliably read back the values you've written to outputs, I think you have to read from the latches.

In such a library, I would like to see support for...
  • Pull-up registers (Do you have them on 23016?)
  • Writing 8 bits to a whole port at once.  This is how I usually use it.
  • Writing 16 bits to the whole chip at once.  One thing I use it for is to drive a 12-pin 4-digit 7-segment LED, so I know all 12 bits at a time to display a digit.

Btw, I think you need Wire.h in your .PDE because that's how Arduino build system knows which libraries to link in.  It's a clever, simple approach (like much in the Arduino software).  Other build systems require you to configure the project and separately define which libraries to link in.  Here, it just picks it up from the includes.  Nice.
6  General Category / General Discussion / Re: Why am I a ghost?? on: February 20, 2011, 02:02:57 pm
Oh, it's GENDER!  Great, thanks.
7  General Category / General Discussion / Why am I a ghost?? on: February 20, 2011, 12:38:00 pm
Just curious...  Wondering why I have a little 'ghost' icon next to my name in posts, where most others have a little silhouette of a person.
8  Using Arduino / Motors, Mechanics, and Power / Re: Fried my Atmega328 using L298 to drive step motor ... what to blame? on: February 20, 2011, 11:58:02 am
Yep, really am using 1N4004's.  When putting this together, I couldn't quite grasp the complexity of the diodes available.  Trr is rarely listed on diode data sheets.  So I used what it seems like other circuits posted on the Internet were using.  From reading around, it looked like about 80% of the time, people were like "Anything is fine, 1N4004's are fine", and then the other 20% gave non-specific warnings that something better should be used.  Never could I find a part# that should be used instead.  So anyway, now I ordered some 1N5822's to try, but even that does not list trr on the data sheet!  I am relying on the "Extremely fast switching" in the marketing section of the datasheet.  Do you think 1N5822's will be sufficient??

Also buying an Aavid 566010B03400G heat sink.  It seems that heat is normal and expected for the L298, but since I'm leaving this thing on all day now, and not real savvy about thermal engineering, I'm trying to play it safe by keeping the chip cool to the touch.

Magician, there is definitely LOW on Arduino pins 11 & 12 when the switches are open.  R1 & R2 are there to pull the pins low.  This is before I learned about pull-up resistors on the chip itself, so future revs of this will have the switches simply connect GND to the pin.  But these Arduino pins are not part of the L298 circuit, they're just there so I have some control over the operation of the sketch.
9  Using Arduino / Motors, Mechanics, and Power / Re: Fried my Atmega328 using L298 to drive step motor ... what to blame? on: February 19, 2011, 06:46:13 pm
Ok, I managed to measure current FROM the L298, and it came it an 210mA.  Current TO the L298 will be the tricky bit.
10  Using Arduino / Motors, Mechanics, and Power / Re: Fried my Atmega328 using L298 to drive step motor ... what to blame? on: February 19, 2011, 06:28:21 pm
Thanks...  Yeah, I was trying to replicate that drawing.  So in the datasheet schematic, D1 connects pin 13 to +Vs, D3 connects pin 14 to +Vs.  In my circuit, D1 connects pin 13 to +12V, and D4 connects pin 14 to +12V.  So my D1/D4 should be doing the job of D1/D3 in the datasheet schematic.  (Note that there are 8 diodes in all, so perhaps the right-most part of the drawing was cut-off for you.)

CrossRoads, thanks for that tip, I'll have to figure that out.  My little meter doesn't read current, and my big meter is to large for this circuit.  Guess I need to upgrade.
11  Using Arduino / Motors, Mechanics, and Power / Fried my Atmega328 using L298 to drive step motor ... what to blame? on: February 19, 2011, 01:35:12 pm
Hi.  This morning I seem to have fried the atmega chip on my Duemilanove, and so I'd like to figure out the problem so I don't do it again.  The Deumilanove is working now because I replaced the Atmega328 chip with a replacement that I had (coincidentally) just ordered.

I am driving a step motor using an L298 circuit built as a shield.  I have used this design in other projects, and it's worked fine.  (In fact, this exact design feeds my cat every 12 hours smiley-grin)  But this is the first time I have run a motor for long durations (over an hour) at a 20% duty cycle.  The driver chip does not heat up too much at 20%, although it did at 25%, so I dialed it down.

This is also the first time I am using a particular motor I just picked up.  The motor is not marked in any way, so I am driving it with 12V but frankly I have no idea how much to use on it.

The schematic is attached.

Does anyone have ideas what could have caused this?
Pages: [1]