Archive

Archive for August, 2007

Arduino GPS

August 27, 2007 Pari 3 comments

Just to get my hands dirty and wrap it up with the AVR’s, I created a GPS data logger – using an Arduino board, GPS receiver chip, 4×20 LCD, and a uALFAT microSD board.

A good document on NMEA commands and data formats used by GPS chips is here. Regarding the GPS unit, it was SiRF vs Trimble, and I went for SiRF, the SiRF III (the EM-406A by USGlobalSat). I picked it over the Trimble Lassen IQ and the Parallax.

Of course you can buy a GPS data logger board with LCD for about $200. But the whole point is that it’d be a learning exercise, an interesting one :-).

I decided to write it in raw C (UART driver, LCD driver, flash data logger,…) instead of Arduino’s Wiring language. This amounts to pretty much reading most of the 300 page data sheet for the MCU, giving you a thorough understanding of all aspects of the MCU – GPIO, clocks, counters, interrupts, UART, SPI, I2C,… all related considerations like registers, masks, timings, memory organization,…

(photo updated, 12/2007).

Categories: AVR

Internet Radio on the Slug

August 26, 2007 Pari Leave a comment

There are a good number of streaming radio channels on the net that would like to listen to — without leaving my power-guzzling (and really noisy) 400W computer on just for that.

The slug as an internet radio turns out to be an ideal solution for this. Its low power (under 5W) and compact size makes it ideal as a radio replacement. No longer forced to choose from local stations.First you’ll need to have a sound device for your slug. I got a USB Sound Device off of eBay for about $6 (including shipping). Sound clarity is very good for something so cheap.

The application you need to get is mpd (Music Player Daemon). If you’re running Debian/ARM just do:

apt-get install mpd
/etc/init.d/mpd restart

mpd itself doesn’t do anything, it just sits there, listening on default port of 6600 for commands. You’ll need a client. I use mpc (a command line client). There is also a nice plugin for Firefox called FoxyTunes.

First set up these environment variables pointing to your mpd:

export MPD_HOST=your_slugs_ip
export MPD_PORT=6600

Add a station (you can find stations on Shoutcast directory; note that mpd remembers the list of stations and which station it left off at and automatically streams it after rebooting):

mpc add http://www.live365.com/play/wamu3

Or you can create a play list and put it in /var/lib/mpd/playlists. Sample file (say radio_stations.m3u):

http://www.live365.com/play/wamu3
http://195.56.146.98:8002
http://64.202.98.133:2220

And load it:

mpc load radio_stations

Play:

mpc playlist
mpc play 2
mpc volume +5

Categories: Linux, Slug

Arduino LCD

August 25, 2007 Pari Leave a comment

Interfaced a 4×20 character LCD panel to the Arduino. Details on interfacing any Hitachi HD44780 based LCD panel can be found here.

I went for the default parallel LCD’s. They’re cheap, about $15 for a 20×4 panel on eBay (HD44780). The serial ones cost about 2-3 more. These LCD panels allow you to use 4 data lines (with some bit-banging) instead of 8. Get one that is STN and transflective (vs reflective and transmissive), known for better contrast and brighter.

Check out also LCDProc.

Categories: AVR

The Arduino

August 24, 2007 Pari Leave a comment

Just got it today :-) More than anything, the Arduino is a great learning platform for anyone interested in the embedded world. The entire platform is open (hardware schematics, bootloader, lots of examples, etc.).

Arduino comes with a nice language that abstracts out lot of the bit-level stuff. But for learning purposes I’d recommend just using C – i.e. to get right down to the metal to get to know the AVR. Ubuntu has a nice ready-made GNU C toolchain for the AVR which works quiet well. There is also an Eclipse plugin. You’ll probably end up reading two-thirds of the 350 page ATmega168 specs… but very worthwhile. Once you’ve done one, you’re all set to handle any 8-bit MCU. I found Atmel’s AVR docs are very well done, complete with assembly language and bit-level C-language code snippets.

Also, check this site out: Atmel AVR Application Notes. Tons of stuff. You don’t really need to buy any embedded systems books. The stuff here plus the Atmel AVR 8-bit Instruction Set set document should be all that you need.

Categories: AVR

ATmega128

August 22, 2007 Pari 2 comments

The Atmel ATmega128 AVR is a nice little full featured 8-bit MCU. It is as good as it gets among general purpose MCU’s (i.e. not including MCU’s which add on a host of other features like controllers for LCD, USB, Ethernet MAC, DSP, MMU, etc.).

For my own quick reference:

Feature ATmega128 ATmega168 ATmega8
Flash 128K 16K 8K
SRAM 4K 1K
512
EEPROM 4K 1K
512
UART 2 1
1
8-bit Timer 2 2
2
16-bit Timer 2 1
1
PWM (channels) 6+2 5
3
10-bit A/D (channels)
8 6
8
DebugWire/OCD Y -
-
Analog - Y
-
JTAG Y -
-
SPI 1 1
1
TWI 1 1
1
Categories: AVR

Cloud Computing

August 15, 2007 Pari Leave a comment

For those of you who aren’t in on it, check out Google’s Cloud Computing and Amazon’s EC2 (Elastic Computing Cloud). Amazon and Google have tons of computing power and storage sitting in huge server farms. Now they’re making it available for you.

Of the two, Amazon EC2 service is ahead of the game. If you ever need a clean Linux server for testing, you can create one with just one command, use it, and delete it. The basic instance gives you a 32-bit server with 1.7 GB memory and 160 GB storage.

