Friday, January 09, 2004

java on a microcontroller

dinesh and i are working on a project in barc. the project is basically programming a 8051 microcontroller dervivative to first store data from various digital detector devices and then transmit that data at periodic intervals to a central station. many such kits are installed all over the country, and regularly collect important data. the chip should be able to send the data either over phone lines (like normal dial up), or ethernet (a v-sat link), or GSM (mobile communication), or internet (dial up to an isp).

as the project goes on i'll try to keep you updated.

for now i'll speak about the heart of the project, the microcontroller. we are using DS80c400, from dallas semiconductors. see www.maxim-ic.com. this is a very advanced chip. it has serial ports, an ethernet port, a can bus(more on this later) for connectivity. the chip has 1mb ram, and 1 mb flash rom, a real time clock, and a tcp/ip stack along with a mac address and support for ipv6. also the chip can be programmed in assembly, C, or my favourite java.

the chip has a tcp/ip stack. so after we give it an ip address, we can actually start an ftp or telnet server on the chip. the chip supports *nix style commands like adduser, rm, ls, df, etc. and the superuser is root. so basically you can remote login to the chip and then transfer files or issue commands to the shell. there are two processes running always. a init process and a second java GC ie garbage collector.

that brings me to java. this chip can be programmed in java, but not any crappy restricted api. but the j2se. you cannot (obviously) run graphics stuff like swing,awt. but it can handle networking, threading, io(also file) other than the basic lang and util stuff. we have conected the chip, actually motherboard to the local network hub by rj45 cable and assigned an ip add. java files are then written and compiled on a seperate pc. these are then converted to a .tini file. tini is actually a java based propriety framework by dallas semiconductors. it packages all the necessary .class files and adds some more info. this tini file just has to be transferred by ftp. next java the .tini file. thats all. in normal java apps, the jvm executes the class file and the garbage collector is actually just a daemon thread. but in this implementation, the gc is a seperate process. you can read more on tini on the dallas site(which even i have to).

so far we have implemented a test server. we start a ServerSocket like in an earlier blog and wait for connections. then the incoming Socket input stream is read (which should be from central station). this will be some command, like say provide current chip time. then the Server returns the appropriate message or error.

some more links
DS80c400
TINI

No comments: