Showing posts with label AVR. Show all posts
Showing posts with label AVR. Show all posts

Monday, June 7, 2010

AVR development on Mac OS X with XCODE


Are you an AVR fan who has recently migrated to Mac and disappointed by the lack of AVR support for Mac users? Specially if you have been working on CVAVR and AVRStudio for development, and now you realise that there is no such GUI available for Mac.
A closer look at the situation reveals that there is ample support and resources available for here which I will list one by one.

Alternative 1 :
Install VMware on Mac and run all your old windows programs without a glitch. The disadvantage is that running another OS like XP, more so if its Windows 7, consumes a lot of resources and your system performance goes down. Nevertheless, you can give it a try if you have a free/ trial copy of VMware, and of course XP.

Alternative 2 :
As we all know avr-gcc compilers are available for linux and Mac as well. So you can download and install them and start writing programs and burning them from Terminal command line. This might turn out to be a tedious task if you are new to command line. You are bound to falter once while changing fuse bits through command line and this results in killing your poor Atmel chip.

To burn fuses without burning the chip, there is a nice application available for Mac called the AVR Fuses . This application provides the same interface as your AVRStudio for changing fuses and programming your chip.





This GUI uses avrdude to program the fuses as well as the program memory. (I will explain installing that later). Just go to the preferences and set the right path to avrdude and the programmer port and it begins to work.

Note : If you plan to use a USB to serial converter like the one from prolific you need to install a PL2303 prolific mac driver which is readily available on the web.

Alternative 3 :
A similar but more useful app called the AVR Tools also has a built in serial terminal. So this eliminates the need for XTerm etc. The environment is slowly building up to give you a good experience. This app has a whole list of programmer support ranging form USBasp to the simple sercon mini programmers. Select the port form the dropdown list which is automatically populated depending on the available serial ports (USB to serial adapters, bluetooth serial ports etc.). This as well requires installing avr-gcc and avrdude. I would recommend AVR-Crosspack for installing the avr-gcc toolchains etc. To configure it rightly, please follow Lady Ada's tutorial . Please follow it step by step.



Alternative 4 :
Till now we haven't come across a native IDE for AVR development on Mac. We haven't yet explored the beauty of development on Mac. If you are not familiar with Xcode, its the native development environment for Mac. It has an amazing GUI. Yes, you are thinking in the right direction. We are about to use Xcode for AVR development. Please install and test AVR-CrossPack and configure it correctly before you proceed.
Xcode provides you option for creating project templates. A great person has created a nice AVR template for us. Download the template folder from the following link:

and copy the folder into the directory:

/Developer/Library/Xcode/Project Templates/Others/
or,

/Library/Application Support/Developer/Shared/Xcode/Project Templates/

Now run the Xcode and click open a new project. A template chooser like one of the following will appear depending on where you had copied the folder in the previous step.



Select the AVR project or the Atmega project. On the left pane you see firmware folder. Expand it and you will see 2-3 files including main.c and makefile. main.c is the file you need to edit and write your project in. After writing the code click on build and a hex file will be created in the project folder. From the Release dropdown list on top left, you can choose to flash the microcontroller if the write programmer and options are set in the makefile.

You can also edit this template to include some default things by opening the project file from the directory you copied in the first step. For example, I edited the template so as
1. to use particular serial port by default by editing the make file
AVRDUDE_PORT = /dev/cu.STK500-1-GenericSerial
2. to use a particular programmer type by editing the make file

AVRDUDE_PROGRAMMERID = stk500v2

3. I often use delay functions. So I made a delay.h header file and included it in main.


I made some more changes in the make file to write all the build files in a subdirectory of the project file to prevent it from unnecessary cluttering.

Later, I connected a bluetooth serial module to the programming port of my STK500 board and began flashing it wirelessly from my Mac. So now when I press the build button, it automatically compiles the code and burns it on the microcontroller wirelessly :P . Details about it in the next blog.


Hope you have a good AVR+Mac experience.

Thursday, March 26, 2009

AVR fuse programmer for MAC

Flashing MCUs or programming fuses in MAC doesn't have much GUI support except for the java based Burn-o-mat. Someone has really taken pain this time to make an open source cocoa based app for burning the AVR (old .NET based version also available). The good part is that he has tried to make the GUI exactly similar to the AVR studio fuse programmer. The software can be downloaded from:
http://www.vonnieda.org/software/avrfuses

During the setup it will ask for the path to avrdude. If you are using AVRMacPack, avrdude is a hidden file with path similar to :
/usr/local/AVRMacPack-20080721/bin/avrdude

Note: Please confirm the location before specifying the path. e.g. you can do so by right clicking the AVRMacPack manual in application folder and clicking show original.

If you are using prolific based USB to serial converter don't forget to install the driver. Interestingly, an open source driver is available for the same which performs better than the one provided by prolific. Its available at :
http://sourceforge.net/projects/osx-pl2303/

Below are some of the screen shots:



Wednesday, February 11, 2009

Atmega Webserver part II

My mid-semester exams got over on the 4th Feb. Miraculously these were one of the best midsems of my stay at IITK. It somehow filled me with new zeal of doing things and I started out on a mission for which I have been planning for long. Got a blog registered in the name of AVR India - a platform to bring AVR developers in India under one roof. As of now I have started posting AVR tutorials for the beginners. After 3-4 days of continuous work and hopping between various domains and servers, I have already written 4 tutorials at :avrindia.blogspot.com . Just waiting for google site project to take some good form so that I can formally shift there.
Then I got back to my old project "the Atmega webserver" which had been lying deserted for a month. I finally learnt HTML for completing it and displaying real time data on it.



I even connected a temperature sensor(LM75) to the atmega this time which is read using the in built ADC of atmega and the temperature displayed on the page. In addition I gave a button on the page which shows the status of LED connected to the atmega. The LED can be turned on/off by pressing the button on the page. So now I can control my room lights and fans and any damn appliance remotely (yes, from anywhere in the campus :) ) . But this wasn't giving the temperature in realtime. It was a static page so had to just put in a small line to refresh the page every 20 secs. This created another problem. The page was reloading from the cache so not giving the correct readings so had to auto redirect the page to itself every 20 secs. The page looks in good shape except that it doesn't seem to work at some places in the campus so I am still trying to figure out the reason. I added the gratitious ARP broadcast to be done when the server starts but doesn't seem to work much.

Friday, January 16, 2009

The IMU_Bluetooth_Phone



The picture shows the final form of the IMU. Finally it was able to display the data received from the IMU on a cellphone screen. The best part being that its the cheapest display with built in bluetooth receiver and java programming platform. The standalone bluetooth module cost around 3600 rupees while the phone just costs 3000 rupees. A four member team from RDSO (including their R & D director ) visited the lab yesterday. I reached the lab at 12 pm exactly 5 minutes before the beginning of the presentation. They were pretty glad to see it. They apparently want it to be used in their railway track inspection vehicle. The existing methodology involves "a few engineers who keep gossiping on the inspection vehicle and as soon as they regiter any jerk they stop to check for crack or defects in the track" Using our device the system can be automated. They rather want a GPS module to be combined with the system and the location of the defect be transmitted directly to their control station.
Regarding the detailed discussion they have invited us to RDSO - hoping for some good deals to improve our country. :) In the evening we packaged the kit in a RP made box of the size of matchbox. The IITK logo on the box looked elegant. We gave it to Sir who took it yesterday night itself for demonstration in some aerospace conference in Bangalore.

Saturday, December 20, 2008

Web server on Atmega !!



After a long period of dormancy I make a re-entry into the AVR world with the tiny webserver. Thanks to tuxgraphics, Palash and obviously the one seeking it the most "The Lord" :P.
Weird and unusual as always was the way in which it worked. First of all I needed the RJ-45 connector (to connect to the lan) but I couldn't find it so I managed to take out one from an old LAN card along with the transformer. Then some hack into people's code and TCP stacks. After 4-5 days of effort , the yellow and green light on my board began to blink at ip 172.26.6.248 ( in TMRS lab) indicating that the link is up. At 4 a.m. Palash and me ran the webserver successfully on Atmega32 which takes a message from the user and displays it on my terminal along with sender's ip. If the message happens to be my signature it displays "Hey!!You appear to be my Friend".

Visit the server @ http://172.28.6.248 (set no proxy)
For more pics click here
By the way we were supposed to be making a project proposal as usual for Vyas Sir and Shantanu has already fallen asleep and I too have a long day ahead workig for Techkriti.

Further reading http://kshdeo.blogspot.com/2009/02/atmega-webserver-part-ii.html