Sunday, July 24, 2016


Last year I tried to implement a wheel encoder in between heats and failed. The ambient light was just too bright. So this time I am building the wheel encoder into the gearbox. I took the spare gearbox apart to see what the best way to do it is. Inside the casing is a differential gear in the form of a cylinder with gear teeth around the outside and the differential gears inside. The cylinder is sealed, held together with 4 screws. But, the outside of the cylinder is perfect for my design. The gearbox cover plate in that part of the gearbox is relatively easy to remove, and in just the right spot. If a hole is drilled through that plateau optical sensor can be set up to look through the hole and read the half of the differential cylinder face which is painted white. Two such sensors can be used to mak single-track quadrature encoder, which can tell whether the wheel is turning forward or reverse.

I have a pair of QRF1114 sensors specifically designed and obtained for this purpose. This part is basically just an infrared LED and an infrared phototransistor in the same case. It isn't directly useful as-is, but I combined it with a few resistors and made a three-terminal analog device.

Friday, May 13, 2016

Hooray for distributed backups!

I found a backup of my database from April 21 of this year, which was only a couple of days before the failure. That should have all of my wikis and gallery data, and therefore represents the second-most important data I have. The most important is the code, and that is backed up by means of git. I know for sure that there is a valid git repository on one of my portable USB disks

Thursday, May 5, 2016

Yet Another Episode in the Annals of Data Stewardship

Having learned my lesson from before, I did not set up my filesystem as one big raid0. I did a btrfs raid5 instead. When one of the disks finally did give out, it wasn't with the click of death I heard before, but with read errors. The btrfs degraded, and by mounting read-only in recovery mode, I was able to use the two good disks in order to get my data.

Or so I thought.

A word on the issue I was having. I was seeing "stale file handle" warnings, of the type you see when you are in a folder that is NFS mounted, after you lose connection. But, this wasn't an NFS system. I rebooted the system and it wouldn't come up, because the btrfs refused to mount. After manually mounting in degraded mode, many of the disk accesses reported errors in dmesg, about the generation of certain metadata being off of the expected value, often by hundreds or thousands of generations.

First, I decided that I had lost confidence in btrfs -- if it wasn't going to keep working in the presence of a disk failure, what was the point? I spent the next several days scraping data off of the btrfs and putting it wherever I could find a place for it - on the USB disks I have, on other computers, on the system disk, etc. I then replaced the bad disk and formatted them all as zfs - now possible since Ubuntu 16.04 includes a native zfs driver.

Finally, I started copying data back onto the zfs. All appeared to go well, until I tried to bring up the wiki. The LocalSettings.php file was completely blank - it had the expected value, but all bytes in the file were 0x01 . Hrm.

Turns out a lot of files were like this. Files I care about, like the database, the git repositories, etc. It seems like the newer the file is, the more likely it is to be damaged like this.

No problem, I've got backups. A raid5 is not a backup, so I had the most important data copied off onto several other systems.

Or so I thought.

My backup script runs on a cron every night, and had backed up the bad data and spread it all around over the good data.


It isn't a total loss. I have all my code in a git repository on the big USB disk. I have an old backup (from December, I think) of all the data I considered important. I did lose a lot of video :( but I don't think I lost anything from Florida 5.

So I think.

Monday, April 4, 2016

Hearing but not Understanding

I just heard a conversation drift over the walls of my cube. I could identify the speakers, I could recognize their voices, but I couldn't understand it. It was as if I couldn't parse spoken English. What was actually happening was that, in between the noise level of the fan in my cube, the sound insulation in the cube partitions, and the low level of the conversation to begin with, I just couldn't make it out.

But then how was it that I was able to identify the voices and put names to them, when I couldn't parse them? It means that at some level, identifying voices is easier and more noise-resistant than picking words out.

Or it means that the spoken English section of my brain is broken. I have neither spoken nor heard anyone speak since then, a few minutes ago.

Thursday, March 31, 2016

Check PCLK measurement

Check if the user code measures PCLK properly. If it doesn't, then the baud rate calculation will be wrong. Since one of the symptoms that has been seen is that the RX light on the FT232 doodad flickers, but no characters appear in putty, it is possible that the baud rate isn't what we think it is.

Consider also calculating the baud rate registers and stuffing them manually. If this works, then it's the PCLK stuff that is broken.

Friday, March 11, 2016

The Secret to Success

  1. Pick something you like doing.
  2. Do it and do it and do it until you don't like doing it any more. This will always happen at some point.
  3. Keep doing it.
Following these steps don't guarantee success, but failing to follow them guarantees failure.

Tuesday, February 16, 2016

Cortex M4 FPU

For a while I was having trouble getting my part to print any FPU calculations. Finally it occurred to me that maybe the FPU has to be turned on, and that the ISP wasn't doing it since it didn't use it.

It turns out that you DO need to turn on the FPU:

4.6.6 Enabling the FPU
The FPU is disabled from reset. You must enable it before you can use any floating-point instructions. Example 4-1shows an example code sequence for enabling the FPU in both privileged and user modes. The processor must be in privileged mode to read from and write to the CPACR.
Example 4-1 Enabling the FPU
; CPACR is located at address 0xE000ED88
LDR.W R0, =0xE000ED88
; Read CPACR
LDR R1, [R0]
; Set bits 20-23 to enable CP10 and CP11 coprocessors
ORR R1, R1, #(0xF << 20)
; Write back the modified value to the CPACR
STR R1, [R0]; wait for store to complete
;reset pipeline now the FPU is enabled

In effect, the FPU is counted as coprocessor 10 and 11. Cortex-M doesn't fully support the concept of coprocessors, but it does in this context. We allow full unpriveleged access to coprocessors 10 and 11.

I don't know about waiting for the store to complete and resetting the pipeline. I just put some C++ code to do this long before the FPU is used, and let a bunch of other work instructions flush the pipeline.