Go Down

Topic: Butterfly -> Arduino (Read 5124 times) previous topic - next topic


I have an AVR Butterfly sitting on my desk and was wondering if there is any way to use the arduino language and IDE with it. Is the bootloader 168-specific or can it deal with a 169?
Has anyone tried this ?


I looked at doing this, and noticed that the big problem is that all the pins on the butterfly are USED.  You might think that you could put some sockets in the headers and implement your 13+6 arduino IOs, since the 169 starts with so many more pins than than the 168, but all the 169 pins are CONNECTED to something.  (Many are connected to the LCD, and you really don't want non-LCD waveforms on those pins if you don't want the LCD display to die an untimely death...)

So I gave up on the idea.


I'm a bit late coming to the party, but I thought I'd start by saying that the statement about limits on Butterfly pins isn't exactly correct. You can see what I've got to say about this in detail at:

[TUT] [HARD] Butterfly Alternate Pin Uses

In brief, the LCD shared pins will only have a problem is the output is DC and for an extended period of time. I use these pins to run a variety of DIP switch and LED experiments and while the LCD elements do dance, they don't seem to degrade. You can also get access to some of the JTAG pins for ADC.

I think the Butterfly would be an excellent platform for the Arduino philosophy and will be looking deeper into this myself.

[edit]Oh, bother, this is my first post so I can't add an URL so I'll put that in the next post[/edit]



Let's see if it will take it now:
[TUT] [HARD] Butterfly Alternate Pin Uses



(In case people don't know, "Smiley Micros" is THE major 3rd party distributors of AVR Butterflies, along with assorted accessories, books, and  educational kits based on the Butterfly.)
His presence here in arduino-land bodes ... interesting things, perhaps?


Thanks smiley and westfw, the  www.smileymicros.com site looks to have lots of useful butterfly information and stuff.

If either of you are looking to get arduino code running on the butterfly I would be happy to try and help. I have a butterfly on my desk waiting for an interesting challenge.


Well, I can't commit to anything for sure, but I have taken several days to dig into Arduino/Wiring/Processing since I was well on my way to reinventing the wheel on 'novice friendly microcontroller engineering' with some recent work that I've been doing.

It looks like to me that the folks who have generated all this have a keen insight into the things novices want to do and have come up with ways around the many traps that prevent the novice from doing those things.

I have read several philosophical statements by the originators that make me want to sigh, 'Home at last!'. Especially after arguing with some of the buggers on AVRFreaks who think you should be able to read the data book, memorize the AVR assembly language, and program in C on a PC before even touching the microcontroller.

I've had folks there really bash ideas that I've put forward, that are very similar to the sorts of stuff that the Wiring/Arduino folks are doing so well. I think a bright and interested person with no technical background can be blinking LEDs and reading switches in a couple of hours, and be downright dangerous in a couple of days. And have fun learning this stuff.

It feels great to see a community that validates your personal prejudices. :)

Anyway, I'm reading through some stuff and trying to see if I can bend the pins_arduino.c file into something that will work for the Butterfly and still be compatible with the Arduino philosophy.

I want to get a much better background on all this before talking too much more.



I wasn't sure where to post this so I put it in the Hardware Development forum: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1222630663
It discusses what I'm planning on trying with the Butterfly - and I sure would like some feedback.



Welcome to the Arduino Forums O Great AVR Freaks Refugee Smiley--even though you may not be as inexperienced as most of us here, I hope you feel free to stick around. :D

It's also cool to read an experienced AVR developer wanting to enable as many people as possible to use it AVRs as a tool--I guess that's why you wrote a book... :-)


P.S. I found a copy of Nuts & Volts in New Zealand last week and noticed your second AVR column in it.


Thanks for the welcome :)

I'm glad to see that Nuts&Volts is in New Zealand, I didn't realize that it is international. You can get a copy of these articles on my website, one month after they appear in the print edition.



Just done a first pass of the butterfly version of the arduino12
You can download my files from http://www.brokentoaster.com/arduino012_butterfly.zip

Any thoughts or feedback most welcome.

Things you need to do to make it work:

* copy the files & folders into your arduino Hardware directory.

* change preferences.txt to upload.using=butterfly

     This preferences file is found in this folder:

         * /Users/<USERNAME>/Library/Arduino/preferences.txt (Mac)
         * c:\Documents and Settings\<USERNAME>\Application Data\Arduino\preferences.txt (Windows)
         * ~/.arduino/preferences.txt (Linux)

* push the button when uploading starts
* dont hold the button down the entire time.

Things to do in the future:
Butterfly library for
     - temperature
     - flash
     - light sensor
     - speaker
     - LCD
     - Joystick
- check analog pins (jtag port)
- check digital pinouts on port b and D
- check all the timmings
- check it makes sense.      


These are things I've done in the files to make it kind of work. They may or may not be necessary.
I tried using conditional compilation but I wasn't being picked up so I just copied the core and
made changes to that.

* added following to boards.txt to support as a target compilation board




* added Bf_boot to bootloaders dir
     - copied hex from bf_boot up to bootloaders/bf_boot and renamed bf_boot.hex

* removed second external interupt from hardware/cores/arduino/WInterrupts.c: -> changes not picked up??

* changed boards.txt core = butterfly
     - copied arduino core folder and renamed to be buttefly
     - changes to hardware/cores/butterfly/WInterrupts.c
     - changes to hardware/cores/butterfly/wiring.c  TCCR0 - > TCCR0A  
     - changes to hardware/cores/butterfly/wiring_analog.c: In function 'analogWrite':
     - changes to hardware/cores/butterfly/wiring_digital.c: In function 'turnOffPWM':

* added avrispv2 to programmers.txt
* added butterfly to external programmers




Great news that you are doing this. I'll look at this in a few days. I've also been working on something similar off and on for a while, so it will help to look at what you are doing when I can get back to it. I suspect we may be duplicating some efforts, but let me check what you've done and I'll get back to you. No use both of us doing this.

And you are the guy with the dangly cigaretted on AVRFreaks aren't you?



Dec 05, 2008, 01:13 am Last Edit: Dec 05, 2008, 01:14 am by merlin13 Reason: 1
I'm really new with microcontrollers so please bear with me if I ask really stupid questions.

Nick, the work you did sounds great and since I have a Butterfly, I was thinking to give it a try. One question though: using your Arduino-like modifications, can I still use the serial cable I regularly use to program my Butterfly? Or do I need a parallel one (of which I had one when I fixed the 0x940c error but I misplaced it somehow).

BTW, thanks Smiley for your posts on avrfreaks, they helped me a lot to fix my Butterfly when I thought it was dead for good with the 0x940c error.

Thanks for your work and for reading.


Dec 05, 2008, 04:28 am Last Edit: Dec 05, 2008, 04:51 am by DaveK Reason: 1
using your Arduino-like modifications, can I still use the serial cable I regularly use to program my Butterfly?

I'm not Nick, but yes you can use the regular serial cable (that's what I'm doing and it's working).

There's something wonky going on with the clock speeds that I haven't worked out yet, but so far so good.
[edit]The wonkyness was entirely me, evidently delay(1) doesn't actually delay for 1mS, but delayMicroseconds(1000) does. It's working great now.[/edit]


Dec 05, 2008, 05:29 am Last Edit: Dec 05, 2008, 05:30 am by mikalhart Reason: 1
evidently delay(1) doesn't actually delay for 1mS

That's an interesting point.  delay(n) is implemented in such a way so that the actual delay is betwen n-1 and n milliseconds.  I think a better implementation would be to make sure delay waited at least n milliseconds before returning, similar to the way other environments operate.


Go Up