From: linnix on

mrdarrett(a)gmail.com wrote:
> mrdarr...(a)gmail.com wrote:
> > linnix wrote:
> > > > 2) Let's say I want to make a simple AA battery tester (0 to 1.5 VDC
> > > > range), and interface it to the PC via serial port. I know I'll need
> > > > an ADC, and I can probably get away with using the one on the chip
> > > > (comparator, right?). Anyone have any schematic for building such an
> > > > AVR-to-Serial interface?
> > >
> > > Yes, a Max232
>
>
> Ah, I think I'm starting to get it. Use a dedicated RS-232 chip. And
> here I was banging my head against a wall trying to figure out how to
> build my own.
>
> Well, surprisingly, Mouser actually seems to have a few MAXIM 232s in
> stock...
>
> Hmm... if I'm going to use an output chip to control my computer
> interfaces, maybe I should just bite the bullet and look for a USB
> output chip... any suggestions? ;-)

The AT90USB128 is almost pin compatible with the 165/169/329/649.
Unfortunately, you have to rewire pin 2 to 5 for USB and RS232 to other
pins. Actually, we simply bring out the pins to vias and wire them for
either chip. This is a lousy design by Atmel. I wish there is a
AT90USB128/Atmega649 combo.

>
> Thanks!
>
> Michael

From: mrdarrett on

linnix wrote:
> mrdarrett(a)gmail.com wrote:
> > mrdarr...(a)gmail.com wrote:
> > > linnix wrote:
> > > > > 2) Let's say I want to make a simple AA battery tester (0 to 1.5 VDC
> > > > > range), and interface it to the PC via serial port. I know I'll need
> > > > > an ADC, and I can probably get away with using the one on the chip
> > > > > (comparator, right?). Anyone have any schematic for building such an
> > > > > AVR-to-Serial interface?
> > > >
> > > > Yes, a Max232
> >
> >
> > Ah, I think I'm starting to get it. Use a dedicated RS-232 chip. And
> > here I was banging my head against a wall trying to figure out how to
> > build my own.
> >
> > Well, surprisingly, Mouser actually seems to have a few MAXIM 232s in
> > stock...
> >
> > Hmm... if I'm going to use an output chip to control my computer
> > interfaces, maybe I should just bite the bullet and look for a USB
> > output chip... any suggestions? ;-)
>
> The AT90USB128 is almost pin compatible with the 165/169/329/649.
> Unfortunately, you have to rewire pin 2 to 5 for USB and RS232 to other
> pins. Actually, we simply bring out the pins to vias and wire them for
> either chip. This is a lousy design by Atmel. I wish there is a
> AT90USB128/Atmega649 combo.
>
> >
> > Thanks!
> >
> > Michael


Looks like the AT90USB128 is about $14 from Digikey. A (Texas
Instruments!) MAX232 is about $0.90. For a beginner, I think I'll
stick with RS-232. (Should be easier to write the software for the PC
side too.)

Thanks a bunch.

Michael

From: linnix on

mrdarrett(a)gmail.com wrote:
> linnix wrote:
> > mrdarrett(a)gmail.com wrote:
> > > mrdarr...(a)gmail.com wrote:
> > > > linnix wrote:
> > > > > > 2) Let's say I want to make a simple AA battery tester (0 to 1.5 VDC
> > > > > > range), and interface it to the PC via serial port. I know I'll need
> > > > > > an ADC, and I can probably get away with using the one on the chip
> > > > > > (comparator, right?). Anyone have any schematic for building such an
> > > > > > AVR-to-Serial interface?
> > > > >
> > > > > Yes, a Max232
> > >
> > >
> > > Ah, I think I'm starting to get it. Use a dedicated RS-232 chip. And
> > > here I was banging my head against a wall trying to figure out how to
> > > build my own.
> > >
> > > Well, surprisingly, Mouser actually seems to have a few MAXIM 232s in
> > > stock...
> > >
> > > Hmm... if I'm going to use an output chip to control my computer
> > > interfaces, maybe I should just bite the bullet and look for a USB
> > > output chip... any suggestions? ;-)
> >
> > The AT90USB128 is almost pin compatible with the 165/169/329/649.
> > Unfortunately, you have to rewire pin 2 to 5 for USB and RS232 to other
> > pins. Actually, we simply bring out the pins to vias and wire them for
> > either chip. This is a lousy design by Atmel. I wish there is a
> > AT90USB128/Atmega649 combo.
> >
> > >
> > > Thanks!
> > >
> > > Michael
>
>
> Looks like the AT90USB128 is about $14 from Digikey. A (Texas
> Instruments!) MAX232 is about $0.90. For a beginner, I think I'll
> stick with RS-232. (Should be easier to write the software for the PC
> side too.)

We won't be buying that much, but the qty 10K price is $2 to $3.

>
> Thanks a bunch.
>
> Michael

From: Tim Auton on
In sci.electronics.design mrdarrett(a)gmail.com wrote:
[snip]
> I think I'll try and build my own programmer. I'll try the
> ATTINY11-6PC: $0.53 each at Mouser. What a deal! At this rate I can
> buy more than one, in case I burn it out.

