Temporary connections?

I bet once or twice in the past you wish that you could find a simple way to just hold a module with male headers like this Adafruit GPS module in the pin holes of a circuit board without soldering the pins so you can later take the module and put it elsewhere. Here I found a neat solution, wedging the module with some ESD foam. You get ESD foam pieces from buying ICs so they come for free and have some springy-ness. Then you put in between the module and the board and push in. The force from the foam will make the module form a wedge and there is enough strength to tlit the pins against the holes to make connection. Here are some photos:

The first photo shows the underside of my new phi-3 shield. The GPS module is supposed to be on the top side but unless I solder it to the shield, there is not enough space to make a wedge with the module while it is under the display. So I hang it below the shield board and stuck a piece of ESD foam between the module and the shield board. Here is a side view. You can’t see the foam, which is too dark but you do see the pins are all tilted and thus pushed hard enough to make electrical connection. I only recommend this on a temporary basis. Tomorrow the GPS module is going on another board, the SDI-12 + GPS USB adapter. I’ll solder this time.

Phi-panel circuit board update

Recent comments from customers interested in phi-panels have convinced me that going from the original buttons with black plungers to low-profile metal buttons was a bad idea. On my end, the low-profile buttons on the front side of the board required me to reflow both sides of the boards, something that takes a lot of time and extra effort.

So I have made a recent priority update to the phi-panels, both 20X4 and 16X2, to use the original buttons with black plungers again. I’ll be building these boards soon and post some photos.

From now on, all kits will have pre-built components on the back side. All you need to solder are:

  • Buttons
  • LEDs and their resistors
  • Connector for serial port
  • LCD
  • Buzzer

If you buy assembled version, as always, everything is assembled and ready to go.

Here is the back side of the kit board, with key components already reflow-soldered on:

Here is front side of the kit board, just a blank board:

 

Here is assembled unit, same as before:

Here is assembled unit’s back side:

I2C LCDs

There are many types of I2C character LCDs on the hobby electronics market. To design my new open source data loggers and Phi-3 Arduino shield, I decided to move away from the bare parallel HD44780 character LCDs and go with character LCDs and I2C backpacks (aka I2C LCDs). I found out a few popular designs and thought that I would summarize them for your convenience.

Most I2C LCDs are based on the following two ICs, all of which are I2C I/O (port) expanders:

  • PCF8574 or PCF8574A
  • MCP23008

Hardware:

Both ICs have 8 I/O pins. MCP23008 is more versatile but that is irrelevant to simple applications in LCDs.

Adafruit designed an I2C LCD backpack and Arduino LCD shields based on MCP23008. There are compatible devices sold on ebay. I can’t tell without seeing the sample code to decide whether an ebay seller is actually selling a compatible product. But if you do want to get one on ebay, make sure you find their library code and confirm that the library contains Adafruit’s names. Libraries you find from ebay sellers are likely out of date though. One good thing is that the compatible ones are very likely using the same pin assignments as Adafruit’s so it’s easy to get it to work once you get the library installed.

FM (Francisco Malpartida) designed an I2C LCD backpack based on PCF8574. There are lots of compatible devices sold on ebay and they don’t have the same pin assignments! This creates issues when you are making purchases thinking that they have certain pin assignments. The pin assignments refer to which PCF8574 pin is connected to which HD44780 display pin. Also the I2C addresses are all different. I don’t mean one might have an address of 0x3F and another might have 0x3E. What I mean is that one might have 0x3F and another one may be 0x20. There is no way to set one display that has address 0x20 to address 0x3F! PCF8574 has address space of 0x20 to 0x27. PCF8574A has address space of 0x38-0x3F. Most common addresses I’ve seen are 0x20, 0x27, and 0x3F, with the latter two sharing pin assignments that are different from the ones with 0x20 address. Most of these displays allow you to cut traces or solder pads to change addresses. Why would you if you don’t have multiple LCDs?

Software:

Adafruit has its own library Adafruit_LiquidCrystal. This library is decent. It can take different pin assignments as parameters. On the other hand, it is a different library than Arduino’s included LiquidCrystal library. So code you wrote for LiquidCrystal library may need some change when you switch to an Adafruit compatible I2C LCD.

FM wrote a library New LiquidCrystal. This library is pretty good. You can use a number of different LCDs including parallel HD44780 LCDs, I2C LCDs using PCF8574, LCDs using shift registers etc. A nice feature is that there is a base class LCD so regardless what actual type of LCD you are using, as long as it’s supported by this library, it works the same way on the software level as another supported LCD.

