Remove your Arduino's external oscillator to gain a free pair of IO pins

2free-arduino-io-pins

[Mark] from SpikenzieLabs was wrapping up a project using an Arduino the other day and found himself in need of a few more I/O pins. He could have added extra circuitry to the project, but he decided to see if he could gain a few pins by removing a few components instead.

He put together one of his Minuino boards, but rather than installing the crystal and its associated capacitors, he added a couple of pin headers in their place. It’s well known that the internal clock on the chip is not as precise as a crystal, but [Mark’s] project was not that time sensitive, so he had no problem sacrificing the oscillator for a few extra pins.

With his new I/O pins in place, he merely needed to tell the ATmega chip which clock it should be using, and he was well on his way. While this might not be the best solution for all projects out there, if you are building something that values pincount over precision, this hack is for you.

Check out the video below to see [Mark’s] hack in action.

[via HackedGadgets]

[youtube=http://www.youtube.com/watch?feature=player_embedded&v=gHU0zrn1o-w#!&w=470]

Comments

  1. Felicitus says:

    Why didn’t he simply use a regular Atmel? They’re cheaper and can run the Arduino software anyways.

    • Eirinn says:

      Why not build everything out of logic gates?

      • Felicitus says:

        The only thing which makes a difference from the MiniDuino to the Atmel is the board. I mean, it is even socketed. Just pull it out, place on the board, done. Not even a need to build the whole Arduino board.

      • Hackerspacer says:

        Or relay logic?

    • Matt says:

      Because he had the minduino laying around and this could help drive sales?

      Cool idea. I would think of it when working with the bare chip but it never would have come into my head as a possible solution when using a prepackaged dev board.

    • tlalexander says:

      Why doesn’t everyone just use an AVR and not an Arduino? Oh, because Arduinos are very easy to use.

      I lay out my own boards for Atmel’s SAM3 ARM chips and program them myself – but I still have a few arduinos lying around because they’re easier when all I need to do is blink some lights.

  2. CrashSerious says:

    This is a standard configuration. It just uses the internal oscillator. The downfall is it runs slower. ~8Mhz, if I recall correctly.

    • svofski says:

      Internal RC oscillator is specified up to 8MHz, but in reality it can be calibrated to run at up to 12MHz. V-USB has code that does this.

      HaD, please, work on your terminology. ATmega can be configured to run off an external clock, but it never was used here. The oscillator was and still is internal. He had originally an internal oscillator with external crystal. Then he switched the configuration to use the internal calibrated RC oscillator and removed the crystal, thus freeing 2 more pins for I/O. But crystal != oscillator. It’s only a part of it that defines frequency.

      Still breaking my head, since when this is news, but nevermind.

  3. macegr says:

    Heh, just the other day I scrounged some parts in the lab and built up one of those Minuino boards Mark gave me in New York. I actually didn’t have through-hole 16MHz crystal and had to pull one off another dead board…should have thought of this idea!

    As an aside…the PCB is crazy thick, feels so weird…

  4. Jeremy says:

    Does the arduino ide still work for loading code onto it? Aside from adjusting the clockspeed, I know that the internal oscillator isn’t recommended for serial communication because it can drift with temperature.

    • svofski says:

      Unless you’re stressing your chip with temperatures that change by dozens of degrees, RC oscillator is perfectly fine for serial comms. In fact, it’s more flexible. You may need to calibrate it.

    • jbiehler says:

      You also take a pretty big hit in clock accuracy by using the internal oscillator versus an external crystal or even a resonator. Thats what is nice about the Teesnys. Paul used a high quality crystal and the trace lengths are optimized for the crystal. This means a very stable oscillator and it shows in his frequency measurement sketch.

  5. Joe says:

    I do support inginuity, but at some point there comes a time when it is time to put down the arduino and pick up an actual amtel, pic or whatnot. Idk just my opinion.

  6. DrLuke says:

    If you implement a software-reset, you can also turn the reset pin into an IO pin.

    • Daid says:

      Not if you want to use the ISP feature. And I think you would also need a high voltage programmer to disable the reset pin function.

      • Jeremy says:

        No, you need a highvoltage programmer to *reenable* it.

      • NewCommentor1283 says:

        hehe! XD he’s right, its a catch 22 of AVR’s …

        its that way with several features of the device assuming you dont own a dev board with all programming methods in place.

        ICSP enable (if u own only ICSP programmer)
        JTAG enable (if u own only jtag programmer)
        clock-selection (if you dont own any crystals…lol)
        bootloader (if u dont own any programmers at all)

        plus the reset setting we are talking about!
        did i miss any catch 22’s ??? lol theres too many, oh wait, BOD if ur dev board is 3.3v with a 3.3or5 volt capable chip.

        BUT FEAR NOT!
        HackADay will help you sort it all out using search “unbrick AVR” and “unbrick” all your AVRs you have 🙂

        PPS: as for the chicken and egg situation of only HAVING one AVR, you can reverse engeneer the code and write x86 dos executable to use parallel port on old computer, er, i mean, port Arduino to x86, big project 😛

        (ASSUMING U DONT HAVE LPT PORT:)
        or with the addition of a few logic chips, use a “spare” IDE cable as a parallel port instead and write windows 2k/xp code 🙂 muuuuch better
        THAT you can search HAD for “IDE stk200”
        but make it more then 8 bits instead of 4 bits to mimic standard LPT port wirings. IDE is 16 bit.

  7. bio says:

    how nessary is the external crystal?

    this would make it so much simpler to shove arduinos in to circuits

    • Garbz says:

      Unnecessary.

      External oscillators are often required if you want to do software USB (and don’t want to overclock), use the fast capabilities of your chip (16MHz), need an accurate clock for rock solid high speed serial transfers, or are doing any sensitive timing applications (and this does not include building clocks where a RTC is often a better option).

      I’ve only really needed an external oscillator once. Plus using the internal oscillator, the clock div option, and a few other tricks you can get your power consumption down really low.

  8. lamer says:

    how will this affect 9600 serial communication?
    with temperature changes?

    /Lamer

    • Garbz says:

      It provides you the option to improve it. 9600 baud gives a 0.2% error rate with a 16MHz clock as provided on the board. The internal RC oscillator can be configured down to 7.3728MHz giving you a 0% error at at any standard board rate.

      It’s quite stable too.

  9. Brian says:

    I’m not quite sure what’s going´on here. You get featuret on HAD to drive a microcontroller without a crystal? wow, it swept me off my feet.

    • svofski says:

      That’s the effect of the cargo cult that Arduino is causing. People don’t know Atmel from AVR, Arduino from microcontroller, resonator from oscillator and now they have discovered fuse settings. Oh boy, what they will think of next!

  10. Kinda lame post, I guess everyone knew you can program a microcontroller in different ways and that they usually have internal oscillators too.

  11. Malikaii says:

    Not everyone knew that.

  12. Troy says:

    Good idea, however the video should have gone in to a little more “arduino” detail here.

    How do I set the fuses using the Ardiuino IDE, etc.

    How do I reconfigure the IDE so that I can use these additional two pins.

    • Daid says:

      “How do I set the fuses using the Ardiuino IDE, etc.” You can’t. Arduino is strictly bootloader, and a bootloader cannot change fuses.
      “How do I reconfigure the IDE so that I can use these additional two pins.” The same way you SHOULD use the other pins. With the correct registers.

      • Troy says:

        I don’t think this is entirely correct.

        “You can’t”
        Last time I used the burn boot loader option in the IDE the fuses were also set. I understand they are referred to from the board.txt file and set. Something here would just need to be modified depending on the chip used.

        “Arduino is strictly bootloader”
        There is a lot more to Arduino than the bootloader. Libraries, IDE, etc.

        “the same way you SHOULD use the other pins. With the correct registers.”
        Isnt the whole point of the arduino ide/libraries to not have to use the port registers? Otherwise i’d just program straight avr-gcc.

Speak Your Mind

*

Related Hacks in arduino hacks

  • Garden sensors measure soil moisture and greenhouse temperature
  • More pins and more power with a DIY Sanguino
  • A much easier take on an Android garage door opener
  • UnoJoy makes your Arduino play well with Xbox 360 or PS3
  • RC car controller and receiver replacement