Further component selection and schematic capture

A project log for RPNCalc

A calculator which uses RPN instead of infix notation

raphael.treccanichinelliraphael.treccanichinelli 04/15/2019 at 22:290 Comments

In my last post i explained the project, and my choice in MCU, display, and button count. In this log, I'll run through the more intricate parts of the component selection, and how i laid them out as a schematic.

I used Altium CircuitStudio to design this circuit. I use Altium proper at work, and the familiar layout is convenient. I began by laying out a minimum viable circuit for the Atmega328P-AU . the minimum requirement is simply a voltage supply between 1.8-5V, a pull-up resistor on the reset pin (pin 11), and a crystal oscillator with 2 20pF capacitors. The crystal is strictly optional, but since this chip may have to run at a lower frequency for efficiency purposes, and since i need to be able to load the bootloader onto the device, I do need an external crystal (you can't install the bootloader using the internal oscillator, and bootloaded Atmega328p's are expensive). I also added a 1uF capacitor on the voltage rail. this may be insufficient and I may have to add additional capacitance. 

I then added the FT232RL chip for converting USB signals to UART signals to program the Atmega. The observant of you will note that this is (pretty much verbatim) the circuit for an Arduino board. I used a genuine FT232RL instead of the cheaper CH340 used on some Arduino clones, since i wanted this to be easy to reprogram.

I attached the Tx and Rx lines to the Atmega via 1k resistors to pins PD1/PD0 (pins 31 and 30).

I now needed a USB port. I chose micro-USB despite wanting to use USB C since USB-B is easier to layout and compatible with the arduino nano profile on the arduino IDE. 

I then needed to design my button array. I originally designed around these style of buttons Image result for 2 pin pcb buttonto be arranged at 45 degree angles on the board. I gave this idea up after thinking about it and deciding that it may lead the buttons to flex along their longest axis when pushed hard. I went for the slightly larger 4 pin buttons for extra stability.Image result for 4 pin pcb buttonI laid these buttons out in a 5*5 array to be multiplexed 

You'll notice the R and C wires (rows and columns), which connect to 10 IO pins on the Atmega. The 1k resistors are overkill probably, but I can always adjust the value later on. The basic principle here is that C1 through C5 will be outputs, and one of them will be on at a time. R1 through R5 will be inputs (pulled down on the Atmega328), and in order to scan the button array, C1 will be drawn high, and the R pins will be read, then this will be repeated with C2 through C5 in order to determine which switches are on. Multiplexing is a useful way to drastically reduce the amount of IO needed. in this case, i save 2.5X as much IO. 

I then reached a pretty interesting issue, which is, how can you safely battery power a device? i took inspiration here from Adafruit, in the form of their battery range. they have a wide selection of small Li-Ion batteries, which feature protection circuitry on the battery, preventing over and under-voltage, and over-current situations. this allows you to use the battery as a simple power source, without too much worry about it exploding. The issue then is charging the battery, and again, Adafruit comes through with a solution. they have a reference design for a single cell lithium charging system. I followed the reference design to some extent.

In my design, the value of R10 is set at 4k, as in the datasheet, it defines the formula for setting the charge current. I decided to use a 500mAh battery, and during a regular charge cycle it expects 0.1C current (500mAh * 0.1 = 50mA). A fast charge can run safely at 1C. I decided on a compromise of 0.5C (250mA). this can easily be adjusted by varying R10 if this proves unsafe.

BATSTAT is a tri-state pin, which can be driven either disconnected, high, or low. I pulled it up to VCC and attached it to an IO pin on the atmega

via a 1k resistor. This pin indicates the state of charging. to put it simply, low voltage indicates charging, high voltage indicates either fully charged or not charging. In a future revision of this board I'd like to figure out a way to actually monitor the battery voltage to display on the calculator, but for now, this will allow me to put a charge icon on screen. 

The only other piece of the puzzle is the screen connector. this is pretty elementary, using the hardware SPI bus on the Atmega,  pins PB0, PB1, PB2, and PB4 (PB3 is for data going into the MCU, for this project there is none. 

with this, the schematic capture is complete. in the next log, I'll detail (briefly) my board layout for this design.