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.

Sunday, June 6, 2010

Activating Matlab on Mac OSX Snow Leopard

This post is meat for people who are having problem activating MATLAB on OSX Snow Leopard. You should be aware of the fact that MATLAB runs on Mac through Java and not as a native Cocoa application. After the recent kernel upgrade to 64-bit, MATLAB is facing problem writing the license file to the installation folder specially if you are activating in the offline mode with a license file. It gives an error message asking to view the log the file in /var/..../-temp-/ews.log.

To fix this problem is very easy. Actually the Java comes configured to run applications in the 64-bit mode which is causing the problem. Follow two simple steps to resolve it.
Step 1 : Open the java preferences from Spotlight as shown in picture below.

Step 2 : Drag 32-bit option above 64-bit.


Try activating now. It should work.

Wednesday, May 19, 2010

MEMS MOMS IMU tested on Varuna and Indigo




The IMU developed by Rajiv, Praneeth and me in summer 2007 has begun to take some useful and aesthetically appealing form. The latest version which has been developed for the MOMS (MEMS based Oscillation Measurement System) under the supervision of RDSO, Lko was tested yesterday in the AC Chair Car of the Varuna Express. The train was supposed to depart at 4 p.m. and we reached the station at 3.55 p.m. and got into an empty luggage bogie. The train started to move and Shubham found out that we had to get into the chair car. We ran on the platform and got aboard in DDLJ style while Trivediji was left behind. He joined us at the next station where he was found hanging outside the closed gate of the moving train. Not forgetting the Rs.700 penalty we had to pay for sitting in AC with General ticket, the journey was very interesting and full of fun.

The device which was mounted in the JTAG mk2 case with colorful LEDs from inside looked quite geeky. It had a 2 axis ADIS accelerometer sampling at 1000 samples/sec and a 5Hz GPS module for geotagging the jerk points. The computer end software which was written by Asna and me was running smoothly on our Chhotuku (the hp mini netbook). We took loads of data on the window of the compartment, underneath the seat and also on the car while going and returning. The GPS was initially giving half the actual speed, and was calibrated on the go to give very very accurate result updating at 5Hz. We monitored jerks on the track and also Shubham's foot bangs on the floor. Later while returning we even monitored the car on turns for centripetal acceleration.
Sairam had enormous discussions with Mr. Gregory on the case design of the device and has come up with very sleek CAD models for the same.
We got down at Charbagh station where Ramchanderji had arrived on the taxi to pick us up. Thanks to everyone involved.

Wednesday, February 17, 2010

my Vision my India

Techkriti in the last four years has always meant to me more zeal, more fun, more technologies, more ideas and more inspirations. I had never imagined that this Techkriti might be so dull - sitting in my lab and working on assignments. But the concluding day, Feb 14th, was inspirational enough to make up for the rest of it.

Shubham and myself went on a campaign to collect junta's ideas of an improved India. We asked the participants to pen down their ideas on a chart paper which we would upload on a website. The wonderful logo was designed by Neha which added to our moral boost. The source of inspiration for the drive : MumbaiUnmute --> Shubham -->IITK.

We started with two young ladies in the staff canteen and then went to the SAC. And to our surprise, the response was overwhelming. You just need to carry a DSLR and tell junta that your pic will be on the web and they would do all sorts of somersault for you.

A satellite meeting with the director was also scheduled in the day. We got him as well in the groove.


The rest of the pictures can be seen at :


A very motivating and enthusiastic drive indeed !!

Wednesday, February 3, 2010

Track me live !!


With the instamapper app for iphones, now anyone can track me live. Just click on the link:

With my login, it even shows me the paths I travelled.