

Comscicalc compute
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
9R7FA4M3AF3CFM#AA0
LFQFP-64(10x10)-40℃~+105℃ 100MHz 128KB 12bit 12bit 1MB 2.7V~3.6V 32 Bit 42 8KB ARM Cortex-M33 Built-in FLASH LFQFP-64(10x10) Microcontrollers (MCU/MPU/SOC) ROHSRenesas ElectronicsMicrocontrollers (MCU/MPU/SOC)FT811Q-T
VQFN-48-EP(7x7)Video Interface ICsFTDIUSBLC6-2SC6
SOT-23-60.35pF、0.8pF 100nA 150W@8/20us 15V 2 5V 6A@8/20us 6V ESD SOT-23-6 ESD and Surge Protection (TVS/ESD) ROHSUMWESD And Surge Protection (TVS/ESD)SSSS211603
SMD-40℃~+85℃ 10000 times 300mA 5.5mm 6V Rectangular Columnar SMD(SMT) Tab SPDT Surface Mount, Right Angle SMD Slide Switches ROHSALPSALPINESlide SwitchesACM2012-361-2P-T002
SMD-4P,2x1.2mm-40℃~+85℃ 2 220mA 360Ω@100MHz 500mΩ 50V 50V SMD-4P,2x1.2mm Common Mode Filters ROHSTDKCommon Mode FiltersASPI-0403S-1R5M-T
SMD,4.5x6.6mm1.5A 1.5uH 45mΩ Consumer grade ±20% SMD,4.5x6.6mm Inductors (SMD) ROHSAbraconPower InductorsFL2400022
SMD3225-4P-25℃~+85℃ 10pF 24MHz 50Ω ±10ppm ±10ppm SMD3225-4P Crystals ROHSDiodes IncorporatedCrystalsNSR0240P2T5G(ES)
DFN1006-2LDFN1006-2L Schottky Diodes ROHSElecSuperSchottky DiodesUSB4110-GF-A
SMD-40℃~+85℃ 1 48V 5A Black Female Surface Mount, Right Angle Type-C USB 2.0 SMD USB Connectors ROHSGlobal Connector Technology (GCT)USB Connectors
README
README.mdComputer 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:
./software/run_unit_tests.shTo 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:
$ ./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:
git submodule update --initDocumentation
To generate the docs, run the following:
cd software # Go to the software dir.
doxygen doxygen_configAnd the docs can be found in software/html/index.html
Technical jargon
The core functionality of the calculator is:
- Handling input (valid checks, insertion)
- Printing input
- 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:
.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:
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:
- It would be super nice with a pointer in the operator to a documentation string, so I added that.
- 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.
- 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.
- 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| Qty | Value | Footprint | References |
|---|---|---|---|
| 23 | 33R | Resistor_SMD:R_0402_1005Metric | R25, R26, R27, R28, R29, R30, R31, R32, R33, R34, R35, R36, R38, R39, R40, R41 +7 |
| 17 | 100nF | Capacitor_SMD:C_0402_1005Metric | C2, C3, C4, C5, C6, C8, C10, C11, C18, C21, C23, C31, C33, C34, C35, C36 +1 |
| 9 | DNM | Resistor_SMD:R_0402_1005Metric | R1, R2, R9, R10, R11, R12, R13, R23, R50 |
| 7 | 10k | Resistor_SMD:R_0402_1005Metric | R4, R6, R8, R17, R21, R24, R49 |
| 7 | 22uF | Capacitor_SMD:C_0805_2012Metric | C13, C15, C16, C17, C24, C27, C29 |
| 6 | TestPoint | TestPoint:TestPoint_Pad_D1.5mm | TP1, TP3, TP4, TP5, TP7, TP8 |
| 4 | 0R | Resistor_SMD:R_0402_1005Metric | R3, R7, R22, R37 |
| 4 | 10nF | Capacitor_SMD:C_0402_1005Metric | C22, C26, C28, C30 |
| 3 | 10uF | Capacitor_SMD:C_0805_2012Metric | C12, C19, C25 |
| 3 | 1k | Resistor_SMD:R_0402_1005Metric | R5, R19, R20 |
| 2 | 22pF | Capacitor_SMD:C_0402_1005Metric | C1, C7 |
| 2 | 4.7uF | Capacitor_SMD:C_0603_1608Metric | C20, C32 |
| 2 | 5.1k | Resistor_SMD:R_0402_1005Metric | R14, R18 |
| 2 | BLM21PG300SN1D | Resistor_SMD:R_0805_2012Metric | FB1, FB2 |
| 2 | Conn_02x14_Odd_Even | Connector_PinHeader_2.54mm:PinHeader_2x14_P2.54mm_Vertical_SMD | J1, J2 |
| 2 | SSSS211603 | SamacSys_Parts:SSSS211603 | SW1, SW2 |
| 1 | 1uF | Capacitor_SMD:C_0603_1608Metric | C14 |
| 1 | 22R | Resistor_SMD:R_0402_1005Metric | R15 |
| 1 | 3.3uH | VLS5045EX-3R3N:IND_VLS5045EX-3R3N | L2 |
| 1 | 33.2k | Resistor_SMD:R_0402_1005Metric | R16 |
| 1 | 4-1734839-0 | SamacSys_Parts:4-1734839-0 | J4 |
| 1 | ACM2012-361-2P-T002 | SamacSys_Parts:ACM20121022PT001 | FL1 |
| 1 | AP62300TWU-7 | SamacSys_Parts:SOT95P280X100-6N | IC3 |
| 1 | ASPI-0403S-1R5M-T | SamacSys_Parts:ASPI0403S332MT | L1 |
| 1 | FL2400022 | SamacSys_Parts:FL2400022 | Y1 |
| 1 | FT811Q-T | SamacSys_Parts:QFN50P700X700X90-49N-D | IC4 |
| 1 | NSR0240P2T5G | SamacSys_Parts:SODFL1006X40N | D1 |
| 1 | R7FA4M3AF3CFM#AA0 | SamacSys_Parts:QFP50P1200X1200X170-64N | IC1 |
| 1 | TPS92360DCKR | SamacSys_Parts:SOT65P210X110-5N | IC2 |
| 1 | USB4110-GF-A | SamacSys_Parts:USB4110GFA | J3 |
| 1 | USBLC6-2SC6 | Package_TO_SOT_SMD:SOT-23-6 | U1 |
| 1 | X1G004171001800 | SamacSys_Parts:X1G004171001800 | Y2 |
More from oskarvh/ComSciCalculator
3- 2 layers180 × 108 mm

- 4 layers106 × 61 mm

- 4 layers100 × 36.8 mm

Similar boards
- 4 layers60.4 × 51.4 mm

Wasp node board
oskarvh/wasp
WebAssembly Swarm Processor - a WAMR network compute distribution for MCUs
116 parts1Apache-2.0 - 4 layers30 × 18 mm

- 4 layers57 × 35 mm

- 4 layers120 × 50 mm

- 4 layers60 × 90 mm

- 4 layers25 × 25 mm

- 4 layers53.5 × 53.5 mm

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 mm

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.