Simple method to make ternary full adder

My fresh invention is ternary full adder design. First of it’s kind in the World. Very much all search result from Internet are wrong and doesn’t work. This is first known design which truth table is right. And design uses simple MOSFET transistors. Not any nano carbon tube or other weird futuristic materials seen on Internet search result.

Ternary half adder truth table

SUM  A B C | S C
0+0  0 0 0   0 0
0+1  0 1 0   1 0
0+2  0 2 0   2 0
1+0  1 0 0   1 0
1+1  1 1 0   2 0
1+2  1 2 0   0 1
2+0  2 0 0   2 0
2+1  2 1 0   0 1
2+2  2 2 0   1 1

New method

Ternary full adder is possible to construct from one half adder. If carry-in is 1 then invert inputs and outputs. Result is rest of the full adder truth table below. This is tested with simulation software and it’s works!

SUM  A B C | S C
0+1  0 0 1   1 0
1+1  0 1 1   2 0
2+1  0 2 1   0 1
1+1  1 0 1   2 0
2+1  1 1 1   0 1
3+1  1 2 1   1 1
2+1  2 0 1   0 1
3+1  2 1 1   1 1
4+1  2 2 1   2 1

There is no need for C=2 condition because it’s not newer two.

Design and more design…

Mechanical design

Image is from USB side of The Mystery Box. It’s my designed SDR radio. Other end has SMA for antenna. PCB’s are ordered with assembly service. Them should be ready on next week and arrive to me about three working days later from that.

I intentionally selected round connectors for USB and antenna. It should be easy to drill holes for them altough case is aluminum. Possibly even easier when case ends are connected to center piece. USB connector hole size is 12.7 mm but it can be round to 14 mm so that I can use standard drill bit. SMA connector hole size is 6.5 mm which is already standard size.

Software design – Mbed OS and Tiny IIO Daemon

After massive amount of research I think I can at least try to set up Arm Mbed operating system and Tiny IIO Daemon to The Mystery Box device. Mbed OS consumes about 55kB of flash memory. The onboard STM32L476RG MCU has 1MB of flash memory so there is plenty of room for custom program.

Guide to porting Mbed OS to new device is there:

Porting process is even easier because The Mystery Box is designed on top of Nucleo development board which is already supported by Mbed OS. Some minor configuration might be only thing that must be done before it is possible to use Mbed Studio to program and upload programs to the device.

There is only one code example for Tiny IIO Daemon on the Internet:

However it is enough. Running Tiny IIO Daemon continuously is very easy and program is quite simple. This is taken from above link:

int32_t main(void) {
	struct tinyiiod *iiod = tinyiiod_create(&ops);

	set_handler(SIGHUP, &quit_all);
	set_handler(SIGPIPE, &quit_all);
	set_handler(SIGINT, &quit_all);
	set_handler(SIGSEGV, &quit_all);
	set_handler(SIGTERM, &quit_all);

	while (!stop)


	return 0;

I have an idea how IIO daemon could work. I will test it as soon as I receive The Mystery Boxes from prototype manufacturer. Idea is that receiver and transmitter are turned off by default. Only when data is requested receiver is turned on momentarily and when data is about to send transmitter is turned on momentarily. Only parameter is frequency.

Frequency is controlled with local oscillator through SPI port. I haven’t found yet any example about how to control SPI with IIO daemon. In theory it is possible with GNURadio from Linux computer when IIO daemon is running.

The Mystery Box

The Mystery Box – A multiband software controlled receiver-transmitter for 50MHz…6GHz frequency range.

This is my latest project. Main feature will be simplicity. Only one USB connector for computer and one SMA connector for antenna. Other key features are small size 120*54 mm and wide operational temperature range. It will be also cheaper and more hackable than it’s competitors because there is no any FPGA’s.

I’ll probably program my own controlling software to that radio. Other alternatives are for example popular GNURadio, but it’s design is very complicated and there is not enough information on how to implement IIO environment to embedded system without before mentioned FPGA. I think IIO forms some kind of ring buffer to device, but this is where information ends.

There is however a plenty of information how to render audio stream on Linux operating system. For example on this page.

Then I only need to parse received audio from quadrature and in-phase signals from ADC. Unfortunately Wikipedia is very cryptic about these signals and so are most web search results. However there is I/Q data for dummies.

This is one of rare pages that clearly states that I and Q signals are 2D representations of 3D world from side and from above. Very simple to understand. Worth reading!

Butterworth filter design

One new thing that I learned during development was calculating correct component values for Butterworth lowpass filter. I found almost perfect calculator from website.

That was good starting point for filter design. Input values for that calculator that I use was following. Response: “lowpass”, type: “Butterworth”, topology: “Series First”, order: “8”, cutoff frequency: “57MHz”, input and output impedances: “50 ohm” and component values: “exact”.

My circuit uses 50MHz local oscillator. That’s why I selected 57MHz cutoff frequency so that only at most 50MHz signal goes through it without any attenuation. All received signals is downmixed to that frequency before filter. After filter there is quadrature demodulator circuit.

Back to filter design. From Wikipedia I found important information how to convert that filter circuit to it’s balanced version.

Capacitors are untouched but inductors are doubled for both sides of circuitry and their values are divided by two. This topology is yet verified with circuit simulator and it works as expected. Frequency response is identical with original results.

Balanced-T attenuator design

That was easy part. All component values and circuit design was ready on that web page.

I needed only to select component values from table with desired attenuation and then choose correct circuit version to have balanced design. Attenuation is needed because MCU’s ADC uses 1.8 volts analog voltage and quadrature demodulator outputs 2V p-p signal levels.

Arbitrary Transmission Line Calculator

Atlc is a program which can be used to calculate differential PCB traces impedance among many other things. It seems to be very accurate when compared to other calculators on the Internet and I think it’s result is most accurate of them all. That’s why I selected it to be my main tool when calculating PCB traces.

First thing when using Atlc from command line is to produce data file which is then used to calculate result. Data file is actually a BMP bitmap and Atlc comes with several helper programs to make them.

I needed to design 50 ohm coupled lines so I used my favorite method that is trough trial and error and come to these values below.

create_bmp_for_microstrip_coupler -b 8 1.4 0.2 0.2 0.36 0.035 1 4.3 out.bmp

BMP size is selected with b option to be 8. It’s default value is 4 so now result accuracy is doubled. Trace width is 1.4mm and spacing between them is 0.2mm and spacing between traces and surrounding ground plane is 0.2mm. There is also ground plane below traces on the first inner PCB layer and that thickness between these layers is 0.36mm. Copper thicknesses are 0.035mm and air permittivity is 1 and PCB’s is 4.3.

Result is calculated by Atlc with this way.

atlc -d 0xac82ac=4.3 out.bmp<br>
out.bmp 3 Er_odd=   2.912 Er_even=   3.355 Zodd=  24.866 Zeven=  31.882 Zo=  28.156 Zdiff=  49.732 Zcomm=  15.941 Ohms VERSION=4.6.1

We can see from that result that Zdiff is 49.732 ohm which is almost perfect for our target use.