uJ – Java machine for microcontrollers

Some people just know Java very well and in order to program microcontrollers it would be best choice. But microcontrollers don’t have java Virtual Machine (VM) running in them. So there is a difficulty which has to be removed. Dmitry decided to change things a bit and programmed uJ – Java VM for microcontrollers. Its written purely in C so can be used for most microcontrollers including AVR, PIC and ARM. Lots of things are already done and many are in to do list. But results are speaking for themselves. Biggest constrains here are RAM limits, so few workarounds are implemented in order to work correctly like not coppying classes to RAM, custom stack control and other. JVM is modular so for smaller microcontrollers some features can be turned off in order to fit and leave more space for user programs. You write java programs as you would normally write for PC of course have in mind that MCU has very limited resources. Then boobloader loads bytecode from SD card and execute from Flash leaving RAM free for data. As… Continue reading

Programming AVR chips manually

Once your program is written and compiled, the next concern is flashing and running on a real device. Any programmer adapter does this job quickly. But what if you don’t have an adapter or you are lost on the island with attiny13 in your hands… then you can program chip manually. With some knowledge and patience, you can do this with a couple of buttons. As you may know, avr microcontrollers are programmed through the SPI interface. It consists of four wires – reset, MOSI, MISO, and SCK. So all we need is to control these signals manually. Manually keying, it is possible to program chip bit by bit. SPI programming speed isn’t limited to slow. With buttons connected to these wires, bits can be clocked in. For example, a successful blinking LED program was programmed into Attiny13 that way. It took 425 button clicks to do that. Here is a translated version of the post. Continue reading

Basic understanding of microcontroller interrupts

Earlier I’ve made a mistake by referring this tutorial to first AVR family microcontrollers like Atmega8/16/32/64/128. But AVR is being continuously changed with various new tweaks and updates like enhanced pin control or different register names. Since now tutorial will be based on Atmega328 microcontroller which is popular in Arduino boards. So you’ll be able to test all code examples on Arduino as it can serve as general purpose AVR test board with no problem. Understanding Interrupts Probably you won’t be able to find a microcontroller without interrupt capability. These are essential attributes of any modern microcontroller or processor. They may seem confusing and tricky at first glance, but during the time you will find out that normal MCU operation is impossible without interrupts. Interrupts can be compared to real life events. Look around – all your activities are full of them. For instance, you are reading this tutorial and find it interesting, so you are all in it. But suddenly your cell phone rings. What do you do? You remember the last stroke you’ve read and answered the phone.… Continue reading

Setting up AVR development platform

You can be encouraged to use various types of AVR development tools. Most of them cost money to get full functionality and support. Most common commercial packages are CodeVisionAVR, Imagecraft ICCV, IAR Workbench. All they are great tools out of the box with fast support that you have to pay. Of course, you can give a try with their limited versions to se capabilities as we mentioned before we are going to use free tools that great enough comparing to commercial. WinAVR or AVR-GCC tools WinAVR is a toolset for C programming the AVR microcontrollers. It is a bunch of small programs that make development as comfortable as possible. Main tools here are avr-gcc compiler, avrdude programmer, avr-gdb debugger and even more. These are command line tools, so you need to integrate them into some integrated development environment (IDE). There can be any IDE supporting external tools like Eclipse and of course AVRStudio that we will be using. Besides, WinAVR comes with great program writing tool – Programmers Notepad. Actually, with WinAVR you can write, compile, upload to chip and… Continue reading

AVR at a glance

Any AVR microcontroller is an 8-bit computer in a chip designed and manufactured by ATMEL Corporation. It has some RAM and ROM (Flash) as well. There is also an EEPROM memory. Including AVR core CPU all these are more than enough to say that it is a small computer where you can execute programs stored in Flash memory, run them while operating data in SRAM and storing some constant values in EEPROM. Comparing to the real computer that sits on your table you can say that AVR core is a CPU like AMD or Pentium. Flash memory would be your hard drive where programs are stored, RAM is RAM nothing to add there. EEPROM probably can be compared to some media device like CDRW. Anyway, this is only similitude in a different scale. AVR microcontrollers aren’t limited with core CPU and memory. The main thing what makes them valuable (and any other type of microcontroller) – they are rich in peripherals inside the chip. In most cases, you will find USART, I2C, SPI, ADC, Timers/Counters, and a bunch of I/O… Continue reading

Fridge Thermostat – A Must Have Tool For All Beer Lovers!

Go figure, you’re sitting around on a bench with your family on the warm summer’s night. You and your family are chatting and laughing around happily. It would be even better, if you can have some excellent homebrew beer with your loved ones, isn’t it? Is it impossible for you to spend over thousands of dollars out from your wallet to buy a brand new refrigerator? If you did, then you should consider building a beer fridge here. This fridge thermostat has many useful features, such as: It has a very simple and small design (It can be installed in the fridge easily), Its power efficiency is good and can save a lot of energy, It fully equipped with adjustable temperature setting. In order to power the thermostat, you can use a battery pack and a 7805 voltage regulator to supply a nice 5V to the rest of the system. For temperature controlled switching, a 10k NTC thermistor is needed in this project. As you can see on the above figure that the thermistor has been mounted high off the… Continue reading