I had a difficult time getting a Nest to work my steam heating system, and google failed me, so I engineered through it. The nest says that it works with 95% of all systems out of the box, but when you have that 5%, it's rather vague. The Nest, and most other thermostats, are in the class of "power stealing thermostats", which basically means they use a RC circuit to leach a bit of power off the lines from the heater. This means that the power is acquired from two lines from the heater. At a minimum, you need two lines to turn on your heater, which are the R and the W. In my case, the Nest did not work; however, I guessed this might happen so I ordered a 120v to 24v transformer in advance.
I have a Beckett 7505B burner controller that does not have a common line. It has just two lugs, Tw and Tr, which are the R and W wire terminals. If you short these two wires together, the system will turn on. The issue was that the Nest need more power. The solution is to add a 24VAC transformer and connect them to the Rc and C lines. The "C" line is the common from the transformer, which is most likely a black line. The "Rc" line is the power from my non-existent air conditioner. In this way, the Nest is powered by Rc and C wires while the control is passed via the Rh and W1 wires. The final schematic follows and worked very well.
Monday, November 20, 2017
Monday, October 30, 2017
finding something in a text file
BSD and Linux have slightly different temperaments, and "find --type" didn't work under MacOS. I was trying to find the word "command" in all of my shell scripts to see how I tested if commands exists. I settled on grep:
grep --include=\*.sh -rl '.' -e 'command'
Wednesday, October 11, 2017
Getting started with TypeScript under MacOS.
These are mainly notes for me, but I thought that it would be useful for someone else as well. I have a strong dislike for Javascript because the code seems to be sloppy and non-maintainable. When you come from the background of physics, the fact that you cannot do integer math will bother you. I have a new driver that I want to make portable projects between Windows/Linux/MacOS in a way that is approachable and maintainable.
I have been moving my MATLAB to Python, and for many things that are not related specific to mathematics I have had a more difficult time finding a portable language. Due to the fact that Windows support is always a challenge when you do not use it, I settled on Typescript. In the same way that Microsoft address all of my gripes about Java by making C#, Typescript solves most of my complains about Javascipt. Typescript creates Javascript, so that the code can run on the seemingly ubiquitous Javascript.
In order to use Typescript, we need a program called tsc at a minimum. A Typescript IDE would be helpful too (I used Visual Studio Code). In order to install TypeScript, I used macports, so start by installing macports.
Once you have macports, install package manager for node.js called npm:
Now that you have npm, you need to install the typescript support:
Next you should test the installation of the typescript compiler, tsc
At this point, one can compile a program. It is a two step process where you use tsc to turn a typescript file into javascript, and then use node to execute the compiled javascript. I created a file called test.ts as in:
You then can compile the test.ts file:
The result will be the generation of file test.js which now can be executed as
The result is "Hello World"
I have been moving my MATLAB to Python, and for many things that are not related specific to mathematics I have had a more difficult time finding a portable language. Due to the fact that Windows support is always a challenge when you do not use it, I settled on Typescript. In the same way that Microsoft address all of my gripes about Java by making C#, Typescript solves most of my complains about Javascipt. Typescript creates Javascript, so that the code can run on the seemingly ubiquitous Javascript.
In order to use Typescript, we need a program called tsc at a minimum. A Typescript IDE would be helpful too (I used Visual Studio Code). In order to install TypeScript, I used macports, so start by installing macports.
Once you have macports, install package manager for node.js called npm:
port install npm5
npm install -g typescript
tsc --version
{ class Startup { public static main(): number { console.log('Hello World'); return 0; } } Startup.main(); }
tsc test.ts
node test.js
Wednesday, May 31, 2017
Counting duplicates in a file.
I've been looking at lightweight hashes. In doing so, I needed a way to look for collisions. I've been using the Solaris 2.6 kernel file as a test target as it is from a 32-bit RISC processor, so it has 32-bit words. First, you convert the kernel into 32-bit words in ASCII.
xxd -c4 -g4 -p unixI then run scripts that results in unix.hash, and from there, I need to look for collisions.
sort unix.hash | uniq -c | grep -v '^ *1 ' | sort -nr
Tuesday, May 30, 2017
Makefile: *** missing separator. Stop.
I do not know why you still need tabs in Makefiles.
Makefile:118: *** missing separator. Stop.Replaced my spaces to a tab and it suddenly all works.
Sunday, May 28, 2017
Keybase looks like it will not support UTF-8 well.
When I first came across keybase.io, I was excited about the premise of simple key management. I'm a crypto novice, but still, I've seen some terrible crypto implementations.
So what's the problem with keybase? Well, nothing as long as you only speak English. For some reason, it seems that keybase will not let you name devices with utf-8 characters.
I do not believe that the keybase team realized what an annoying bummer that is. I name each of my devices in the language of which I primarily use it. The analogy is that English speakers laugh when you transliterate "Dragon King" into "Long Wang". As young as keybase is as a company and application, I wish they would invest in language support on the front end. Currently, if you want to name a device in Japanese, or French/Spanish with the complete character set, you are out of luck. The proof is in the regex:
So what's the problem with keybase? Well, nothing as long as you only speak English. For some reason, it seems that keybase will not let you name devices with utf-8 characters.
I do not believe that the keybase team realized what an annoying bummer that is. I name each of my devices in the language of which I primarily use it. The analogy is that English speakers laugh when you transliterate "Dragon King" into "Long Wang". As young as keybase is as a company and application, I wish they would invest in language support on the front end. Currently, if you want to name a device in Japanese, or French/Spanish with the complete character set, you are out of luck. The proof is in the regex:
var deviceRE = regexp.MustCompile(`^[a-zA-Z0-9][ _'a-zA-Z0-9+-]*$`) var badDeviceRE = regexp.MustCompile(` |[ '+_-]$|['+_-][ ]?['+_-]`)
Wednesday, May 24, 2017
Standing on the shoulders of giants.
I write *a lot* of papers. It's my job.
I was asked today what my favorite paper was. My favorite paper will never get any citations and is On the temperature dependence of subthreshold currents in MOS electron inversion layers, revisited. This paper is revisiting the methods data from a 1979 paper entitled On the temperature dependence of subthreshold currents in MOS electron inversion layers by Card and Ulmer.
One might say "it's been done", so why revisit it? Well, because Tsividis cited this work on his seminal paper on CMOS bandgaps and I had never seen similar results. I revisited the data and tested an IC on a modern process, and found that "self aligned" CMOS processes remove the issue they reported.
I tried to contact Card and Ulmer. I found that Card had died, but Ulmer was still alive and was very helpful. I met him in Phoenix after I presented at RFID 2017. We are all building on the work of the people before us. I hope that when I'm 75, some younger mind will take me out for coffee.
I was asked today what my favorite paper was. My favorite paper will never get any citations and is On the temperature dependence of subthreshold currents in MOS electron inversion layers, revisited. This paper is revisiting the methods data from a 1979 paper entitled On the temperature dependence of subthreshold currents in MOS electron inversion layers by Card and Ulmer.
One might say "it's been done", so why revisit it? Well, because Tsividis cited this work on his seminal paper on CMOS bandgaps and I had never seen similar results. I revisited the data and tested an IC on a modern process, and found that "self aligned" CMOS processes remove the issue they reported.
I tried to contact Card and Ulmer. I found that Card had died, but Ulmer was still alive and was very helpful. I met him in Phoenix after I presented at RFID 2017. We are all building on the work of the people before us. I hope that when I'm 75, some younger mind will take me out for coffee.
Saturday, May 13, 2017
Public-Key encryption, explained as simply as possible.
Over on the wonderful crypto.stackexchange.com, you will find a bunch of mathematicians. When people ask for the most simple example of public-key exchange, you are ultimately sent to either: 1) an overview that does not show you much, nor give an example, or 2) a webpage written by mathematicians, for mathematicians. As I have seen this more than once, I decided that I should try to write the simplest example possible. In order to follow the example, you need to review
The simplest example I could come up with is:
I'm passing on "Alice and Bob" because I think that it's a terrible notation. In the example above, the prime P, and α are initially shared. The result is "Z", which is calculated between both parties.
Me | You |
Prime, P = 29,α = 2
| |
secretme = 5
αsecretme
= 25 = 32 = x (mod P) = 3 (mod 29) | secretyou = 12
αsecretyou
= 212 = 4096 = y (mod P) = 7 (mod 29) |
ysecretme = Z (mod P) 75 = Z (mod 29) | xsecretyou = Z (mod P) 312 = Z (mod 29) |
Z = 16 | |
I'm passing on "Alice and Bob" because I think that it's a terrible notation. In the example above, the prime P, and α are initially shared. The result is "Z", which is calculated between both parties.
Saturday, May 6, 2017
PDF word count
Tuesday, April 25, 2017
It's so hard to publish data.
It's really difficult to publish your data when your institutes keep changing policies. I had a webpage for over 10 years at Georgia Tech until it went away. In 2004, the policy was that Ph.D. student webpages were permanent, and I used those pages to distribute the data from my papers (or that was my understanding). Well, this turned out to be a terrible idea as I now have IEEE papers that have bad references to data. I started a github archive that has my test data from my papers.
Most importantly, if you ever need *real* nFET data from a commercially available 350nm process, it is available in nfetdata.
Most importantly, if you ever need *real* nFET data from a commercially available 350nm process, it is available in nfetdata.
Tuesday, March 14, 2017
MPLAB IPE gives "Connection Failed" on MacOS
I was given a PIC32MZ board. I am currently very interested in lightweight cryptography, and the PIC32MZ seems like a great target. It even has BSD4.4-lite port! I was trying to use the MPLAB IPE and I kept getting:
Connecting to Starter Kit on Board... Currently loaded firmware on Starter Kit on Board Firmware Suite Version.....01.38.10 * Firmware type..............Unknown Firmware Type Now Downloading new Firmware for target device: PIC32MZ2048EFH144 Downloading AP... AP download complete Programming download... Connection Failed.Apparently, you need to run the MPLABCOMM program to install the USB drivers. The file is included with the IPE, but it apparently skips that step in the installation. The IPE worked magically after that.
Tuesday, March 7, 2017
This was supposed to be the AES S-Box, it's not.
Test vectors are so very important. Whenever possible, I try to verify all of my circuits. I was verifying the AES S-Box implementation and randomly picked: 0x00, 0x04, 0x10, 0xFF. Everything worked out except 0xFF, and due to the small data size, I can actually test every option. The resulting logic output for my S-Box follows:
Most of these entries are incorrect; however, I only noticed because the 0xFF value was off. This is just a good reminder of why I test every value if possible and why it's good to design test vectors. Now to determine if it is in my multiplicative inverse unit or the affine transform. (I'm betting the affine circuit because if the multiplicative inverse circuits were bad, 0x00 wouldn't have mapped to 0x63)
Most of these entries are incorrect; however, I only noticed because the 0xFF value was off. This is just a good reminder of why I test every value if possible and why it's good to design test vectors. Now to determine if it is in my multiplicative inverse unit or the affine transform. (I'm betting the affine circuit because if the multiplicative inverse circuits were bad, 0x00 wouldn't have mapped to 0x63)
Making BASH throw an error with the function name.
Debugging bash strings is just strange. I've just come across ${FUNCNAME[0]}, which returns the function that was called. In the following code, the testwithlen4() function expects a string with the length of 4, and if you give it short or long string, it returns the error with the name.
The error result will be:
Now to make a whole slew of changes to my support code. :/
#!/bin/sh echoerr() { echo "$@" 1>&2; } # echo output to STDERR testwithlen4() { isom_inputstring=$1 isom_inputsize=${#isom_inputstring} #get the length, it should be 4 isom_inputmaxsize=4 if [ "$isom_inputsize" -ne "$isom_inputmaxsize" ]; then echoerr "ERROR, ${FUNCNAME[0]} failed due to isom_inputsize != $isom_inputmaxsize ($isom_inputsize) " exit -1 fi testwithlen4 "abc"
ERROR, testwithlen4 failed due to isom_inputsize != 4 (3)
Wednesday, February 15, 2017
kicad IO_ERROR
I was getting some strange IO_ERROR warnings after my KiCad upgrade to 4.0.5.
IO_ERROR: footprint library path '/Library/Application Support/kicad/modules/Microwave.pretty' does not exist from /Users/ansible/4.0.5/kicad-mac-packaging-4.0.0/kicad/pcbnew/kicad_plugin.cpp : FootprintEnumerate() : line 1786 IO_ERROR: footprint library path '/Library/Application Support/kicad/modules/Inductors_NEOSID.pretty' does not exist from /Users/ansible/4.0.5/kicad-mac-packaging-4.0.0/kicad/pcbnew/kicad_plugin.cpp : FootprintEnumerate() : line 1786It seems that one of the developers left their path in the code somewhere. A reinstall of KiCAD fixed the issue. I guess I must have gotten the install packages while the error was in the wild as the reinstall was the same version.
Sunday, February 5, 2017
Finding files in SVN that will be added or have updated.
As this is my blog for me to remember things, I keep getting this syntax incorrect:
I have a lot of documentation in my SVN tree, and intermediate files. For instance, I only keep .tex files but not the intermediate files or the final PDF in the repo. The command above shows everything that is NOT a "?" from svn status.
svn status | grep "^[^?]"
I have a lot of documentation in my SVN tree, and intermediate files. For instance, I only keep .tex files but not the intermediate files or the final PDF in the repo. The command above shows everything that is NOT a "?" from svn status.
Sunday, January 29, 2017
Forwarding ports with sshuttle, and making ssh require no password.
The first rule in *unix: if you type the sequence more than 10 times, write a script.
I've been using sshuttle over VPN to make my computer part of the network by forwarding all ports, even though I'm in the coffee shop across the street.
However, I actually use this to connect to many, many servers. I basically type the same 5 commands over and over to make SSH require no password after the first login.
I created a script that does all of the work for me. You just put in your username and server and then enter the password...and you never need to type your password again (unless you change your private key).
I've been using sshuttle over VPN to make my computer part of the network by forwarding all ports, even though I'm in the coffee shop across the street.
sudo sshuttle --dns -r me@thatserver.com 0/0
I created a script that does all of the work for me. You just put in your username and server and then enter the password...and you never need to type your password again (unless you change your private key).
#!/bin/bash #Before anything else, set the PATH_SCRIPT variable pushd `dirname $0` > /dev/null; PATH_SCRIPT=`pwd -P`; popd > /dev/null PROGNAME=${0##*/}; PROGVERSION=0.1.0 printf '\nWarning!\nThis script creates the ssh key pair so that one does not need\n to type a password to login more than once. If you know that you\n need to do this, you probably can check this scripts source\n to see what is being done.\n\n' read -r -p "Are you sure you want to continue? [y/N] " response case "$response" in [yY][eE][sS]|[yY]) ;; *) exit 1 ;; esac printf "This script will put public key on the remove server\n and now it will ask for your USERNAME and the REMOTESERVER\n" printf "USERNAME [ENTER]:" read USERNAME printf "REMOTESERVER [ENTER]:" read REMOTESERVER echo "Will send pair to $USERNAME@$REMOTESERVER" if [ -f "$HOME/.ssh/id_rsa.pub" ]; then echo "$HOME/.ssh/id_rsa.pub exists, skipping rsa key generation" else #create the key pair echo "ssh-keygen -t rsa" ssh-keygen -t rsa fi #create the remote directory if it doesn't exist and change the mode echo "ssh $USERNAME@$REMOTESERVER 'mkdir -p .ssh && chmod 700 .ssh'" ssh $USERNAME@$REMOTESERVER 'mkdir -p .ssh && chmod 700 .ssh' echo "cat .ssh/id_rsa.pub | ssh $USERNAME@$REMOTESERVER 'cat >> .ssh/authorized_keys'" cat $HOME/.ssh/id_rsa.pub | ssh $USERNAME@$REMOTESERVER 'cat >> .ssh/authorized_keys'
Friday, January 20, 2017
256-bit multiplication in BASH, if you have the time.
In my continuing saga of using BASH to glue programs together with bashbignumbers.sh
, it takes 8 seconds to do a 128-bit multiply resulting in a 256-bit result, and 31 second for a 512-bit result.
The resulting output is:
#!/bin/bash # Required programs: BIGNUMBERS=bashbignumbers.sh if [ ! -f $BIGNUMBERS ]; then echo "File, $BIGNUMBERS, not found!" exit fi source "$BIGNUMBERS" TESTSTR256_0="ce6a8c03135bf12ca7ca2e748c9c3557ca564f9b69a2565f6adee7000d9236ec" TESTSTR256_1="a325aa75a7335e84f11f80c46f0921ada9a4887620c583eff95f09e669df8634" BINARG0=$(bashUTILhex2bin $TESTSTR256_0) BINARG1=$(bashUTILhex2bin $TESTSTR256_1) start=`date +%s` RESULTFULL=$(bashMULbinstring $BINARG0 $BINARG1) end=`date +%s` runtime=$((end-start)) echo "runtime: $runtime" RESULTHEX=$(bashUTILbin2hex $RESULTFULL) echo "$RESULTHEX"
runtime: 31 838c35fdd0424be26879b9824ca6ad38b245bbb0425da4bdf5e9a51027687da7b7def3037554f1659df8a104630f5afe5bf4a3bdaff5d7c4e3ad6209ee06aff0
Thursday, January 5, 2017
Multiplying large numbers in bash.
In my saga to glue and manipulate results from my simontool program that emulates the hardware of the Simon Cipher, I have now added a multiplication instruction to my bashbignumbers.sh
library.
The resulting output is:
#!/bin/bash # Required programs: BIGNUMBERS=bashbignumbers.sh if [ ! -f $BIGNUMBERS ]; then echo "File, $BIGNUMBERS, not found!" exit fi source "$BIGNUMBERS" STRBIN2_MUL="0000010001111000" SSTRIN1_MUL="0001010000000000" SRESULT_MUL=$(bashMULbinstring $SSTRIN1_MUL $STRBIN2_MUL) echo "$STRBIN2_MUL" echo "$SSTRIN1_MUL" echo "$SRESULT_MUL"
0000010001111000 0001010000000000 000000000010110010110000000000000
Subscribe to:
Posts (Atom)