Pages: [1] 2   Go Down
Author Topic: Butterfly -> Arduino  (Read 1693 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 58
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 ?
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 106
Posts: 6378
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Great Smokey Mountains
Offline Offline
Newbie
*
Karma: 0
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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]

Smiley
Logged

FREE TUTORIAL: 'Quick Start Guide for Using the WinAVR C Compiler with ATMEL's AVR Butterfly' AVAILABLE AT: http://www.smiley

Great Smokey Mountains
Offline Offline
Newbie
*
Karma: 0
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Let's see if it will take it now:
[TUT] [HARD] Butterfly Alternate Pin Uses
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=45064

Smiley
Logged

FREE TUTORIAL: 'Quick Start Guide for Using the WinAVR C Compiler with ATMEL's AVR Butterfly' AVAILABLE AT: http://www.smiley

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 106
Posts: 6378
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

(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?
Logged

London
Offline Offline
Faraday Member
**
Karma: 8
Posts: 6240
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Great Smokey Mountains
Offline Offline
Newbie
*
Karma: 0
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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. smiley

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.

Smiley
Logged

FREE TUTORIAL: 'Quick Start Guide for Using the WinAVR C Compiler with ATMEL's AVR Butterfly' AVAILABLE AT: http://www.smiley

Great Smokey Mountains
Offline Offline
Newbie
*
Karma: 0
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Smiley
Logged

FREE TUTORIAL: 'Quick Start Guide for Using the WinAVR C Compiler with ATMEL's AVR Butterfly' AVAILABLE AT: http://www.smiley

New Zealand
Offline Offline
God Member
*****
Karma: 0
Posts: 999
Arduino pebbles
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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. smiley-grin

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... :-)

--Phil.

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

Great Smokey Mountains
Offline Offline
Newbie
*
Karma: 0
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the welcome smiley

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.

Smiley





Logged

FREE TUTORIAL: 'Quick Start Guide for Using the WinAVR C Compiler with ATMEL's AVR Butterfly' AVAILABLE AT: http://www.smiley

Oxford, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.      
 
OTHER NOTES:

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
      bfly.name=Butterfly

      bfly.upload.protocol=butterfly
      bfly.upload.maximum_size=14336
      bfly.upload.speed=19200

      bfly.bootloader.low_fuses=0xE2
      bfly.bootloader.high_fuses=0x98
      bfly.bootloader.extended_fuses=0xFF
      bfly.bootloader.path=butterfly
      bfly.bootloader.file=bf_boot.hex
      bfly.bootloader.unlock_bits=0x3F
      bfly.bootloader.lock_bits=0x0F

      bfly.build.mcu=atmega169

* 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


www.brokentoaster.com/arduino012_butterfly.zip
Logged

Great Smokey Mountains
Offline Offline
Newbie
*
Karma: 0
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Nick,

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?

Smiley
Logged

FREE TUTORIAL: 'Quick Start Guide for Using the WinAVR C Compiler with ATMEL's AVR Butterfly' AVAILABLE AT: http://www.smiley

0
Offline Offline
Newbie
*
Karma: 0
Posts: 17
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: December 04, 2008, 07:14:07 pm by merlin13 » Logged

Omaha
Offline Offline
Full Member
***
Karma: 0
Posts: 187
AC0KG
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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]
« Last Edit: December 04, 2008, 10:51:35 pm by DaveK » Logged


Austin, TX USA
Offline Offline
God Member
*****
Karma: 4
Posts: 997
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.

Mikal
« Last Edit: December 04, 2008, 11:30:09 pm by mikalhart » Logged

Pages: [1] 2   Go Up
Jump to: