Skip to the content
4 layers96 × 61 mmComscicalc compute, the printed circuit board in 3D

Comscicalc compute

oskarvh/ComSciCalculator

Code for the computer scientists calculator

Size
96 × 61 mm
Copper layers
4
Thickness
4.69 mm
Parts
111
Nets
140
Pads
460
Tracks, vias
1,017, 166
Pours
14
Routed
Yes
KiCad
KiCad 6 (file 20211014)
Created
17 Jul 2022
Updated
13 May 2026

Overview

Comscicalc compute is an open-source printed circuit board by oskarvh, from the oskarvh/ComSciCalculator repository on GitHub. It is a 4-layer board of 96 × 61 mm with 111 parts on 140 nets, routed with 1,017 tracks and 166 vias.

It is built around the R7FA4M3AF3CFM#AA0, FT811Q-T and USBLC6-2SC6, with the SSSS211603, ACM2012-361-2P-T002 and ASPI-0403S-1R5M-T among its other parts. Its parts include 50 resistors, 36 capacitors, 5 ICs, 4 connectors and 2 switches.

Main components

9

README

README.md

Computer Scientist Calculator

The computer scientist calculator is a modern take on the HP 16C. It was born out of frustration of the terrible windows calculator, and since it's aimed at EE's, it also has to have hardware.

Status of project

The software is mostly being worked on at the moment. A few iterations of the hardware has been made, but nothing has been ordered yet because some components are hard to get at the moment, along with the continuous change of heart when it comes to the hardware specs.

The software is in a semi-stable phase at the moment. The core of the calculator, the software/comSciCalc_lib has had the ground work made. Fluffy features such as doxygen and clang formatter has been added as well.

Unit testing has begun using the Unity framework.

Software

The software folder consists of two major code bases: comSciCalc_lib and unit_tests.

The comSciCalc_lib is a library, currently compiled with GCC, which contains all the functions needed to input data, calculate and output result and formatted input. To compile and run the unit tests, run the following script:

bash
./software/run_unit_tests.sh

To run the script in verbose mode, add the -V flag. To not compile the source, use flag -d. Incorrext flags will prompt the usage message:

bash
$ ./run_unit_tests.sh -h
Usage: ./run_unit_tests.sh [-V verbose] [-d dont clean]

This will compile the comSciCalc_lib library and the unit test code (using Unity test framework) and run the tests.

This very same library is intended to work on an embedded system, along with (hopefully) a PC GUI of sorts, so the code does not implement any fancy features.

However, the test code uses some GCC specific preprocessor routines to initialize some of the arrays.

Software dependencies

On Windows 10, I am using :

  • gcc (MinGW.org GCC-6.3.0-1) 6.3.0
  • Clang version 12.0.0
  • Doxygen 1.9.6
  • Git bash

To pull unity into the repo, run:

bash
git submodule update --init

Documentation

To generate the docs, run the following:

bash
cd software # Go to the software dir. 
doxygen doxygen_config

And the docs can be found in software/html/index.html

Technical jargon

The core functionality of the calculator is:

  1. Handling input (valid checks, insertion)
  2. Printing input
  3. Converting from text to something that can be solved.

Going through the list above, the input handling is done using a doubly linked list, where the incoming char will be placed. Each entry has a pointer to the previous and a pointer to the next entry, along with data and meta data for that entry. The data is the actual input character, where the accepted chars are a union between numerical and non-numerical input [0-9,a-f,(,),','] and chars specific to the operators, found in comscicalc_operators.c.

The meta data consists of e.g. base (i.e. hex, dec, bin), type of entry, pointer to operator function (see below) and some more. See the docs for more info.

Each operator has a unique char associated with it, along with some meta data of its own, and a pointer to the function implementing the operator. The function is linked via function pointer that are casted left and right, but due to the way C let's a code handle pointer willy-nilly, this works out fine.

When an input list is solved, it will re-use the entry list type above, but then each entry has a number associated with it, instead of a char. The solver will then go through this list and solve based on the function pointers and numbers entered. The next section will explain how to add a new operator.

Adding new operators

A new operator is added in the comscicalc_operators.[c,h] files, by adding a new entry to the operators table. The entry must consist of the following:

text
.inputChar = /* Associated operator character , e.g. '+'*/,
.opString = /* Null terminated string to be displayed during printing.  "+\0"*/,
.solvPrio = /* Solving priority, 0 is the highest. (see docs) */,
.bIncDepth = /* Boolean indicating if operators increase depth (=should it invoke a bracket) */,
.numArgs = /* Number of arguments. -1 if variable. Must be 2 if not depth increasing.  */,
.pFun = /* Pointer to the function associated with the operator */

Moreover, the operator function needs to be added to the comscicalc_operators.c and comscicalc_operators.h file as well. The operator function must follow this format:

text
int8_t calc_<NAME>(SUBRESULT_UINT *pResult, inputFormat_t inputFormat, int num_args, SUBRESULT_UINT *args);

Ideally the operator should support fixed and floating point, along with signed and unsigned integer formats. But if for some reason this is impossible, then the function must return format_not_supported

Test coverage

The software/test_coverage.sh script will run a gcov analysis of the two main library files: comscicalc.c and comscicalc_operators.c when running the test suite in order to see what the code coverage is during the tests. This should ideally be close to 100% as it would indicate the code coverage is complete.

Running this script will make a temporary folder under software called test_coverage, where the build files, gcov files and copies of the source files are stored.

Moreover, the script will print the code coverage for the two files being analyzed.

To check which lines are being covered, run the test_coverage.sh script, go into the test_coverage directory and take a look in the *.c.gcov files. Each line with a ##### mark has not been executed.

With that information, additional tests can be added to the test suite to ensure as good test coverage as possible.

Developer log.

March 6, 2023

For preceding operators, such as NOT, have a single operand, but can still have a long list of internal calculations. This is kind of the same as brackets/parenthesis. There are situations where these are stacked, e.g. NOT(NOT(...)) or ((12+4)*2). These situations require a lot of extra edge case handling if handled in a single list entry. After protoyping in Python, I found that if the brackets spawn a new list entry with an increase in depth of 1 per new entry, it becomes a lot easier to work with. Since there are a lot of commonalities with preceding/single entry operators, I think it makes sense to do the same. However, there is a point in keeping the opThis (i.e. preceding operator) for printing purposes. Although, it's a bit confusing having both preceding operator and normal operator in one entry.

Conclusion is that there shall only be one operator per entry. so a NOT() operator shall always have a next list with one higher depth. Same goes for parenthesis. Do this and all tests of getInputListEntry passes

March 14(pi day):