Since not all PCF8574/74A I2C lcds have the same pin assignment, or even back light polarity, using the correct definition will be crucial. I found the following three definitions. Each seems to work with the particular I2C address, although there is no relation between I2C address and how the pins are assigned (by circuit designer):

The first two work on backpacks that look like this:

Notice that only the address is different. Pin assignments and back light polarity are all the same.

LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Blue potentiometer with back light jumper.

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Blue potentiometer with back light jumper.

The last definition works on backpacks that look like this:

Notice that pins are very different and back light polarity is negative.

LiquidCrystal_I2C lcd(0x20, 4, 5, 6, 0, 1, 2, 3, 7, NEGATIVE); // Tiny mental potentiometer no back light jumper.

Detection:

In case you can’t determine the address or pin out, say none of the above definitions work, but you’re sure the IC is PCF8574/74A, you should first scan the I2C bus for the address, and then use your meter to map out the pin assignments, and then use your definition. The lcd constructor has the following parameters: lcd(add, En, Rw, Rs, d4, d5, d6, d7, Bl, Pol).

Here is the I2C scanner I use by Tod E. Kurt:

https://github.com/todbot/arduino-i2c-scanner/

 

Phi-3 shield videos

Here is a video of me navigating through the alarm clock program’s menu:

Here is a video of me explaining the components of the shield:

Here is a video of me explaining the different kits you can buy:

OK one more assembling modules on the shield:

Phi-panel 20X4 kit available again

Sorry the Phi-panel 20X4 panel kit was unavailable for a while. I’ve made some updates to the board. Here is a picture of the board:
2017-02-28-20-42-47

This is the back side:
2017-02-28-20-42-57Notice that the push buttons are all surface mount buttons. The have low profile and are a bit different from the old buttons with a thicker profile and black plunger.

Also most other components are surface-mounted.

The kit will have all surface-mounted components pre-assembled but the following parts still need your assembly:

LCD’s pins, 6-pin female header on back side, and the speaker. You also have to adjust the potentiometer to get proper contrast.

Open source data logger

I have been designing data logger for a number of years. This is my answer to lots of data logging needs. An Arduino Nano-based open source data logger:

ospl-th-on

The logger provides the following features (in green) including features of Arduino Nano (in black):

Microcontroller Atmel ATMEGA328P
Power 5 V via USB or 2X AA battery (internally)
Digital I/O 10 (4 PWM output, other Arduino pins used internally)
Analog Input 4 10-bit ADC (8 on ATMEGA328P, only 4 brought out)
DC Current per I/O Pin 40 mA max
Flash Memory 32 KB of which 2 KB used by bootloader
SRAM 2 KB
EEPROM 1 KB on ATMEGA328P, 32 KB on real-time clock breakout board
Clock Speed 16 MHz
MicroSD card 32 GB maximum
Real-time clock Temperature compensated (DS3231)
ADS1115 4-chn 16-bit differential ADC with up to 16X programmable gain
LCD 16 column by 2 row character LCD with back light on/off control
Input Rotary encoder with switch (when shaft is pressed)

Table. Specification of Arduino Nano and the rest of the modules.

Another photo:

red-version-assembled-lcd-removed

As you can see, the logger incorporates a number of breakout boards instead of including these ICs on a single circuit board. More to come…

Phi-shield revised and released

phi-3-shield-on-in-hand

It has been a while since I gave the phi-shield a major revision. I’ve been working on this for a while and now I am releasing the Phi-3 shield. This shield continues to support user interaction with LCDs and buttons. Here is a list of the features:

The following hardware are provided by the shield:

  • 20X4 LCD with back light on/off control
  • Six buttons (up/down/left/right/B/A)
  • Two LED indicators
  • Speaker
  • MicroSD card slot
  • Real-time clock (DS3231)
  • EEPROM (32KB 24LC256)
  • Connector for Adafruit Ultimate GPS module or Bluetooth module
  • Stacking headers for easy access to all pins.
  • Recessed board right edge for easy access to MEGA’s 18X2 pin headers on the right side.
  • Reset button

phi-3-shield-lcd-side-by-side

The following software functions are provided by various supporting libraries:

  • User-selectable menu (LCD + buttons)
  • Number and text entry (LCD + buttons)
  • Scrollable long text (LCD + buttons)
  • Date and time (DS3231 or GPS)
  • Location (GPS)
  • Data and configuration storage (MicroSD card and EEPROM)
  • Playing simple tones (speaker)
  • Indicators (LEDs)
  • Wireless connection (Bluetooth module)