There is also the Amazon’s S3 service which lets you purchase storage in the cloud. I use S3 service for backing up data that I need to access while on the go, and for sharing large files (you can even setup ACL’s). Data is stored encrypted. They charge $0.15 per Gigabyte per month.

There is also a FUSE utility that lets you mount/unmount it. Anything you drop into the S3 folder gets automatically transfered to the S3. You can even rsync to it.

See also: 9 Hidden Features of Amazon S3.

Categories: General

Which RTOS?

August 14, 2007 Pari Leave a comment

After scouring through tons of MCU’s I’ve decided to go with the Atmel AVR, in particular the ATmega168.

But then, my recent adventure into the Slug’s hardware, got me thinking ARM. After much researching, I settled for Atmel’s AT91SAM7 series of ARM MCU’s.

My next thought was how I can run Debian/ARM on it. But unfortunately that was quickly ruled out – as the largest of the 7S or 7X series has only 512K Flash and 128K SRAM. Note that the 7SE series has an external memory bus.

So what can I squeeze into 256K Flash and 64K RAM? My hunt came up with these top 3 (in terms of the number of microcontrollers each has been ported to):

  1. FreeRTOS (्free)
  2. uC/OS-II (commercial)
  3. eCos (pdf book: Embedded Software Development with eCos)
  4. TNKernel (free)

And these bootloaders:

  1. u-Boot
  2. Redboot
  3. Apex

Categories: ARM

Where to get parts ?!

August 12, 2007 Pari Leave a comment

Where do you go for basic electronic parts in the USA!? like resistors or capacitors (in single quantities, i.e. without having to bulk order them)?

Back in India (and I think in most South Asian countries) most major cities have streets/bazaars full of electronic component shops (no not consumer electronics, but components, semiconductors,…). It’s a electronics engineers heaven to find stores like that. It is so frustrating not to find something like that here in the USA, and RadioShack just doesn’t do it for me. But I did find some online shops:

Categories: General

Slug – Install

August 12, 2007 Pari Leave a comment

All these slug notes are for my own future reference in I decide to get some more slugs down the line :-). Just putting it out here to share.

I’ve installed Debian 5.0.1 (i.e. Lenny), on a 2GB flash drive (connected to USB port 1).Created a root partition of 1.5GB, and swap of 512MB on the 2GB flash drive:

Disk /dev/sda: 2041 MB, 2041577472 bytes
61 heads, 60 sectors/track, 1089 cylinders
Units = cylinders of 3660 * 512 = 1873920 bytes
Disk identifier: 0×000667ca

Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1         816     1493250   83  Linux
/dev/sda2             817        1089      499590   82  Linux swap / Solaris

Did the installation via flashing the debian installer image using upslug2 method as described here. At the end of the installation of the minimal Debian system, it flashes the new kernel and initrd to the Slug’s Flash.

Added the following extra packages after installation using apt-get:

apt-get install alsa-utils apache2 autofs bind9 bmon bzip2 chkconfig cups curl dhcp3-server dropbear irb ldap-utils lsof lynx nfs-common nfs-kernel-server pciutils portmap psmisc rtorrent ruby sasl2-bin samba screen sg3-utils slapd sudo sysstat tcpdump vim-runtime xauth

You don’t want to have all those services running given the limited memory the slug has, so you can remove the services you need from auto starting by this command (the equivalent of chkconfig command in Fedora/Redhat):

update-rc.d -f service_name remove

To restore the default runlevels, run:

update-rc.d service_name defaults

See Also:

Categories: Linux, Slug

Slug – Cups

August 12, 2007 Pari Leave a comment

Printer settings in /etc/cups/cupsd.conf (just the most relevant sections to get you started):

# Only listen for connections from the local machine.
Listen localhost:631
Listen 192.168.1.77:631
Listen /var/run/cups/cups.sock

# Show shared printers on the local network.
Browsing Off
BrowseProtocols cups
BrowseOrder Deny,Allow
BrowseAllow from @LOCAL
BrowseAllow from @IF(eth1)

# Default authentication type, when authentication is required…
DefaultAuthType Basic

# Restrict access to the server…
<Location />
Require valid-user
Order Deny,Allow
Deny From All
Allow From 127.0.0.1
Allow From 192.168.1.0/24
</Location>

# Restrict access to the admin pages…
<Location /admin>
#Require valid-user
Require group printadmins
Order Deny,Allow
Deny From All
Allow From 127.0.0.1
Allow From 192.168.1.0/24
</Location>

Then reload the configuration:

service cups reload

Plug the printer into the USB (if it isn’t already).

Next, from your browser bring up the Cups Printer Administration tool, running on the Slug’s port 631:

lynx http://slug:631

and follow the steps there to detect and the printer that is connected to the slug. After that is done you’ll find a printers.conf in /etc/cups directory, containing details of your printer.

Accessing your printer

You can access your printer via IPP. In Ubuntu 8.10, under add New Printer, select “Internet Printing Protocol” and specify the URI. For example, ipp://slug:631/printers/Samsung_ML-2010

Sharing Printers via Samba

Printer settings in global section in /etc/smb.conf::

[global]

load printers = yes
printing = cups
printcap name = cups
cups options = raw

My printers section in /etc/smb.conf:

[printers]
comment = All Printers
browseable = no
path = /var/spool/samba
printable = yes
read only = yes
create mask = 0700
use client driver = yes;
admin users = @printadmins

# If you want anyone to be able to use your printer then keep this:
guest ok = yes

# If you want to restrict users, then comment out above and uncomment this (make sure user1 is in the samba db).
;valid users = user1

Categories: Linux, Slug