The ATtiny11 has no RAM, only registers. C really needs some RAM for its
stack, or you have to do some funky things to make it work at all. You
can't have much fun with just 32 registers to store all your data (this
paragraph contains more than 8x that much data). The small ones really
are incredibly limited.

Best advice for a hobbyist: Buy big. Considering the cost of shipping,
it's a false economy to buy the really low-end chips. You'll end up
making another order very soon when you find your first project is
larger than you expect. What you though was a saving ends up as being
more profit for FexEx.

I'd suggest an ATmega8 (or two) and a few matching sockets - you can
then swap the chip from project to project (no need for the sockets if
you don't plan to solder stuff together yet, a breadboard is one big
socket!). The ATmega8 has a UART, which means it has hardware to make
talking to a PC's serial port easier[1]. It has a good amount of RAM
and flash, which means you can use things like C's printf function to
make life easier (printf and associated gubbins takes up around 2.5K of
flash). It has multiple timers, plenty of pins, PWM and a bunch of other
stuff you'll soon find you want.

[snipped a question]
> 2) Let's say I want to make a simple AA battery tester (0 to 1.5 VDC
> range), and interface it to the PC via serial port. I know I'll need
> an ADC, and I can probably get away with using the one on the chip
> (comparator, right?). [...]

You can use a comparator (gives a signal when one input has a higher
voltage than the other) as an ADC, but you have to use it to measure the
time it takes for the voltage you are measuring to charge up a capacitor
to some reference voltage. You have to provide the capacitor, reference
voltage, code to time it accurately, coded to turn that exponentially
varying number into a linear voltage and make sure the current you take
charging the capacitor doesn't affect what you're trying to measure
(this method has a low input impedance - it puts a significant load on
what you're measuring, changing it in the process). It takes two pins
and you can only measure one voltage with your one comparator. This is
not much fun, though it can shave a few cents of the price of your
device, which might be worth it if you want to make a million of them. I
doubt you want to make a million of them. Buy a chip with a proper ADC
built-in; no external components, very little code, more accurate
results, multiple inputs which take just 1 pin each and you can connect
the pins directly to virtually anything without it affecting what you
connect to (the ADC inputs have very high impedance). Don't connect the
inputs to anything outside the AVR's supply range (0-5V probably, but
you have some choice in the matter) though, or you'll fry it.

For the battery, connect - to circuit ground, + to an ADC input on the
AVR. The AVR's ADC can then measure the voltage with half a dozen lines
of code. That wouldn't actually make for a great battery tester; there's
more to testing batteries than just measuring the voltage, but that's
another subject.

> [...] Anyone have any schematic for building such an
> AVR-to-Serial interface?

> fwiw, I went over to Borders last night, and even the PIC books didn't
> discuss in much detail how to interface with the PC. Just only how to
> interface the programmer with the PC. Sheesh.

Best to use the serial port, as that's by far the easiest. You might
need a USB-serial converter if your PC doesn't have serial ports.
Sending raw bytes is most efficient, but you'd then have to write
software for the PC to decode those bytes. Much easier to just buy a
nice big AVR and use printf to send ASCII text, at least at first. You
can then use something like Hyperterminal on the PC and get text output
on screen with minimum hassle. You can do clever, efficient protocols
and squeeze them into the really cheap AVRs when you've learnt some
more.

[1] You will need a MAX232 or equivalent chip to convert the AVR's 0-5V
serial port (UART) signals to the +/- 15V RS-232 signals a PC serial
port expects - remember to buy the 4 capacitors such chips require too,
if you don't have that kind of thing lying around. You need to think
about the cable from the chip to the PC as well.

If you haven't already, check out AVRFreaks. There is a lot more there
than there may appear to be at first.

http://avrfreaks.net/


Tim
From: mrdarrett on

Tim Auton wrote:
> In sci.electronics.design mrdarrett(a)gmail.com wrote:

-=snip=-

> Best advice for a hobbyist: Buy big. Considering the cost of shipping,
> it's a false economy to buy the really low-end chips. You'll end up
> making another order very soon when you find your first project is
> larger than you expect. What you though was a saving ends up as being
> more profit for FexEx.
>
> I'd suggest an ATmega8 (or two) and a few matching sockets - you can
> then swap the chip from project to project (no need for the sockets if
> you don't plan to solder stuff together yet, a breadboard is one big
> socket!). The ATmega8 has a UART, which means it has hardware to make
> talking to a PC's serial port easier[1]. It has a good amount of RAM
> and flash, which means you can use things like C's printf function to
> make life easier (printf and associated gubbins takes up around 2.5K of
> flash). It has multiple timers, plenty of pins, PWM and a bunch of other
> stuff you'll soon find you want.

-=snip=-

Thank you for taking the time to give very good advice to us newbies.
I appreciate it.

I think you're right. ATmega8. For about the price of a Six Dollar
Burger at Carl's.

Michael