Shop OBEX P1 Docs P2 Docs Learn Events
I2C Intelligent Peripherals for Prop using cheap ATtiny85/84 (8/14pin) micros - Page 2 — Parallax Forums

I2C Intelligent Peripherals for Prop using cheap ATtiny85/84 (8/14pin) micros

2

Comments

  • jazzedjazzed Posts: 11,803
    edited 2010-10-21 15:37
    Cluso99 wrote: »
    To program the attiny the reset needs to be controlled and the SPI interface is used (not always the SPI pins but they are on the ATTiny24/44/84). No high voltages are required in this mode. So all we need here is a 4pin header (if the SPI pins are not two of the I2C pins otherwise it is only 2 pins) which can be connected to the prop for programming purposes.
    The atTinyX4 SPI pins are totally separate from the I2C pins. It shouldn't be too hard to figure out the download protocol if it's not published already.

    The other thing to consider even for AVR I2C connections is the ability to reprogram Flash using the SPM instruction. Maybe an I2C address can serve as a "program monitor" for updating code. That could even be used to reprogram the atTiny85 with a blown reset pin fuse :)
  • TubularTubular Posts: 4,717
    edited 2010-10-21 16:38
    Talking to my friend who lives and breathes Atmel... these free programmers are worth a look
    AVRDUDE - http://www.nongnu.org/avrdude/

    PonyProg - http://www.lancos.com/prog.html
  • TubularTubular Posts: 4,717
    edited 2010-10-21 16:50
    It appears the Bus Pirate v3 or v4 can be used to program Atmel devices, in conjunction with AvrDude. If I must fork out for a programmer, this seems like a good flexible option
    http://www.sparkfun.com/commerce/product_info.php?products_id=9544
    http://www.seeedstudio.com/depot/bus-pirate-v3-assembled-p-609.html?language=en
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-10-21 16:50
    The SPI programming interface for the ATTiny micros is pretty simple. Parallax's MoBoStamp-pe uses two of them, which are programmed from the BASIC Stamp. The reset pin is controlled in such a way as to make inadvertent resets and the havoc they could cause difficult. The PC-resident AVR loader program is written to prevent the reset pin from being programmed as a port, which would entail reprogramming the chip with an elevated Vpp.

    -Phil
  • BigFootBigFoot Posts: 259
    edited 2010-10-21 18:03
    The I2C touch control chip we use in our systems has four 8/12 bit
    ADC inputs and two internal temperature sensors.

    We have a 7" Lcd display / touchscreen and it is a very sensitive
    & self contained controller.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-10-21 18:05
    I know I have been talking about the LPC111x chips but the development tools for this are a bit more complex than most are familiar with. I hate unnecessary complexity in anything and GCC based tools never make it simple.

    PRACTICAL SOLUTION
    In my old thread about PPCs I mentioned using Silabs parts and they are very easy to write code for as well as program in-circuit, in fact I have posted Spin code that does it. The tools are available from Silabs and are free and easy to use.

    So I have just checked Mouser to see what they have and it looks like you can get quite a few types available for around the $2 premium (shucks!!!) and there I spy a suitable device in an SOIC14 and not the QFNs which some seem to dread (but not DIP). I can solder these babies with a plumbers iron (actually I could).

    The C8051F304-GS is available in SOIC14 and features:
    Core: 8051
    Data Bus Width: 8 bit
    Program Memory Type: Flash
    Program Memory Size: 4 KB
    Data RAM Size: 256 B
    Interface Type: I2C/SMBus/UART
    Maximum Clock Frequency: 25 MHz (that's 25MIPS)
    Number of Programmable I/Os: 8
    Number of Timers: 3

    This chip is in the low end of the range but there are a lot of others to choose from plus the 8051 core is very efficient when it comes to bit-bashing and low-level stuff.
  • TubularTubular Posts: 4,717
    edited 2010-10-21 18:33
    Right. Next time I'm up your way I'm bringing a plumbing iron for the soic14. And in return you can laugh at me attempt to solder a QFN.

    The Silabs parts are very attractive in many ways as you highlight, but they are pricey and perhaps not quite so widely available as say an AtTiny or PIC. Whats the nature of the programming interface, and how many pins are required? Is the programming protocol documented or proprietary?
  • groggorygroggory Posts: 205
    edited 2010-10-21 18:54
    Tubular wrote: »
    Right. Next time I'm up your way I'm bringing a plumbing iron for the soic14. And in return you can laugh at me attempt to solder a QFN.

    The Silabs parts are very attractive in many ways as you highlight, but they are pricey and perhaps not quite so widely available as say an AtTiny or PIC. Whats the nature of the programming interface, and how many pins are required? Is the programming protocol documented or proprietary?

    Crappy iron + good solder wick means most things can be done.

    And I'm very interested in all this. I would love a nice slave processor to do trivial stuff for me. Propellers are kinda expensive, eat up a lot of board space, and take support components. Sometimes I want to add a second propeller to the circuit...but its just so overkill.
  • TubularTubular Posts: 4,717
    edited 2010-10-21 19:07
    Solder wick? That would be cheating :lol:

    Yep, the whole co-pro thing makes perfect sense really

    I'm sensing the need for some kind of very basic, single wire, interface standard, that can be used with whatever might is preferred by others. I see parallels with the rendezvous idea when talking to cogs, but in this case the rendezvous location is out on a serial bus.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-10-21 19:10
    SMD soldering used to be "highly technical" decades ago but all that changed with learning simple tricks. How many of us have a toaster oven dedicated to reflow soldering??? When I first had to solder smd parts such as 80 pin QFPs back in the 80's and 90's when smd stuff was hard to get I would use the tack and blob technique where I would tack down the corners of a QFP so that it was aligned and flat. Then I would blob a mass of solder over all the pins with a warm iron so as not to burn off the flux after which I hit it with a big hot iron running the tip along the pins while holding the pcb slightly upside down. The solder would flow off the pins into a great big blob on the tip of the iron which got flicked off after the last pin in the row.

    Ok? so I know I can solder a simple SOIC with any iron and when I say any iron I am even thinking of those old lumps of copper we used to use in metalwork class.

    PROGRAMMING SILABS CHIPS IN-CIRCUIT
    Nice and simple. There are two pins, the clock and data whereas the clock is shared with the reset pin. I tie the ICP data to the SDA pin and run the ICP clock/reset to a dedicated Prop pin. So other than the I2C bus I only dedicate one pin per chip.

    Here is some C2 programming code. I will post some examples of 8051 code as well.
  • Cluso99Cluso99 Posts: 18,069
    edited 2010-10-23 03:40
    The most important thing for me in programming the micro is only the standard voltage (3v3 or 5v). 1-4 pins are fine and if it has to be a header and connected to another port for initial programming so be it. For instance, once we get an I2C interface code in there we could use this code/interface to "reprogram" the micro.

    I still like the ATTiny x4 because both soic14 and dip14 parts are available and are not too badly priced and look similar (RISC) to the prop. I am definately steering away from my previously preferred MC(R)S08.

    Peter: I don't have a toaster oven. I just use a fine tipped temperature controlled iron to solder my RamBlades and so far no failures. I occasionally need solder wick. I will be trying/using QFN shortly but while I am not so concerned I do know others are.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-10-23 06:34
    A cheap toaster oven is a must and a fine tip iron is one of the last things I ever use when soldering SMD (really). If you like Ray I can give a live demo next time of just how easy it is to paste, place, and toast. About 5 minutes in the oven and all the work is done for you, and that means multiple pcbs at a time, all perfectly soldered. If there is any touch-up to do I find that applying a little flux to the area and hitting it with an iron works better than solder wick. (That's a funny thing with our North American cousins, they say "SOD-ER" and we say "SOLD-ER")

    I can see the development and Flashing of the peripheral micro being more important than the cheapest price or even features or the package. I keep looking at other micros because they are cheaper but the Silabs parts are very easy to work with in many ways.
    Cluso99 wrote: »
    The most important thing for me in programming the micro is only the standard voltage (3v3 or 5v). 1-4 pins are fine and if it has to be a header and connected to another port for initial programming so be it. For instance, once we get an I2C interface code in there we could use this code/interface to "reprogram" the micro.

    I still like the ATTiny x4 because both soic14 and dip14 parts are available and are not too badly priced and look similar (RISC) to the prop. I am definately steering away from my previously preferred MC(R)S08.

    Peter: I don't have a toaster oven. I just use a fine tipped temperature controlled iron to solder my RamBlades and so far no failures. I occasionally need solder wick. I will be trying/using QFN shortly but while I am not so concerned I do know others are.
  • Cluso99Cluso99 Posts: 18,069
    edited 2010-10-23 18:23
    Hi Peter, I am on the GC currently - not sure if this time I will be able to catch up but I have phoned in case.
  • Cluso99Cluso99 Posts: 18,069
    edited 2010-10-23 23:05
    Copied from "I2C Keyboard/Mouse thread...

    The ATTiny84 from DigiKey seems like an excellent choice. ATTiny84-20PU $1.68/100 (DIP14), ATTiny84-20SSU $1.62/100 (SOIC14), ATTiny84V-10SSU $1.62/100 (SOIC14). All have 8KBx8 and 10b ADC. The SOIC14 is 1.27mm pitch and 6x8.7mm which means quite easy to solder.

    Steve is working on a spec for the ATTiny to be able to program itself (after being pre-programmed with a bootloader) over the I2C bus.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-10-23 23:53
    If you rely on a pre-programmed bootloader to write programs to the AVR's flash, make sure it's bombproof. This means that no program that it loads can possibly overwrite the bootloader itself or interfere with getting the bootloader's attention when it's time to load another program. That's not a condition that will be easy to maintain. If it's violated, you will have to reprogram any non-socketed chip in-circuit via the SPI pins and /RST, which means those pins have to be kept free for that purpose.

    -Phil
  • Cluso99Cluso99 Posts: 18,069
    edited 2010-10-24 02:40
    Phil: Absolutely. The I2C bootloader must not reprogram the bootloader area. I have written bootloaders for many micros in the past and fully understand these. Most of these were used with downloading executable code into SRAM. Some had battery backed SRAM such as the battery backed chips, others did not. The RamBlade has this as well. BTW my first downloadable micro was built in 1977 and used an MC6800.

    There is more discussion over on the other thread.

    Here is an example of the pins on the 14 pin ATTiny84.
    Pins 1 & 14 = power
    Pins 4 (reset/debug), 7 (sda/di/mosi), 8 (do/miso), 9 (scl/usclk) = program via SPI ((7=SDA 9=SCL for I2C to Prop))
    Pins 10-13 = external peripherals such as Keyboard and mouse or 4xADC
    Pins 5-6 = external peripherals (pin 6 is 1xADC)

    Now lets look at the programming pins 4,7,8,9...
    * Pins 9 & 7 are already to prop (9=USCLK, 7=MOSI) as I2C (9=SCL, 7=SDA)
    * Pins 4 & 8 will be on an optional header (4=Reset, 8=MISO). This will need to be wired to the prop temporarily to initially program the bootloader. These 2 pins "could" also be used for external peripherals as well as long as they can be disconnected for bootloader programming.

    I chose the ATTiny84 based on Steve's recommendations that the x4 is a better chip (14 pins instead of 8). The 8x is because it has 8KBx8 program (flash) memory rather than 4KB or 2KB. There is little difference in price so lets have the 8KB space.
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2010-10-24 02:49
    The ISP pins could be used but they should only be lightly loaded, ie over 5-10 K Ohms or so, so that the programmer cam still assert itself. A 4053 switched over by the /RST line is one way, but thats one more chip ...


    One more thought, I know that if the RAM amount goes over the 256 byte count then the SP requires two bytes, this can lead to problems if the code is compiled for the lower memoried variaty (been there ... )
  • Cluso99Cluso99 Posts: 18,069
    edited 2010-10-24 04:54
    I have updated the definition of I2C pins in the post above.

    A 2x2 links can overcome this if the extra 2 pins are required - 2 shunts to connect the peripherals, and get used as header for programming.

    Tony: Yes, need to ensure 2 byte addresses.
  • Cluso99Cluso99 Posts: 18,069
    edited 2010-10-24 06:14
    Reading through much of the ATtiny84 specs it certainly seems as though the debug-wire (which is the reset pin) can be used to program the chip. However, this still requires attaching an extra prop pin.
  • jazzedjazzed Posts: 11,803
    edited 2010-10-24 08:56
    Cluso99 wrote: »
    Reading through much of the ATtiny84 specs it certainly seems as though the debug-wire (which is the reset pin) can be used to program the chip. However, this still requires attaching an extra prop pin.
    The problem with debugWIRE programming is that you have to program a fuse using SPI to use debugWIRE. Once the fuse is blown, you must have a device that supports debugWIRE because it's not an open specification (not embeddable on a Propeller for example).
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-10-24 09:22
    I like to keep an open mind and I have had a lot of experience with AVR as well as 8051, and PIC as well as many other low-end micros. So if I am a little biased then it's based upon this experience. It would be good to standardize to some extent on a peripheral CPU for the Prop as all could benefit.

    But I'm wondering whether the AVR really is a good candidate considering that it can't be programmed from the Prop plus amongst other things I notice it doesn't support a full-duplex UART although you wouldn't be able to use it if you are using I2C anyway. If you think that it doesn't matter that it isn't programmed from the Prop then you may be right but I have found from my experience that this saves board space and allows field upgrades through the one standard programming interface, no need to buy or make another programming cable. To be sure, there are other advantages as well.

    As for software tools I have used this free universal macro assembler for all these CPUs so it helps to standardize and not be tied to a vendors tool.

    But I don't think that the selection criteria should be based upon whether the device is available in DIP or not, it just seems too dismissive of the far more important features etc. SMD soldering is just another technique that needs to be learnt sometime, not avoided. How are Prop heads going to handle the fully SMD Prop II?
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2010-10-24 09:33
    I only shy away from SM stuff because I like to try lots of different things, constantly. Very few projects get to be used items, the rest suffers a further round of recycling. DIP is big and ugly (like me, I'll be the first ..) but is great for the dabbler.
  • jazzedjazzed Posts: 11,803
    edited 2010-10-24 10:06
    If you think that it doesn't matter that it isn't programmed from the Prop then you may be right but I have found from my experience that this saves board ...
    @Peter,

    No doubt that being able to program a device from the Propeller is very valuable. I don't really care what chip gets used for an intelligent peripheral except that one of my boards is using atTiny85 now. Later I'll be designing a separate board that uses Propeller as an intelligent peripheral because that will probably serve users here better.

    However when lowest cost and board space are issues I'll use a cheap chip that does not need extra components. And when it comes down to that again, I'll consider your solution.

    Meanwhile, I'll deal with what has been already done in my case and continue satisfying the creative urge. One of the reasons I'm writing a bootloader for atTiny85 is so I can use the RESET pin as an IO without having to throw away another chip. The other reason is I would like to reprogram the current design "on-line" so people who buy the product can play without that extra equipment. Part of the initial decision for using atTiny85 is that I honestly like programming AVR chips.

    Cheers.
    --Steve
  • TappermanTapperman Posts: 319
    edited 2010-10-24 12:13
    The trick with soldering the QFNs easily is to simply apply the solder paste to the chip and not the pcb. Set it down on the pads and simply reheat and enjoy.

    Reheat with what? Soldering Iron? I've been interested in branching out and attempting to use QFN, but not sure how to employ technology on a back-yard budget?

    ... Tim
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-10-24 15:59
    Tapperman wrote: »
    Reheat with what? Soldering Iron? I've been interested in branching out and attempting to use QFN, but not sure how to employ technology on a back-yard budget?
    ... Tim

    I can pick up a decent toaster oven for under $30 so get one and armed with a syringe of solder paste you are ready to tackle SMD. When you see SMD stuff done this way you will wondering why you ever hesitated and procrastinated all this time.

    Forget the fine tip iron and the solder wick IMO, they prove to be detrimental to simplifying and improving DIY SMD. One thing that does help if you do get bridges is simply to to touch the pads with a clean flat iron and usually what happens is the solder wicks to the pads and leads without further ado. Occasionally you find that this might not work and so applying a small dab of flux (as from a syringe) and touching it again does the trick. Once you get used to applying the solder paste this should happen only infrequently.

    When designing a PCB for QFN packs it helps to extend the pads out from the package so that you can access them with an iron if needed. The trick with soldering a QFN pack which does not have any leads, only contacts, is to apply paste to the contacts rather than the PCB. It's made a big difference with successfully soldering these babies.

    Has anyone done any on-line instructional videos? If not I might catchup to Cluso99 to give him a demo and video the session at the same time (after editing the beer appraisal).
  • Cluso99Cluso99 Posts: 18,069
    edited 2010-10-24 17:42
    Let me answer a few misconceptions...

    The ATtiny84 is the 14pin version of the 8pin ATtiny85. Both have 8KB and the extra cost for 8KB vs 2KB or 4KB is negligable. However, they are not <$1. Both are available in SOIC and DIP and I agree DIP is not necessarily a requirement although an advantage to some.

    Programming is best done via SPI & reset. We will be using 2 of these pins for prop I2C and if the other 2 pins are on a header, then by connecting these 2 pins to 2 other prop pins we can program the boot code from the prop (initially). Once the ATtiny is programmed with the I2C boot code, we can use our own I2C protocol to program the ATtiny over I2C from the prop with our own extension. No high voltage is required.

    For dedicated functions, others (me too) may use cheaper micros where cost is a consideration. However, for the many users wanting to experiment, the ATtiny is a good choice even if it is a little more expensive.

    BTW even Peters 8051 variants have DIP versions.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-10-24 18:42
    Cluso99 wrote: »
    BTW even Peters 8051 variants have DIP versions.

    Those DIP versions are even harder to get than a consensus on this forum :lol:

    I'm still scratching my head though about all this quibble over <$1, >$1 or $2+. I know it means a cheeseburger to some but unless you are talking huge quantities then this criteria for a micro is totally irrelevant, or are we that hard up? Footprint, capability, usability, and development and ICP are factors that I would consider, and then the price. Rather than trying to pick a cripple and make it run it is easier to pick something that is fleet-footed in the first place. Hobble, walk, run, or jump will then be possible.

    If we do pick one based on it's merits that will jump if needed then I know I could buy a reel of them at the $cheap cheap$ price and then maybe some members could act as distributors for these parts. At least we would have a common library of functions, much like the OBEX. Oh, wouldn't that be wonderful :yeah:

    BTW, when I used to use AVRs many lifetimes ago I sometimes had an 8-pin PIC added just to perform ICP over serial. Now that would be funny having an AVR as the Prop's peripheral and a PIC as the AVRs ICP :smilewinkgrin:

    EDIT: This micro for instance is quite capable and only $1.45 in 1K quantities.
    787 x 553 - 103K
  • Cluso99Cluso99 Posts: 18,069
    edited 2010-10-24 22:04
    Peter, yes the C8051F988 is quite a powerful chip with an RTC on-board too. $2.33/100 and $1.46/1K from Digikey.

    Pin spacing for the QSOP24 (~SOIC) is 0.635mm (0.025") is a little unusual but thats only a layout problem.
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2010-10-25 01:53
    If a real serial port is available, then with a few diodes, resistors and a transistor Pony Prog will blast '25-'85s but I didn't see the '24-'84s on its menu (but it denighs the M644s I have but progs them ok). Real serial ports might be a problem to those without an older machine.

    Parallel Port progs are even simpler, but Windows get in the way (without work arounds). The ones with just a few resistors are great, if they work, but the SCK line must be kept clear or any glitches, hence the designs with caps as well. Buffers are added to provide some protection to the mother board.

    I have a USB_ASP which raises that "chicken and egg" problem, it needs a Mega8 (or 48) programmed first.

    As to the "How many procs can we get into the programming chain" what about the one in the PC as well ( but at least that is common to the Prop chain as well)
  • TappermanTapperman Posts: 319
    edited 2010-10-25 19:02
    I can pick up a decent toaster oven for under $30 so get one and armed with a syringe of solder paste you are ready to tackle SMD. When you see SMD stuff done this way you will wondering why you ever hesitated and procrastinated all this time.

    Perfect! Just the answer I was looking for. I have a toaster oven already.

    ... Tim
Sign In or Register to comment.