phi-3-shield-lcd-removed-annotated

There are three tiers of Phi-3 shield kits: kit0, kit1, and kit2, none of which includes a GPS module. The kits are immediately available. Buttons with color caps as pictured will be included while supplies last.

Here is the Phi-3 shield’s own page. There are links on the page to make purchases. Or you can visit the BUY page to see what stores carry this shield.

Phi-3 shield

Video demonstrations will be available next week. Meanwhile, the support of Phi-2 shield will remain. If you need Phi-2 shields, I have them available.

phi-3-shield-bottom-rtc-lcd-wire-removed

Phi-2 20X4 shield kits

This kit is nearly sold out. Due to Chinese New Year, all re-ordered boards and components are expecting long delays. If Inmojo.com and my paypal sales buttons indicate the kits are sold out, then the kits are indeed sold out. Please be patient and check back in a week or so. Sorry for the inconvenience.

SDI-12 concurrent measurement

If you have a few SDI-12 sensors and want to quickly read their values, you may need to perform concurrent measurement. In regular measurement, using an M command, your logger issues the M command and expects the sensor to respond with the number of seconds to wait until data are ready and the total number of values. Here is an example. Assume sensor address is 1. Green is logger and blue is sensor:

1M!

10054\r\n

1\r\n

As you see, the sensor 1 needs 005 seconds to perform the measurement, which returns 4 values. Only the sensor needs to send carriage return (\r) and new line (\n). If the sensor finishes measurement before 5 second expires, it issues a service request, i.e.  its address 1 and carriage return and new line. The logger will respond by asking for data once it receives the service request.

Once the service request is received, or the expected 5 seconds elapses, the logger will ask for data using a D0 command, i.e. D and zero. The sensor will respond with data:

1D0!

1+12.34+56.78-90.12+34.56\r\n

If you have multiple sensors, you need to repeat the process multiple times, waiting about 5 seconds for each sensor. That is a lot of time. If your sensor supports concurrent measurement, you can shorten your wait time to only 5 seconds instead of 5*(number of sensor) seconds. Here is the process using concurrent command C, assuming 5 sensors:

1C!

100504\r\n

2C!

200504\r\n

3C!

300504\r\n

4C!

400504\r\n

5C!

500504\r\n

There won’t be any service request issued and the logger can go ahead to talk with the next sensor as soon as the current sensor responds with number of seconds to wait and number of data points 04 it will return. Notice that the last TWO digits now indicate the number of data points it will return, not the single last digit.

Now the logger proceeds to wait for 5 seconds and then start asking for data the same way it does when it used M command:

1D0!

1+12.34+56.78-90.12+34.56\r\n

2D0!

2+12.34+56.78-90.12+34.56\r\n

3D0!

3+12.34+56.78-90.12+34.56\r\n

4D0!

4+12.34+56.78-90.12+34.56\r\n

5D0!

5+12.34+56.78-90.12+34.56\r\n

Since all sensors are taking measurement almost simultaneously, you don’t have to wait for them individually, saving a lot of time.

Don’t stop here. Sometimes concurrent measurement is SLOWER than reading one sensor at a time! This only applies to faster sensors, such as Decagon 5TM soil temperature and volumetric water content sensor. It reports that it needs 1 second but it requires significantly less than 1 second. So if you use concurrent measurement, you will be forced to wait for a whole second. SDI-12 sensors are intended to be low-power but not for speed. The 1200 baud rate translates into about 120 characters per second, shared between the logger and sensor. The time to send the commands and data back and forth between a single sensor and the logger could take half a second to do!

Procedure to produce small batches of devices

Over the past years, I’ve designed and built devices in small batches such as 10-25 units at a time. I’ve gained some experience doing such small builds. The following is a procedure for building a small batch SDI-12 + Analog USB devices.

The device has a USB serial converter IC FT232RL, an MCU ATMEGA328P (same as Arduino Uno’s MCU), an ADS1115 16-bit analog-to-digital converter, precision resistors, fuse, screw terminal blocks, jumpers etc.

I build the device first by reflow soldering the surface components, and then hand solder the thru-hole components once I’m done confirming the reflow soldered components are working. You’ll see why these devices can’t be sold at $4 a piece, not just because the components cost more from legitimate vendors such as digikey, Mouser, Newark, etc. Most of the steps can’t be completed by someone without proper training of what the device does.

Here it goes. Any recommendation? Post a response!

Manufacturing and inspection procedure

Date: 2016-11-23

1.    Preparation and printing solder paste:

  1. Remove solder paste from refrigerator and set it in room temperature for one hour.
  2. Clean board with alcohol and lint-free wipe.
  3. Visually inspect board for defects and reject boards with visual defects.
  4. Align board with stencil.
  5. Print solder paste.
  6. Check registration especially for ADC, MCU and FTDI chips. Reprint in case registration is too far off.
  7. Wash and dry stencil.
  8. Return solder paste to refrigerator.

 

2.    Components placement:

  1. Place MCU. Check alignment with 3X loupe.
  2. Place FTDI chip. Check alignment with 3X or 10X loupe.
  3. Place ADC. Check alignment with 10X loupe.
  4. Place (5) 100nF caps.
  5. Place (1) 10uF cap.
  6. Place (2) 22pF caps.
  7. Place (1) fuse.
  8. Place (1) EMI bead.
  9. Place (3) 10K resistors.
  10. Place (1) 100K resistor.
  11. Place (4) 1K precision resistors.
  12. Place (4) 10K precision resistors.
  13. Place (1) crystal.
  14. Place (1) mini-USB connector.
  15. Check resistor values with loupe. Replace wrong resistors.

 

3.    Reflow soldering:

  1. Place boards on reflow over racks.
  2. Attach thermal couple to a plated hole on one board.
  3. Turn on temperature gauge.
  4. Connector reflow oven to power.
  5. Follow reflow specifics, make sure to time each step with stopwatches. STOP if expected temperature is not reached within expected time.
  6. Disconnect reflow over from power.
  7. Remove boards and cool them off.

 

4.    Visual inspection:

  1. Visually check for solder issues on chip resistors, caps and other components.
  2. Check for solder bridges on ICs with a 10X loupe.
  3. Check USB connector for bridges.

Found any issues?

  • Y: fix with flux paste, solder braid, and iron
  • N: proceed

 

5.    Flash firmware:

  1. Connector programmer to PC.
  2. Place board on pogo pins.

Programmer detected board?

  • Y: flash firmware

MCU detected after flash?

  • Y: proceed
  • N: check soldering near XTAL pins
  • N: inspect MCU for solder issues and other issues (IC in wrong orientation etc.). Add flux paste and reflow pins.

 

6.    USB connection and initial ADC check:

  1. Connect board to PC.

USB port detected?

  • Y: proceed

Device responding to ID command?

  • Y: proceed
  • N: check MCU and FTDI chip for solder issues

Device returning analog measurements?

  • Y: proceed
  • N: check ADC and MCU I2C pins for solder issues
  • N: inspect connector and FTDI chip for solder issues

 

7.    Check ADC and resistors:

  1. Solder headers and connectors.
  2. Connect different resisters to analog pins.
  3. Set HIGH jumpers on all channels.
  4. Read single-ended inputs.

Results are as expected?

Command ‘zI!’ should return ‘z13Liudr   SDITRD130\r\n’. Command ‘zM!’ should return ‘z0014\r\nz\r\n’. Then command ‘zD0!’ should return ‘z+0.xxxxx+0.xxxxx+0.xxxxx+0.xxxxx ‘ where x is arbitrary but the first x in each number is unlikely going to change if you poll again. Command ‘zM1!’ should return ‘z0012\r\nz\r\n’. Then command ‘zD0!’ should return ‘z+0.000xx+0.000xx ‘ where x is arbitrary and positive signs may be negative signs at times but both values should be very small with at least 3 zeros after decimal.

  • Y: proceed
  • N: check resistors and ADC for solder issue

 

  1. Set LOW jumpers on all channels.
  2. Read single-ended inputs.

Results are as expected?

  • Y: proceed
  • N: check resistors and ADC for solder issue

 

8.    Check SDI-12 bus:

  1. Connect SDI-12 sensor to one SDI-12 terminal.
  2. Poll SDI-12 sensor.

Does sensor return values?

Command ‘1M!’ should return ‘10012\r\n1\r\n’ Then command ‘1D0!’ should return ‘1+1.xx+2x.x’ where x is arbitrary but unlikely to change if you poll again. The second number is temperature so indoor reading should be above 20.0 C.

  • Y: Device passed QC test J
  • N: check MCU SDI-12 bus pin for solder issues
%d bloggers like this: