Physical Computing

A blog about Physical Computing

Thursday, December 30, 2004

Useful Links JAL FAQ
Here is a link to the JAL FAQ. The associated list os probably quite searchable as well.

Wednesday, December 29, 2004

Useful Tips #1
By default the PIC 16F628 Port A pins are set as comparators, which means that by default you can not use the Port A pins for digital input.

In order to set the Port A pins to be used as digital inputs you need to disable the analog functions. For the 16F628 in JAL you would write



var volatile byte CMCON at 0x1F
CMCON = 7 -- set portA to normal digital IO



Port A.4 is an open collector pin which means you can't use it as an input without a pull-up resistor.

via Potemkin.org

Tuesday, December 28, 2004

Project Roadmap

Here I'm giving a brief overview of where I'll be taking my projects over the next few months. All of them use the PIC to control the project

Project 1 - Make a LED flash

Project 2 - Make a bunch of LEDs flash ala Knight Rider

Project 3 - Make a LED turn on when a switch is turned on and turns off when the switch is off

Upcoming Projects

a - Communicate with your PC using a serial connection on the circuit and Serial->USB interface on iBook with Java reading from the serial port.

b - Read a temperature sensor LM75 and flash a LED when temp. changes by a bit.

c - Link a and b together

d - Communicate with an old Nokia mobile using a serial connection to send SMS messages

e - Link c and d together

f - Add a wireless connection to project b to allow the sensor to be placed a long way away from the base station circuit

g - Link f and d together. Allowing you to SMS to the phone and get the current temp. sent back to you and also to set alerts and have the temp sent to a specific SMS when it changes by a certain amount.

Getting Started

To those who have already covered off this stuff please forgive me and for those of you reading this with my level of knowledge, please comment if you have any questions about what I have done or want more details.

First things first, you're going to need a guide book to help you along. I can HIGHLY recommend Physical Computing by Dan O'Sullivan and Tom Igoe from ITP at NYU in NYC. These guys run courses focusing on Physical Computing and their book is such good value for money that its totally worth buying. Jump off and over it from Amazon now.......

While you wait for the FedEx man or the good old postie, you might like to check out the ITP Physical Computing site, its full of useful comments, links to resources as well as extracts from the book. You'll probably end up referring to the site numerous times, so jump off an book mark it.

You should also sign up for their Physical Computing mailing list. Its not as useful and is really aimed at their students but bits of useful info do drop by. I haven't posted on the mailing list, but I'd imagine if you had a question they would probably help you out.

The Physical Computing book focuses on BASIC STAMP chips and the PIC 18F452, which is a 40 pin chip, as well as being fairly windows focused for the "tools" that they use.

As a bit of background, you develop for the PIC chip by writing the code on your PC, compiling it into machine code (.hex file) and then sending the .hex code from your PC to the chip using a "programmer", which is a physical circuit with a socket for your PIC chip to be placed into. You then take your PIC chip out of the "programmer" and place it into your circuit that you have built and power it up...all things working your circuit should do what it supposed to do.

Now, this means you need a compiler on your PC and a programmer to attach to your PC. At this time, most of the compilers work on the PC and some of the higher level language ones in PIC Basic Pro cost a couple of hundred $$. And, all the programmers I have seen attach to a windows computer with the software which downloads to the programmer, also only being available on windows.

Instead of a windows focuses development environment, I'm using an OS X oriented one with windows only for the "PIC programming" bit.

I'm writing my code in a language called JAL. JAL is a high level language sort of like Pascal and has many built in libraries for doing some fairly standard stuff such as serial communication, reading temp. chips etc. Best of all you can compile it to run on OS X.

Once I have written and compiled the JAL code, I then jump over my windows machine, grab the .hex file off my OS X machine (using the web server, you could just email or FTP it etc).

Attached to my windows computer is a Talking Electronics JDM style PIC programmer which cost all of 14$ Australian including postage. It comes as a kit which took me about 90 mins to put together (being quite careful as this was the first soldering project I'd done in forever). There were no really tricky bits except for the serial cable which took me a little while cause it was quite finiky.

In order to send the .hex file from the windows computer to the Talking Electronics PIC programmer, you will need an application called IC-Prog. This is linked to from the Talking Electronics page. I have found configuring the IC-Prog application a little difficult to understand at first, not knowing all about the oscillators, and the various settings. I'll post on installing, configuring and getting IC-Prog running later as well as building the Programmer.

The downside of the Talking Electronics programmer is that it is limited to 18 pin PIC chips, which means that the 18F452 used in the Physical Computing book is not able to be used with this programmer. (As a note, it may well be possible to attach a 40pin socket with some hacking but out of the box, it won't support it).

If you want to program a PIC 18F452 or other 40 pin PIC chip you will need to get another programmer which supports that chip size. There are plenty of JDM programmers around as well as kits for serial and parallel programmers available at your local electronics shop, so you should be able to track down something that works for you.

Once you have your programmer connected and the programmer software running, you load the .hex file, set the configuration parameters and then "burn" the .hex file onto the PIC chip. Your programmer's LEDs should flash and if things are working ok, you will get a message saying that the programmer worked.

Finally you disconnect your programmer, take out your PIC chip and put it into your circuit to use.

Of course, you are now asking....what circuit???

Well, you will need to go shopping and buy up a breadboard and a bunch of tools (soldering iron, wire cutters, pliers etc) and components (resistors, capacitors, transistors) etc. The Physical Computing book has a comprehensive shopping list and this is also available on the Physical Computing web site (today the site is screwed with what looks like the entire wiki being overwritten by spammers).

I spent about 120$ AUD (or at least my parents did on an Xmas present for me ;-) ) buying everything I needed. I already had a soldering iron which would have cost another $20 and I bought a KeySpan USB to Serial adaptor of future projects on Amazon for around 30$ USD.

Once you have your gear, the first thing you need to build is the "hello world" of physical computing, a flashing LED. It may not sound very much but it proves your end to end infrastructure and shows you have everything working.

Next post I'll talk about my project plans.





A bit of background

As a bit of a primer about where I am coming from, I thought it may help to provide a bit of a background about what I know already and where my skills lie, as well as what I'm trying to do.

I'm a software developer with NO electronics experience or hardware experience beyond being about to config general computer stuff. The last electronics project I formally did was building a flip flop circuit (flashes leds) at a YMCA summer course when I was 10.

I can program in java (J2SE, J2ME) and a handful of scripting languages, no C and no assembler.

I have an Apple iBook which I want to use as my primary tool for these projects and I have access to a windows machine (win 2k) which I can use but don't really want to.

All of this means that I am after OS X/Linux based development options with minimal Windows stuff and I don't want to learn C or Assember.

As anyone who has done any PIC development will tell you, this limits what tools I can use and also means that I'm not your "normal" PIC micro developer and will probably run into many brick walls as I try to do certain things in this environment rather than a MSFT style setup.

Finally, I'm happy to spend money on components to build with but I want to minimise cost for software, programmers, chips etc if possible.

Next post I'll cover off where to start ( or at least where I started).

Welcome to Physical Computing

Welcome to my new blog related to Physical Computing, specifically to the process I have just started of learning about PIC micros, programming them and doing fun things with them.

This blog will serve two purposes..1) a reminder to me about tips and hints I've picked up and 2) hopefully a workable guide to other people like me who wish to start learning/doing physical computing stuff and don't have access to people to teach them.