At the moment, I have two main Arduino project ideas:
- Sunrise alarm clock (active)
- Virtual Memory on the Arduino Uno (waiting until summer)
You may (or may not) have heard of these before. Basically, a sunrise alarm clock is a clock that slowly raises the light level in the room to simulate a sunrise. The idea is to clue your body in that it's almost time to wake up, so you can come out of deep sleep cycles and wake up naturally. It may also help get your circadian rhythm on track in places with poor sunlight, like Seattle. These sunrise clocks are available commercially, but they can be pretty expensive (most are $70+).
As an Arduino project, this has value because it requires:
Accurate clock time
- to change the brightness at the right time
Control of 120 volt AC
- to control the lighting
LCD display
- current time, alarm time, settings, etc.
SD card access (optional)
- loading clock settings from file
Web server (very optional)
- set clock settings via HTTP from an Arduino-hosted local webpage
Virtual Memory on the Arduino Uno
If you have used the Arduino Uno, you may have noticed that in complicated projects, the first thing to run out is your available RAM (The new UNO has 2Kb of stack/data space RAM). Typically, the device just stops executing code when this happens. The way this problem is solved currently in full-size computers is with virtual memory.
Basically, when the device is running low on memory, the virtual memory manager takes a chunk of RAM, saves it somewhere else, and opens up the free space for other parts of the program to use. When a value is needed that was moved out of RAM, the virtual memory manager moves the original chunk back to its place in RAM and swaps or pages the current RAM out. On desktop systems, virtual memory is swapped/paged out to the hard disk. This trading process allows each process (basically, each running program) on a 32-bit computer to have access to 2GB of virtual RAM, even if the computer itself has only 256 or 512 MB of actual RAM. The tradeoff is that each virtual 'swap' takes time.
On the Arduino, we do not have a standard desktop hard drive. Instead, with the Ethernet board, we get access to an SD card, essentially a flash memory hard drive. My hope is that the flash memory will run fast enough to make the virtual memory operation reasonably quick, even with the UNOs 16MHz processor clock speed.
There is one very significant hurdle for building virtual memory on the Arduino UNO: The processor does not have memory-based interrupts or a memory management unit. In most desktop systems, the processor will stop and ask the operating system to interpret any virtual memory address it tries to use. The memory management unit helps by remembering some of the operating system's answers, which makes virtual memory on a desktop (or laptop, etc) computer much faster. In the Arduino UNO, the processor will not ask for a virtual address translation at all. So how will we know when it is time to page the memory in and out to the SD card?
I talked with one of the professors at my university (University of Washington - Seattle; go Dawgs!) and we had some vague idea that it may be possible to change the assembly code of the program to make the memory conversion happen in software rather than in hardware. A few Google searches brought up this paper, which also uses this idea. Basically, we replace every data memory reference with a call to the virtual memory manager.
As an Arduino project, this has value because it requires:
Knowledge of the UNO's memory structure
Extensive programming in C++ with pointers/etc.
Familiarity and re-engineering of Bill Greiman's sdfatlib for the SD card (tutorial here)
Work with assembly code
Possible work with the compiler avr-gcc
Goal:
The goal of the project is to release a virtual memory library for the Ethernet shield that increases available RAM with little or no configuration from Arduino programmers like you!
No comments:
Post a Comment