Introduction: Scientific Calculator
Scientific calculator based on an atmega328P.
based on an atmega328P, a 4x4 keypad and 8 7-seg. led displays powered by 2 AAA rechargeable via USB batteries. There are 6 additional key maps including alphanumeric. User defined system settings. Clock display. Scientific notation.
visit my site for details: https://www.sites.google.com/site/demeterart/
The calculator is based on an atmega328P (at 4MHz) and uses all available pins,
16 for the 8-digit led display and 4 analog pins for each of the four columns of the 4x4 keypad. The display consists of two SMA420364 which are 4-digit 7- segment common cathode led devices. The preferred color should be red for low voltage operation - 2 volts minimum.
The power supply can be either external from a USB female type-B connector or internal from 2 AAA batteries. If the batteries are installed then they must be rechargeable for concurrent use with USB power. The voltage available to the circuit, common rail Vcc, varies from 2 to 3 volts while the controller will function down to 1.8 volts (@4MHz) with a very dim light for red leds.
Current consumption at 3 volts/4MHz varies from 6mA to 10mA for a 25% display duty cycle as the number of digits lit varies from 0 to 8. A 100% duty cycle raises the max. current to 19mA. In power down mode the current drops to 0.15mA which goes to the keypad resistor network.
The only external arduino library used is the SevenSeg v1.2.1 by Sigvald Marholm. The keypad is sampled consecutively from channel A0 (leftmost column to pin D14) to A3 (rightmost column to pin D17) and compared to a matrix of analog readings. The 10bit readings are, largely, independent of the power supply and thus operation is fairly reliable over the range of the power supply. User operation allows for both key-driven and command-initiated functionality. The floating point library used is math.h of the avr-libc and the printed format supports scientific notation for very large and very small numbers.
Step 1: SCHEMATIC
The controller is programmed via an arduino loaded with the ISP sketch using the SPI port or a dedicated AVR programmer. The avrdude burner must be used with the fuses set to 0xFD for the low byte, 0xD1 for the high byte and 0xFE for the extended byte.
The command line switches (fill in your own path names) should look like this:
avrdude -C -v -p -c -P -b -Uflash:w: :i -U lfuse:w:0xFD:m -U hfuse:w:0xD1:m -U efuse:w:0xFE:m
The boards.txt file has the following contents:
atmega328b4.name=ATmega328 on a breadboard (4MHz) atmega328b4.upload.protocol=arduino atmega328b4.upload.maximum_size=32768 atmega328b4.upload.speed=9600 atmega328b4.bootloader.low_fuses=0xFD atmega328b4.bootloader.high_fuses=0xD1 atmega328b4.bootloader.extended_fuses=0xFE atmega328b4.bootloader.file=atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex atmega328b4.bootloader.unlock_bits=0x3F atmega328b4.bootloader.lock_bits=0x0F atmega328b4.build.mcu=atmega328p atmega328b4.build.f_cpu=4000000L atmega328b4.build.core=arduino:arduino atmega328b4.build.variant=arduino:standard atmega328b4.bootloader.tool=arduino:avrdude atmega328b4.upload.tool=arduino:avrdude
In case you need the bootloader it is the same as that of the ‘arduino on board’ from the arduino forum but you will need to use a different XTAL and oscillation frequency (only 8MHz and 1MHz - divide by 8 - are supported). I don’t use it as I prefer the programmer for this custom case. You may use the standard 16MHz XTAL and the arduino optiboot bootloader to easily transfer the firmware and forget all about the details above but it will take much more battery current and the minimum supply voltage will need to be much higher for reliable operation.
Step 2: CODE & DOCUMENTATION
Visit my site at