Giter Club home page Giter Club logo

graphing-calculator-project's Introduction

Graphing-Calculator-Project

This project is to serve as an alternative calculator to the infamous Texas Instruments Ti-84 Graphing Calculator. It uses a single Atmega2560 to perform calculations and then drive the actual display. There is a multiplexed keypad along with 8 debounced buttons for input. The Arduino Mega uses that information to perform operations and graph functions similar to how a Ti-84 would do it. (Not quite, but similar). There are also status LED's implemented for visual debug and aesthetic.

Project Author(s)

Ilan Rodriguez

Motivation

I needed a calculator earlier in my senior high school year, so I decided to build one from scratch. However, it took significantly longer than expected. Thus, by the time I finished, I didn't actually need it. It's still cool to have nonetheless. Plus, making a calculator at this level exercised my programming and planning skills.

Originally, I built BCD Full-Adders in minecraft with redstone and mods. Once my computer couldn't run all demands of the game at that stage, so I decided to build a computer with real hardware. However, I do not know enough Computer Engineering design to build a computer from discrete logic.

Building this calculator is a closer alternative in that it can be made tangible sooner.

Installation

  1. Compile, and upload to an Arduino Atmega2560.
  2. Plug TFT Display shield on the mega.

Materials

*3.5" IPS TFT LCD Display ILI9486/ILI9488 480x320 36 Pins for Arduino Mega2560 * x 1

ATMEL ATTINY84-20PU 8-BIT 20MHz MCU (2 PACK) x 1

SunFounder Mega 2560 R3 ATmega2560-16AU Board (compatible with Arduino) x 2

Sparkfun Pocket AVR Programmer x 1

3mm and 5mm Assorted Clear LED Light Emitting Diodes 5 Colors Pack of 300

PIXNOR 1/4W Resistor Kit 56 Values x 20pcs =1120pcs (1ohm-10Mohm) Metal Film Resistors Assortment

CO-RODE Tact Button Switch 6x6x5mm Pack of 100

SainSmart IIC/I2C/TWI Serial 2004 20x4 LCD Module Shield For Arduino UNO MEGA R3 x 1

Additional Credits to Library Authors:

Kris Kasprzak for Graphing Library
Bodmer for HX8357B, HX8357C, ILI9481 and ILI9486 Libraries

https://github.com/Bodmer/TFT_HX8357

Sudar Muthu for MemoryFree Library

https://github.com/sudar/MemoryFree

RobTillaart for Arduino Code

https://github.com/RobTillaart

Jeremy Gillick for LED Fader Library

https://github.com/jgillick/arduino-LEDFader

Nick Gammon for BigNumber Library

https://github.com/nickgammon/BigNumber

MCUdude for providing board definitions on non-standard Arduino Chips

https://github.com/MCUdude/MightyCore and https://github.com/MCUdude/MiniCore

SainSmart Manufacturer for providing the library in handling the 20x4 LCD

Images

img_graph

License

baboomerang/Graphing-Calculator-Project
Copyright (C) <2017>  <Ilan Rodriguez>, <et-al>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

graphing-calculator-project's People

Contributors

baboomerang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

graphing-calculator-project's Issues

Extra Sav_Num Processing

Once a left parenthesis closes and saves the number if there's an operator immediately left to it it will duplicate a ghost "saved number" which will interfere with the reference stack.