I'm starting to think that the setup is a bit too advanced. I don't remember the reason why I had separated the string entry and the operator. I think it was due to the solver (which hasn't been written yet) but I'm starting to think that 400 lines of code just to add a char to a list is a bit on the heavy side. Therefore, I think I'll re-structure the list entry so that it either takes an operator, function, bracket or char, and then just handle the solver later. One thing that is nice with having a string per entry is that solving will probably be easier, but at the same same time, that will most likely not be the main issue, as I would have to convert everything to string after all. Another nice thing with the entry containing an entire string is that handling base changes (hex/dec/bin) is easier. It's a tradeoff though. I'll try it out using linker switches first though.

March 15:

I spent a whole lot of time thinking this through, and in the spirit of keeping things simple, I decided to act on last nights decision. Tests that the old code was failing is now passing. Although a first pass didn't test cursor != 0, they are at least passing the random input tests. I'm feeling happier with this solution, as it is simpler. I don't think that the solver would have been a whole lot easier with the last approach, but changing input base would. That being said, it is not impossible to do. Come to think of it, the approach would be the same except finding the start and end of the string is less efficient now, but not harder.

March 23:

I'm currently working on the solver, and I think I have a good enough idea on how to handle that, but I have identified a few things that needs to be addressed:

  1. It would be super nice with a pointer in the operator to a documentation string, so I added that.
  2. I'm not sure how I want to handle the bitwise operators. I was first planning to have them as OP(arg1, arg2), but I'm starting to think that it's cleaner to have it as arg1->OP->arg2. It should be enough to just change the operator to non-depth increasing for this.
  3. However, we do need to add a comma ',' for the special functions. This would be the argument separator. Should be easy enough to add as it would be handled almost the same as brackets.
  4. At some point, I need to add support for floating point and fixed point. I can't say that I'm looking forward to this though...

Other than that, it's progressing nicely. Since the last update, most of my time had gone into moving from python to the C unity test framework, with a quick pitstop at CFFI in python. I have concluded that there isn't a nice way to integrate this code into a python based test framework, so I have gone with a C based test framework instead. At the moment, adding, removing and printing the buffer works fine, those have static tests, so no randomized input yet. But I was able to squash some bugs there. Moreover, the tests for finding the deepest bracket, along with converting the list entries from char to int is working nicely. The choice of having duplicate lists for input buffer and solving buffer is needed so that we have the input buffer to print.

March 25:

The expression solver is working for basic stuff like 123+456 and 123+456*789, and I'm working on depth increasing expressions. I have thought at bit about how operators and functions are to be handled, and I have set the normal bitwise operators to non-depth increasing. I think the expression solver will handle ignoring non-increasing non-number types, such as a comma, but I have not tested that yet. Moreover, I'm starting to think about what features makes sense. I want to leave it as open to expansions with new functionality as I can in that I want the have any type of function in there. At the same time, I have been thinking about imaginary numbers and variables, if that could be something that the calculator should support. I think imaginary numbers would be awesome. The difference in operators and custom functions are starting to be very very small, so I might as well remove the custom function option and just have operators. Really the only difference I can see is if a custom function should be dynamically linked at runtime. But I cannot see the need for that right now.. After some thought I removed the custom function, it's now merged into operators.

March 26

I made some progress with the code itself, but mostly pulling in doxygen and clang formatter, along with updating the readme file, moving some stuff out of the lengthy C file. In general, minor fixes here and there, and I think the baseline is pretty much done. That being said, a lot more effort needs to go into the tests, since I'm not happy with the test coverage at all. With that said, it now solves basic expressions, and the depth increasing has been tested. But I would like to cover negative tests as well, where I try to break it by giving it bad input.

Moreover, since moving from Python I have pretty much given up on randomized input, but I think that would be nice to bring back, and just have it run through heaps of randomized input data and try to calculate the results. That requires some other parser though, which will be tricky to build in C (it's more or less what I'm already doing). The 'eval' function in python was perfect for this.

March 29 I have re-written the solveExpression function, the first implementation just became too full of edge cases. So I wrote one that has almost the same amount of edge cases XD. But it was easier to re-write it into a stable state than to fix the old one. There is a lot of pointer magic in there, which makes it hard to debug.

That being said, the test cases are now passing, and I have added negative tests as well. There is still a lot of work to be done though, but I'm hoping that the solver is more or less complete.

I'll have to clean up my test parameters in a way that excercises every edge case though, so that requires some thought. A part of me just want to write up a random expression generator, which could be good to have just for mass testing, but I think that the best way to get somewhat of a good test coverage is to just sit down and go through the code, and collect all of the edge cases. There might be a tool for this, but I have not found a nice open source one.

Parts

111
QtyValueFootprintReferences
2333RResistor_SMD:R_0402_1005MetricR25, R26, R27, R28, R29, R30, R31, R32, R33, R34, R35, R36, R38, R39, R40, R41 +7
17100nFCapacitor_SMD:C_0402_1005MetricC2, C3, C4, C5, C6, C8, C10, C11, C18, C21, C23, C31, C33, C34, C35, C36 +1
9DNMResistor_SMD:R_0402_1005MetricR1, R2, R9, R10, R11, R12, R13, R23, R50
710kResistor_SMD:R_0402_1005MetricR4, R6, R8, R17, R21, R24, R49
722uFCapacitor_SMD:C_0805_2012MetricC13, C15, C16, C17, C24, C27, C29
6TestPointTestPoint:TestPoint_Pad_D1.5mmTP1, TP3, TP4, TP5, TP7, TP8
40RResistor_SMD:R_0402_1005MetricR3, R7, R22, R37
410nFCapacitor_SMD:C_0402_1005MetricC22, C26, C28, C30
310uFCapacitor_SMD:C_0805_2012MetricC12, C19, C25
31kResistor_SMD:R_0402_1005MetricR5, R19, R20
222pFCapacitor_SMD:C_0402_1005MetricC1, C7
24.7uFCapacitor_SMD:C_0603_1608MetricC20, C32
25.1kResistor_SMD:R_0402_1005MetricR14, R18
2BLM21PG300SN1DResistor_SMD:R_0805_2012MetricFB1, FB2
2Conn_02x14_Odd_EvenConnector_PinHeader_2.54mm:PinHeader_2x14_P2.54mm_Vertical_SMDJ1, J2
2SSSS211603SamacSys_Parts:SSSS211603SW1, SW2
11uFCapacitor_SMD:C_0603_1608MetricC14
122RResistor_SMD:R_0402_1005MetricR15
13.3uHVLS5045EX-3R3N:IND_VLS5045EX-3R3NL2
133.2kResistor_SMD:R_0402_1005MetricR16
14-1734839-0SamacSys_Parts:4-1734839-0J4
1ACM2012-361-2P-T002SamacSys_Parts:ACM20121022PT001FL1
1AP62300TWU-7SamacSys_Parts:SOT95P280X100-6NIC3
1ASPI-0403S-1R5M-TSamacSys_Parts:ASPI0403S332MTL1
1FL2400022SamacSys_Parts:FL2400022Y1
1FT811Q-TSamacSys_Parts:QFN50P700X700X90-49N-DIC4
1NSR0240P2T5GSamacSys_Parts:SODFL1006X40ND1
1R7FA4M3AF3CFM#AA0SamacSys_Parts:QFP50P1200X1200X170-64NIC1
1TPS92360DCKRSamacSys_Parts:SOT65P210X110-5NIC2
1USB4110-GF-ASamacSys_Parts:USB4110GFAJ3
1USBLC6-2SC6Package_TO_SOT_SMD:SOT-23-6U1
1X1G004171001800SamacSys_Parts:X1G004171001800Y2

More from oskarvh/ComSciCalculator

3
  • 2 layers180 × 108 mmComscicalc keys rev0, the printed circuit board in 3D

    Comscicalc keys rev0

    oskarvh/ComSciCalculator

    Code for the computer scientists calculator

    137 parts
  • 4 layers106 × 61 mmComscicalc hil tester, the printed circuit board in 3D

    Comscicalc hil tester

    oskarvh/ComSciCalculator

    Code for the computer scientists calculator

    116 parts
  • 4 layers100 × 36.8 mmComscicalc compute, the printed circuit board in 3D

    Comscicalc compute

    oskarvh/ComSciCalculator

    Code for the computer scientists calculator

    102 parts

Similar boards

  • 4 layers60.4 × 51.4 mmWasp node board, the printed circuit board in 3D

    Wasp node board

    oskarvh/wasp

    WebAssembly Swarm Processor - a WAMR network compute distribution for MCUs

    116 parts1Apache-2.0
  • 4 layers30 × 18 mmFdcanusb, the printed circuit board in 3D

    Fdcanusb

    mjbots/fdcanusb

    fdcanusb adapter

    36 parts42Apache-2.0
  • 4 layers57 × 35 mmSYSC4907 REV2, the printed circuit board in 3D

    SYSC4907 REV2

    MorganJamesSmith/BioSenseWearable

    Ideas for a university project

    122 parts1BSD-3-Clause
  • 4 layers120 × 50 mmUhmc, the printed circuit board in 3D

    Uhmc

    twuerfl/uhmc

    Underfloor Heating Manifold Controller

    110 parts1
  • 4 layers60 × 90 mm2027Payload, the printed circuit board in 3D

    2027Payload

    Bmcneley/2027Payload

    KiCad project files for 2027 Cy Launch payload PCB.

    96 parts
  • 4 layers25 × 25 mmOpenPrint, the printed circuit board in 3D

    OpenPrint

    dac63701/OpenPrint

    52 parts
  • 4 layers53.5 × 53.5 mmMiniTULPAR, the printed circuit board in 3D

    MiniTULPAR

    ErdemHtyl/Tulpar_Mini_FCB

    This project is under active development. The table below shows what is finished and what is still in progress:

    92 partsBSD-3-Clause
  • 4 layers80 × 60 mmBardsAssistant, the printed circuit board in 3D

    BardsAssistant

    jaylingelbach/BardAssistant

    A tiny “Vicious Mockery” companion built on an ESP32-S3 DevKitM-1.

    77 parts

Questions

How big is the Comscicalc compute PCB?

It measures 96 × 61 mm and has 4 copper layers, 4.69 mm thick.

What parts does the Comscicalc compute use?

111 parts, built around the R7FA4M3AF3CFM#AA0, FT811Q-T, USBLC6-2SC6 and SSSS211603. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the Comscicalc compute KiCad files?

From the oskarvh/ComSciCalculator repository on GitHub, at the commit this page was made from: the board is hardware/comscicalc_compute/rev0/comscicalc_compute.kicad_pcb and its schematic hardware/comscicalc_board/comscicalc_keys_rev0/buttons.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the Comscicalc compute design in my own project?

Its repository states no licence, so its author keeps all rights: ask oskarvh before reusing the design.