Device tree, setting GPIO2_1 as an input

With a BeagleBone Black with the latest image (6th June), I tried this device tree fragment:

(Zip file contains the .dts and the .dtbo)


* pru dts file cape-bone-mytest-00A0.dts

/ {
compatible = "ti,beaglebone", "ti,beaglebone-black";

/* identification */
part-number = "BB-BONE-MYTEST";
version = "00A0";

fragment@0 {
target = <&am33xx_pinmux>;
__overlay__ {
mygpio: pinmux_mygpio{
pinctrl-single,pins = <
0x8c 0x2f



target = <&pruss>;
__overlay__ {
status = "okay";

The fragment is responsible for setting <0x8c 0x2f> which is DIL header P8, pin 18 as seen on the pinmux website, set to Input, with no pullup/pulldown:


After copying it to /var/firmware, and then issuing:

export SLOTS
export PINS
echo cape-bone-mytest > $SLOTS

I can see that the fragment is installed, but cat $PINS | grep 88c shows that the pinmux has not changed to 0x2f.

I can see that the pin is floating, because if I connect a 4.7k resistor to pin 18 and the other end to 3.3V or 0V, the multimeter shows the pin is being set high/low correctly.

Then, in my PRU code, I tried to set GPIO2 | GPIO_OE to 1 (which means input), and then read GPIO2 | GPIO_DATAIN but it reads 0 always, regardless of if the 4.7k resistor is going to 3.3V or not.


The PRU code was this (snippets):
// P8_18 GPIO2_1
#define CONF_GPMC_CLK  0x44e1088c

// Set to 0x2f, since the Device Tree fragment failed:
MOV r0, 0x2f    // 2f is GPIO input mode for this pin
ST32 r0, r1

// we need to disable outputs, to use the pins as inputs
// this means writing 1 to the OE register
LBBO r2, r3, 0, 4
SET r2, 1
SBBO r2, r3, 0, 4

// get GP input
MOV r3, GPIO2 | GPIO_DATAIN; // Address of register to read
LBBO r2, r3, 0, 4 // Store register contents into r2
AND r2.b0, r2.b0, 1<<1        // Mask out everything except the GPIO2_1

// If the register is 0, means the pin went low
QBNE IS_HIGH, r2.b0, 0

MOV r2, 1<<21
MOV r3, GPIO1 | GPIO_CLEARDATAOUT        // Set the LED0 off
SBBO r2, r3, 0, 4

MOV r2, 1<<21
MOV r3, GPIO1 | GPIO_SETDATAOUT        // Set the LED0 on
SBBO r2, r3, 0, 4



Posted in Uncategorized | Leave a comment

1mm and 1.25mm pitch connectors

Some photos to help identify connectors. These ones are JST SH which are 1mm pitch wire-to-board shown here, with surface mount connectors:

These ones are Molex PicoBlade, which are 1.25mm pitch with wire-to-board (through-hole) and wire-to-wire examples shown here:


Posted in general electronics | Leave a comment

Ultra portable pocket PSU

Although a bench PSU is useful, sometimes I prefer testing with something more portable. This ultra portable PSU has a footprint smaller than a credit card. It is perfect for travel. (Pen shown in image below for scale). I can charge it up beforehand (or take a USB cable with me) within a couple of hours, and be confident it will work for tens of hours depending on what is being powered. The wires pack inside a sliding door.


It is very low cost, and very quick to build; it uses mainly off-the-shelf hardware. The 1.4AH LiPo battery (6 euro) and charger circuit (4 euro) is from Olimex. The OKW case is from Farnell and was a bit expensive; I already had it, otherwise I would have used a far cheaper case, maybe even cardboard, since this is not intended to be pretty. The 5V switching converter (to boost the LiPo voltage) was from eBay (less than $6). I also decided to have a lower power 3.3V output too; this is based on a single LP2950ACZ-3.3 and a 10uF ceramic capacitor. Everything was just held down with epoxy resin glue.


The three wires (+5V, +3.3V and 0V) are long enough to be useful, and there is a notch so that they can be left extended or they can be fully packed inside the slide compartment.

psu_leads1.jpg  psu_leads2.jpg  psu_leads3.jpg

There are some 2mm dia holes to indicate USB power, charging, and charge complete (these LEDs were part of the USB charger circuit):


There is a small slide switch for power; the LiPo cell is permanently connected to the charger circuit (it is prevented from discharging by the charger circuit) and the switch just applies the LiPo battery output to the 5V DC-DC converter and the 3.3V linear regulator. You can see the switch wiring in the detailed image earlier.


Here it is powering some hardware:


Note: After I constructed it, I saw on the Internet that PopSci had a similar idea many years ago, see here for construction details.

Posted in analog, general electronics | Leave a comment

7 segment Alphabet

A surprisingly large amount of the ASCII table can be represented with a 7-segment display. The image here shows what can be created.


Here is the source code of the table used to create this.

#define SEGA 0x01
#define SEGB 0x02
#define SEGC 0x04
#define SEGD 0x08
#define SEGE 0x10
#define SEGF 0x20
#define SEGG 0x40

#define NUM1 SEGB+SEGC

const unsigned char asciibitmap[]={
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /*0 to 15 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 16 to 31 */
0,0,0,0,0,0,0,0,0,0,0,0,0,SEGG,0,0, /* 32 to 47 */
NUM0, NUM1, NUM2, NUM3, NUM4, NUM5, NUM6, NUM7,NUM8, NUM9, 0, 0, 0, SEGG+SEGD, 0, 0, 0, /* 48 to 64 */
0,0,0, SEGF+SEGG+SEGB+SEGC+SEGD, 0}; /* v-z(122) */

To use this, just edit the first 7 lines to suit your hardware. It relies on the segments defined as shown here, but the values 0x01, 0x02, etc.. can be modified in the first 7 lines above.


Then, if you want to print the ASCII character for (say) ‘H’, just write the data for asciibitmap[‘H’]. A blank character will be displayed if there is an attempt to print an unfeasible character on the 7-segment display (e.g. asciibitmap[‘K’]).

Posted in general electronics | Leave a comment

Crimp pins, sockets and housings

Like it or not, the 0.1 inch spaced (2.54mm) header pins or sockets on PCBs are extremely common. There are also 2mm spaced alternatives, but they are still uncommon.
Making up 0.1 inch connectors is a minefield; it can be extremely difficult finding matching housings and the crimp terminals (pins or sockets) that fit them. Pre-built wires with connectors are available from sparkfun at a reasonable price. (Search the site for ‘premium jumper’; they are in several lengths and Male-Male (i.e. pin-pin), Female-Female (socket-socket) and Male-Female combinations).

Technically just the Female-Female cables are sufficient, because whenever Male is needed, they can be adapted by SIL pins like these:


Nevertheless, it is still occasionally important to build your own custom cables.

This is an attempt to document some 0.1 inch housings and crimp terminals that work together. I will group them into working collections (and also show images so that the different ones can be visually identified too. Click on the images to enlarge). For example, any housing in group ‘A’ will fit any crimp terminal in group ‘A’. If you know of additional terminals/housings that work with the groups below, let me know in the comments field. Or if you have a new group to suggest.

Housings group A
There are some generic Farnell (Multicomp) available (search for ‘2226A’ on the Farnell site). They are fairly low cost and very good value. They are available in 2,3,4,5,6,8,10,12,14,18,20,22,24 way. Note that 1-way is not available in this range.


Single-way housings (and in fact some other sizes too, and pre-built cables) are available from ebay, and they appear visually identical to the Farnell ones. Search for ‘Dupont jumper’. They are extremely low cost.


Note that the Sparkfun and Adafruit pre-assembled premium jumpers also visually appear to use the same housings.

Crimp sockets group A
The low cost Farnell (Multicomp) type 2226TG is a good choice; it is very economical. It was out-of-stock and awaiting delivery the second time I checked, however.


It can be found that crimp sockets which are likely compatible are also available from ebay (search for ‘Dupont jumper’ but they tend to be non-plated with gold. The Farnell 2226TG type are partially gold-plated (i.e. at the contact end).

Housings group B
TE Connectivity ‘AMPMODU MOD IV’ socket housings are available in every size from 1 to 36 way. Their part numbering is in two variants, where one variant is stamped with white print, and the other isn’t (see the photo. Not all sizes are available in both variants). The TE part code for the single way housing is 7-87499-2 (Farnell 1625135). They are not particularly cheap (£0.50 each).


Crimp sockets group B
TE Connectivity 6-87756-8 (Farnell 1183428) is a partially gold-plated contact. Looking at it length-ways, notice the location of the hook is at the back of the terminal (the front being the open side).


Take a look at TE Connectivity 1-104480-6. It is a gold-plated socket, and is in the AMPMODU (not AMPMODU MOD IV) range. Note the unusual shaped hook. Also, notice that the hook is on the front side of the terminal. However, it still fits the AMPMODU MOD IV sockets, if the socket is rotated 180 degrees about it’s axis.


Crimp tools

Unsurprisingly, good crimp tools cost a lot. The Fry’s Electronics tool #1922790 (Philmore WS26) is intended for D-sub crimp terminals, but it works fairly well for the crimp terminals mentioned above. The tool costs less than $10.

Here is an image of a  10/0.1 wire crimped to a TE Connectivity 1-104480-6 socket. The wire was stripped by a few millimeters and then crimped. Notice that the insulator is well crimped and does not move even with some force, but the conductor is loose.


The conductor would have been well crimped if the wire was thicker, or if the wire had been folded over. Personally, I tend to first tin the wire with solder (this was not done for this photo) and then crimp it, and then gently heat the terminal and apply a little solder near the cut wire end. If this is done quickly, the insulation does not melt, and no solder flows into the contact portion. There are differing schools of thought on this, but for personal use I find it adequate.


Some people use 7/0.2 wire (7 strands of 0.2mm diameter), others use 10/0.1. The former can handle more current. Personally I prefer 10/0.1 (it is slightly thinner). It is obtainable in short lengths and various colors from eBay. It is quite expensive buying short lengths. It is far cheaper to buy from Rapid Electronics in larger 100 meter rolls

Posted in general electronics | Leave a comment

fpga4fun – any good?

I personally feel a beginner is better advised to purchase a more open platform like Papilio One.

The fpga4fun boards are closed, and some of the boards only have a block diagram; some of their examples are not supplied with the VHDL or verilog source either. An example: they sell boards that can be assembled together to form a crude oscilloscope. However, there is no source to modify it, and there is only a block diagram of the ADC, leaving it impossible to improve on aspects such as triggering.

Not only that, but you cannot even download the binary unless you purchase the boards. So, you’ve little hope to see if there is any source code or not, unless you purchase the board. (For the record – if you do buy the board, you still don’t get the source code or the schematics).

Given that some of the best ways of learning is to build on existing examples and improve designs, I fail to see the fun in fpga4fun.

Posted in general electronics | Leave a comment

Adobe Reader Internet access causes hangs

On my fast, SSD-enabled machine, every bit of software runs quick except for Adobe Reader. It got to the point that I was just going to uninstall it and replace with another free reader.

Adobe Reader  XI (11.0.0) and some other versions tend to hang for about 25 seconds. And each time Adobe Reader starts up, it downloads a file from the Internet. This was an unacceptable situation. The only solution I found to stop the hanging and Internet access was a three-step solution.

1.  Go to Edit->Preferences->Updater and set to “Do not download or install updates automatically”

2. Go to  Edit->Preferences->Trust Manager and disable “Load trusted root certificates from an Adobe server”

3. Right-click on Windows Notepad and select “Run as Administrator” and File->Open and select “All files” (otherwise it will only show text files) and go to folder “C:\Windows\System32\drivers\etc”, select the file called “hosts”. If you can’t see this file then follow the more detailed steps here to view this file. Append this line (use some spaces, not tabs) without speech quotes:”     ” and then save the file.

This should work straight away, no need to restart the maching after making these changes. Just restart Adobe Reader.

Posted in application software | Leave a comment

SAM-ICE connector pinout

The pin labeling is in the user guide, but the connector numbering was ambiguous. This photo and table snippet from the user guide shows the pinout. Click to enlarge.


Posted in microcontroller | Leave a comment

Component Storage

SMD devices like resistors and capacitors can be stored in tiny plastic boxes such as shown here.
Make sure the label is written in fade-proof ink and that the labels won’t fall off within a year. I used tiny EPROM labels which are designed not to fall off, but they are expensive (I had lots spare). Traditional paper labels are fine as long as they have high quality adhesion.
Other components can be labeled with a paper sticker (or stuck down with ESD-safe tape for all components):
For all semiconductor components, keep items like antistatic foam, antistatic pots and boxes handy. I also use metal boxes for some components although there are differing schools of thought on that. Some components (e.g. diodes or BJTs) can be stored in paper envelopes.
Keep an Excel spreadsheet of inventory to save accidental reordering costs.

A good source of antistatic storage is from Vermason. A low cost mat for working on can be obtained here and it can be cut if it is too large.

Posted in general electronics | 1 Comment

SMD soldering

This is a quick tutorial on how to solder an SMD board with 0603 and QFP sized components. This was the finished board:

‘0603’-sized components are fairly tiny; 1.6mm x 0.8mm. The image here shows some 0603 capacitors and the soldering iron. I broke the small soldering iron tip, so this is a larger tip which is non-ideal (I used this non-ideal tip for soldering these though, so it is just about feasible). Note the tip is clean and shiny (with solder and wet sponge). 0402-sized components are also possible, but I tend to standardize most components at size 0603 for ease of use at home.

Put some flux on the pads where the component is to be placed.
Picking up the components – note the tweezers should be reliable, otherwise this 0.8mm sized component may go flying or cannot reliably be held in place while soldering with your other hand

Use one hand to hold the tweezers _and_ the solder. Tweezers: held with thumb and forefinger, and grab the component. Then grab the end of the solder (leave a couple of inches of it extended) between the middle finger and forefinger, or between all three fingers (forefinger, middle finger and ring finger, so that just the little finger is idle). You can see the grip here. Use the other hand to bend the solder into the correct position.

Place the component at the correct location on the board, and slide fingers if needed, to move the solder into the correct position if it moved. See this image:
If you are having trouble with the grip, try swapping hands. Or get practice in whenever you eat Chinese food. Then, use the other hand to solder the component in place. If you don’t manage to solder it within a second or two (e.g. the solder slipped from your fingers), wait for it to cool a bit before trying again. You can see some soldered 0603 components here. There is too much solder (the result of using a large tip) but this was acceptable for my board. With a smaller tip, it should correctly look like a fillet instead of a blob. Notice the board looks smeary/sticky and this is due to the flux (it will be cleaned later).
0603-sized components can be visually inspected after soldering, and optionally you may wish to use a lens for the inspection.

Soldering QFP devices
Add a lot of flux to the board. The most important step is to align the component perfectly. The way I do it is to place the component, and then nudge from one side with a small instrument (e.g. tweezers) while observing through a lens, then gently slide the board around 90 degrees and nudge again to get the next side aligned, and then rotate another 90 degrees and repeat. Keep doing this (for a total of maybe 720 degrees or even more) until the component is now sitting perfectly. Use the lens and lamp to look at the component from all angles, to ensure it is spot-on aligned. Then, cut a piece of masking tape and use it to secure the component on the board (leave one edge bare so that it can be soldered from that side first). This is not as hard as it sounds; if you’re careful, the component will not move while taping it (the flux has some viscosity too).

As best as possible, ensure that the component did not move while it was taped down.

Now, carefully solder the pins. The thing to be aware of is how long you’re soldering for, because you don’t want the component to overheat. After you’ve soldered a few pins at each end, you can _gently_ remove the tape and solder a few pins on the other side. After a dozen or so pins, wait for it to cool before continuing. It doesn’t matter if the solder causes bridges; they will be removed later. The next thing (after the time) to be aware of is that the solder must be applied to the junction between the end of the pin and the board. Capillary action will suck it under.

Once all the pins look soldered at the junction between the end of the pins and the board, it is time to remove the bridges. Wait for the component to cool, then apply the desoldering braid (aka solder wick) and apply heat with the iron. Capillary action should cause the solder to be sucked up from the bridges into the wick. Trim the wick regularly to prevent it acting as a heatsink taking heat away from the iron tip. If you find the wick is not sucking, then apply some solder to the iron tip first. This acts like a ‘starter’, to help get the wick warmed and begin the capillary action.If that doesn’t work, then the wick is not touching the bridge well enough. Don’t apply force, because that will damage the QFP. Rather, actually apply more solder to the QFP, to make more of a bridge. Then the wick will suck it all off. As the wick is sucking off, gently drag the wick away from the pad, i.e. in the direction of the ends of the pins. The result will look like this (the smeary stuff is the flux). Each pin here is about 0.2mm wide, on a 0.5mm pitch:

You need to inspect every pin individually. There are two locations that need to be inspected per pin, and they are highlighted here in red.
The red highlights shows that the junction between pin end and board should look filleted as shown in the image, and also that the space between pins should not be bridged.

The inspection doesn’t end here. After the area has been de-fluxed (using isopropyl alcohol and an ESD-safe stiff plastic brush), you need to check that each pin is still attached. The inspection will need to be visual (inspecting the junction between pin ends and the board), but also mechanical: take the scalpel, and _gently_ press the side of the blade against each pin in turn. If you can feel the end of the blade flex by (say) 0.1mm then the join is good. Keep it gentle. If the pin was not correctly soldered but was only being held in place by some sticky flux, then it will detatch and you will feel and see it move slightly. That area of the IC can be reworked with solder, and then cleaned again and then inspected visually and with the scalpel again.

Posted in general electronics | Leave a comment