Skip to main content


Showing posts from July, 2014

PIC16F1708 Macros

So Easy, a Caveman can PIC it The PIC processors have a small and primitive instruction set.  This makes it easy to learn, but doing anything remotely useful usually requires four or more instructions, liberally sprinkled with BANKSEL instructions, which all make the resulting code hard to read and error prone. Your Own Development Kit As you can see above, it is very easy to make a little development kit of your own, using Vero board and a DIP size PIC.  Once things are working, then you can use Eagle schematic and PCB designer to make a tiny surface mount board, or you can just spray the Vero model with conformal coating and stick it into a soap box with a blob of RVT... Your Own High Level Language The solution is to make your own high level language of sorts with macros.  The upshot of macros is that if you find a bug in one, then you can fix that bug in many places all at once.  The downside is that debugging complex macros can be hard, since the PICKit3 debugger ha

PIC16F1708 a Dilly

I always wondered what is a dilly, why would you pick it and what could you possibly do with it in a circus, but those English are crazy - it must be something in the water. The last time I used a Microchip PIC processor - some time before the dinosaurs in the previous century - there were only a handful of different chips.  Nowadays there are over 300.  A problem with this proliferation is that it is now much more difficult to find relevant information on the exact chip that you want to use and getting started with the infernal things can be very time consuming. I wanted to use a  PIC16F1708, which includes an  ADC , DAC and even a couple of Op Amps for anti-aliasing filters, an all in one CODEC chip for an audio interface widget. Here are a few tips on things that I discovered along the way. No Power When trying out the evaluation board I got with the PICkit3, I kept getting the error:  Target device was not found. You must connect to a target device to use PICkit 3.

Fletcher Checksum Calculator in Bash

Bash is quite a powerful scripting language and all UNIX machines have it.   The main problem with it is that it was initially designed to work in text mode, making it awkward to process numbers, which tend to be unexpectedly converted back to text strings. If you need to debug a serial RS232/RS422 avionics device with control messages that end in a checksum or CRC, then it can be hard to generate the checksums.  This example calculates the Fletcher checksum of a hexadecimal message and prints the message out, so that you can copy and paste it into a serial terminal such as cutecom, minicom or screen . Alternatively, you could print the message directly to the serial device, provided that you initialized it with stty  as shown in here: The calculator bc and the printf statement can be used to overcome these limitations. #! /bin/bash echo -en "Message = " # Calculate the Hexadecimal message checksum usi

Mouse Wiggler

Have you ever watched a Jootoob movie and got annoyed when the screen saver kicked in? Some video players interact with the screen savers and will send a dbus command every once in a while to kick the screen saver, but some don't. The standard fix is to get a child to wiggle the mouse every once in a while.  At least that way they get some exercise! However, a computer is supposed to automate things, so here is a Linux mouse wiggler script using the xdotool : # yum install xdotool -y #! /bin/bash STATUS=1 while [ "${STATUS:-null}" != null ]; do   STATUS=`pgrep firefox`   xdotool mousemove_relative 1 1   sleep 1   xdotool mousemove_relative -- -1 -1   sleep 1 done It will keep wiggling the mouse pointer a tiny little bit, while Firefox is running. Modify at your peril... BTW, there is something similar available for a Mac called Caffeine .