given this infix expression (3+4*2/(1-5)*9)
given the infix REFERENCE stack 613141561217417 (1's being #'s 2 - 3+ 4 * 5/ 6rightparenth 7leftparenth

we get the postfix REFERENCE stack as 1114112**1**5143 that extra one isn't supposed to be there
this would be an extra copy of the 5th term in this case actually being 5

Final, Incorrect POSTFIX notation would be 3 4 2 * 1 5 - 5 / 9 *+
Correct, Final POSTFIX should be 3 4 2 * 1 5 - / 9 * +

Halting When Processing Parenthesis

Parenthetical processing works, but only partly. Given infix expression 455*(923/123-7564+72), it is wrapped with a start and terminating characters. This works fine.

455*(923/123-7564+72) becomes (455*(923/123-7564+72)) which does get processed.
however, if you do this:
455*(923/123-7564)+72 it will halt when processing the save_num function of 7564 and the last number it will save correctly would have been 123.

# EDIT: cutHere == numX and when any operator is juxtaposed with a left terminating parenthesis, this bug occurs.

IRRELEVANTAnalysis: Since the closing parenthesis does make changes to the cutHere and other various elements, it is possible that save_num ends up cutting nothing or an invalid distance, thus halting the program.IRRELEVANT

Conversion of Input to Bignumber

The hardest thing to do without recursive addition to get the number.

Tokenizing part of a char array and initializing it as a big number does not work under any easy or simple conventional method in C.
char buf[50]; //holds serial input of chars

We cannot do BigNumber i = buf; despite the initializer syntax in the library supporting that.
It would only work if it was BigNumber i = ("<string-constructor>");

Using toINT() truncates the input prior to conversion.
char array to long by strtol() then long to big number seems possible, but convoluted and still truncates higher-than-long inputs.

The solution that I have used before was a recursive input stacked addition:
psuedocode
for(loop till delimiter(end of string)) {
get the char from the string
convert to int then - 48 (ASCII to decimal conversion)
multiply by that number by 10
then add the next calculated integer
keep doing that till you get your integer part of the number.

625868235 would be processed as
'6' first char then convert to int which is 54
54 - 48 to get int (6)
add 6 to the collector and multiply by 10

the collector is now 60
'2' second char then convert to int which is 50
50 - 48 to get int (2)
add 2 to the collector ( 60 ) to get 62
multiply by 10 again to get 620
...
...
..
.
do this till the last int but don't multiply by 10 to get your big number
inefficient I guess, and quite problematic, but is a necessary evil.

60 + 2 620 + 5 6520 + 8 65280 +6 652860 + 8 6528680 +2 65286820 + 3 ---> 652868235 entirely as a bignumber with no conversion problems.

Fractional Exponents are Non-Calculable

3 ^ 3.00012324 if inputted into the calculator will be internally handled as a 3 ^ 3.
In essence, there will be a truncation of the decimal portion for some absurd reason.

I need modified exponentiation functions specifically written for the Big_Number.h C++ library.
This may the biggest non-correctable problem with the project.

Graphing Asymptotes Bleed out-of-bounds

img_20170406_225621

any value that reaches out of the upper Y or lower Y limit presents a minor aesthetical issue.
The solution is either stop tracking at that point or cap the plotting value to the upper limit of the display if it ever reaches past the limits.

Exponent Behavior Unpredictable in postfix_reference_stack

3 + 4 * 2 / ( 1 - 5 ) ^ 2 ^ 3 : Input infixstring

3 4 2 * 1 5 - 2 3 ^ ^ / + : output postfixstring (what it's supposed to be)

3 4 2 * 1 5 - 2 3 ^ / + : current output postfixstring (what my code does)

The more exponent operators we add, they get ignored. only the first exponent immediately after the closing parenthesis ' ) ' gets copied to the stack, otherwise nothing happens. But everything else works.

3 + 4 * 2 / ( 1 - 5 ) ^ 2 ^ 3 ^ 6 ^ 99 ^ 13 ^ 5 ^ 2: Input infixstring

3 4 2 * 1 5 - 2 3 6 99 13 5 2 ^^^^^^^ / + : Proper Output postfixstring (Correct Form)

3 4 2 * 1 5 - 2 3 6 99 13 5 2 ^ / + : Current postfixstring ( What my code does #obviously wrong )

Something tells me that exponents are copied to the postfix_opstack, but the logic inside of that whole stack is funky. The fix has to be implemented inside of the pushtostack() function.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.