Category Archives: Electronics

Ben Eater’s Breadboard Clock revisited

I got to thinking that there must be a simpler way to make a clock source… https://eater.net/8bit/clock and I realized that using anATTINY85 based board seemed a bit of non-retro silliness after a while… So I looked again for a legacy IC-based solution with a lower chip count than 3 LM555s and a few additonal GLUE LOGIC ICs. Keep in mind, this was not because I have a problem with the LM555 clock source from Ben, as this was just an ‘experiment’. After a while of searching through my parts, I found the CD4047 IC. So, here is what I came up with. The best results for me came from using the `Q out pin... but bothe ‘Q’ and ‘/Q’ are available in addition to the OSCILLATOR pin.

Original Drawing
Original Drawing

I did get my PCBs… so here is Rev1 with a switch bodge as I need to add a capacitor across the switch for reliable presses. So this is what the CPU clock circuit becomes. Revision 2 will add a Halt feature… and O only needed 1 more resistor.

GAL/PAL Programming

A potentially lost art from the the early days of Microprocessor based computers.

What is it?

A PAL or GAL is a type of programmable logic gate chip whose basic design goal is to reduce the number of chips on a printed circuit board by allowing a designer to add truth tables to a single chip, thus reducing chip count.


Typical board from the 70’s/80’s era… with lots of TTL Logic ‘glue’.

Boards can be made much smaller, or more dense by reducing the number of ‘black box’ types. In many cases, each of the smaller IC’s on the board above has a dedicated logic function that they offer one or more of. Basically, each chip is designed to perform one type of function.

The PAL, or Programmable Array Logic, and GAL, or Generic Logic Array, are one-time and multi-use re-programmable logic IC that replaces many of these chips on the board. By allowing the logic decisions between inputs and outputs to be customized as needed, these devices are generically called “Programmable Logic Devices, or PLD’s.

By today’s standards, these devices are obsolete as new devices have superseded them far more features and with pins numbering into the hundreds. The Complex PLD (CPLD) is well beyond what will be discussed here. They are programmed in an entirely different way than the legacy PLD devices. PLD’s are programmed in a way very similar to EPROMS and as a result, devices like the affordable TL866 programmer can be used to prepare them.

Pin Assignments in the GAL16V8 – LEFT SIDE are inputs, RIGHT SIDE is outputs

So, how would you use one of these? We can look at an example of where we can replace a few logic IC’s with a single chip. A good example is Grant Searle’s Z80 design. http://searle.hostei.com/grant/z80/SimpleZ80_32K.html

On the web page, there is a diagram of a small but complete Z80 based system. Some logic is used to route memory reads and writes as well as ROM address decoding and such.

I’m talking about replacing U5 and U7 with a single chip. Keep in mind this is an exercise and was picked because it should be pretty easy.

So, if we look at what the chip is doing and how we can apply it to PLD design file… lets examine whats happening.

If you look at the equations on the right, you can see that this is what the 2 chips are accomplishing. (Ignore the system clock portion of U5) By carefully examining the logic of the wiring… this is what we ended up with.

The nest step is to match the Inputs and Output pins to Names that are used in the equations.

The final step is to add the logic (far right column) equations into the programming file.

The resulting file looks like this:

Name     Z80MemDecode ;
PartNo   00 ;
Date     12/27/2018 ;
Revision 01 ;
Designer Pete Willard ;
Company  Personal ;
Assembly None ;
Location  ;
Device   G16V8 ;

/* *************** INPUT PINS *********************/
PIN 2   = !WR                     ; /*   WRITE                         */ 
PIN 3   = !RD                     ; /*   READ                          */ 
PIN 4   = !MREQ                   ; /*   MEMORY REQUEST                */ 
PIN 5   = A13                     ; /*   ADDRESS                       */ 
PIN 6   = A14                     ; /*   ..                            */ 
PIN 7   = A15                     ; /*   ..                            */ 
PIN 8   = !IORQ                   ; /*   INPUT OUTPUT REQUEST          */ 
PIN 9   = !RST                    ; /*   RESET                         */ 

/* *************** OUTPUT PINS *********************/
PIN 19  = !RAMCE                  ; /*  RAM Chip Enable                */ 
PIN 18  = !ROMCE                  ; /*  ROM Chip Enable                */ 
PIN 17  = !MEMRD                  ; /*  Memory  Read                   */ 
PIN 16  = !RAMWE                  ; /*  RAM Write                      */ 
PIN 15  = IOREQUEST               ; /*                                 */ 
PIN 14  = RESET                   ; /*                                 */ 

/* *************** LOGIC EQU  *********************/
RAMCE       = !A15                 ; /*                                 */ 
ROMCE       = A13 # A14 # A15      ; /*                                 */ 
MEMRD       = MREQ # RD            ; /*                                 */ 
RAMWE       = MREQ # WR            ; /*                                 */ 
IOREQUEST   = !IORQ                ; /*                                 */ 
RESET       = !RST                 ; /*                                 */ 


In order to program a GAL the source file (“.pld”) must be transformed into a JEDEC file. The resulting JEDEC file uses the filename suffix of JED. This is the file that is used by the TL866 Programmer to prepare the device according to our design.

The editor used to create the specification (PLD) and JED file is called WINCUPL, which is a free tool made a available by ATMEL and still offered by the company acquired ATMEL, Microchip.

Here is the link: https://www.microchip.com/design-centers/programmable-logic/spld-cpld/tools/software/wincupl

So… DID IT WORK? Nope !

It turns out… WINCUPL has issues with NEGATIVE OUTPUT LOGIC in equations. So… back to the drawing board… I’ll provide a fix later…

Arduino rant

Programming Framework

This post is about coding as much for yourself as for others. While it’s really easy to write pages of code with only a few comments, in the long run, writing well structured and clearly legible code helps a lot when you return to it months later and are forced to ask yourself “What was I thinking?”

Programmers Lament: ‘I think I wrote this section of code late at night after I had a few beers with friends. I think I need to go out and have a few beers to understand why I wrote it like this.’

I try to write all my code as if I was about to post it to public blog and that the reader will have only rudimentary knowledge of what my goal is. This means that I will need to explain myself clearly. This will impact the kind of comments I write and will remind me that resorting to cute code tricks and obfuscation (even accidental) is a bad idea.

I will admit that I am not a professional programmer, but I play one on IRC. Joking aside, I am not even a trained programmer unless you count reading books on programming. My advice here comes from concepts I have learned through years of reading other peoples code. I have found that what I call the “good” code is written by someone who is well organized writes decent comments and is reasonably methodical in how they break down a problem. Some of my own ideas start as inspiration from these organized and creative programmers whose shoulders I stand on. I will show you a programming template technique I learned from Jon McPhalen. See what I did there? Programming rule #1 should be, “Always include attribution and give appropriate credit for your borrowed ideas”.

While there are some decent books on programming style, it’s not the main focus here. This is about remembering that you could have a future audience that reads your code, so writing efficiently, being consistent and adopting good conventions is paramount.

Using a template for organized code

The Arduino environment already enforces a certain method of coding on us. It requires us to write using the core C++ language and that we employ two sections of functionality in our code. So the base minimum code is the well understood:

void Setup() {

} 

void Loop() {

}

While it is nice that the Arduino developers have saved us a lot of trouble but making “getting started” so easy, it doesn’t much help when you come back later to revise your code later and are clueless because you thought, “I’ll make it pretty later” and you never do. I have adopted a starting point for code that includes some more information than just the bare minimum required. The goal here is to start with a template that is nicely sectioned out so you have a road map for moving forward.

 

Here is an example of a template as a starting point:

//==============================================================================
// TTTTT EEEEE M   M PPPP  L      AAA  TTTTT EEEEE        III  N   N OOOOO 
//   T   E     MM MM P   P L     A   A   T   E             I   NN  N O   O 
//   T   EEEE  M M M PPPP  L     AAAAA   T   EEEE          I   N N N O   O 
//   T   E     M M M P     L     A   A   T   E      ..     I   N  NN O   O 
//   T   EEEEE M   M P     LLLLL A   A   T   EEEEE  ..    III  N   N OOOOO 
//==============================================================================
//==============================================================================
// Program: template.ino
// Author: Pete Willard
// Version: 1.0
// Target: Uno
// Date: 2015/04/02
// Time: 06:41:02
// Notes:
//
// ----------------------------------------------------------------------------
// 'THE BEER-WARE LICENSE':
// petewillard@gmail.com: As long As you retain this notice you
// can do whatever you want With this stuff. If we meet some day, And you think
// this stuff is worth it, you can buy me a beer in return. Pete Willard
// ----------------------------------------------------------------------------
//
// Reference:
//==============================================================================

//=====[ INCLUDE ]==============================================================

//=====[ CONSTANTS ]============================================================
#define DEBUG 1 // 0 = debugging disabled, 1 = enabled

//=====[ PINS ]=================================================================
int onboardLed = 13;

//=====[ SETUP ]================================================================
// Runs only one time at startup
void Setup() {
pinMode(onboardLed,OUTPUT);

}

//=====[ MAIN PROCESS LOOP ]====================================================
void Loop() {

}

//=====[ SUBROUTINES ]==========================================================
void printBreak() {
Serial.println("=============================");
}

 

I actually went so far as to write a small program that uses a fill in form to create this template format on demand. It even creates that retro-style banner with the file name spelled out on top.

A quick review shows that the template has defined a sample constant that you can use while debugging code. Changing this constant between 0 and 1 will enable you to write some conditional code that will print or stop printing debugging data with just 1 edit.

It also contains an example of using meaningful names. Using the variable assignment such as ‘onboardLed’ for pin 13 helps to make the code more readable.

Variable names don’t have to be short and are much better when multiple words are compounded into a meaningful descriptive names. For enhanced readability, try to avoid using using ALLCAPS and avoid variables with leading underscores. Try to adopt the much more accepted “camelBack” notation. This notation starts with lowercase and is the practice of writing compound words or phrases such that each following word or abbreviation begins with a capital letter*. Inserting underscores inside variable names makes the camelBack method redundant so just pick either one and stick with it.

* The case where the leading letter is lowercase but all subsequent words are capitalized is also called the Microsoft style.

Modular thinking

To me, when it comes to reading other peoples code, there is nothing more disturbing than reading page full of if conditional statements that include redundancies and a clear sign of poor planning. If I need to keep track of more than a few conditions while reading code I find that the logic of what “was intended” to be easily lost.

My approach to solving this has always been to create function blocks of code and keep the main section, in our case the Loop(), as clear and readable as possible. In C, this is called creating a “function” and it is sometimes referred to as a procedure or subroutine. I personally use all three terms interchangeably.

In most cases, you will write a procedure that accepts an argument and returns a result but this is not a requirement. For example, you can have a subroutine that just performs a task that makes the rest of your code look cleaner. Like this:

void printBreak() {
  Serial.println("=============================");
} 

So in your main code, all you need to type is:

printBreak();

In one of my programs, I have a Loop() section that basically contains 3 steps:

sampleSensors();	// collect all external sensor variable data into a “struct” variable</span>
printResults();	// send the results in 1 CSV formatted line</span>
cycleCheck();		// is it time to get updates from sensors?</span>

The functionality of the loop section remains readable and it is not bogged down with actual logic decisions. The logic and action steps are reserved for the procedures themselves and the procedures call other procedures to keep things organized. Breaking up tasks will actually help make your procedures more useful and in a lot of cases… re-usable.

I finally got around to documenting how I wired my MendelMax 3D printer

Mendelmax wiring

Mendelmax wiring

I recently added a 24V Kapton heatbed and new Y rail system to replace the finicky dual rod system. The upgrade required me to remove the existing 12V power supply and replace it with a 24V 200W supply. Since only the new heater in the bed requires the 12V I also installed an adjustable Stepdown DC/DC regulator (A 12A unit for sale on Amazon for about #$12 under the name DROK). The unit does get slightly warn during use, so I added a small fan for the smaller regulator that supplies 12V for all the motors, the controller boards and the fans.

The power for the Arduino mega is controlled via a switch from a 12V distribution panel I purchased at Autozone designed to allow power control for up to 6 unique devices. So the unit can still run standalone if needed. I removed the Diode on the Ramps 1.4 board that supplies power to the Arduino since there are those times when you just want to kill power to the arduino board.

The on board Polyfuses were removed and replaced by a piece of hookup wire.  The fuses for the power source are now panel mounted using standard 3AG fuse holders.

Note: My USB cable that comes from the PC already has a switched power option.

 

On a side note: Working with Brian at Ultibots regarding my Y axis upgrade was a superbly positive experience.  Ultibots is now my first choice for parts. 

So… I ordered a Spark Core…

… and these things are really neat.

Ok, so what is a Spark Core?   Wait…  lets start with the fact that this was a Kickstarter project that succeeded and is now a full fledged product that sadly I did not know about until afterwards.  I’d have been there supporting this Kickstarter if I had known about it. I tried to support a different but *very* similar Kickstarter project (well, not tried, I did support it) and have yet to see the product that is now many many months late. Now that I have the Spark core, and I like it, I’m pretty sure I won’t care when the Flutter *finally* arrives.

spark core image

spark core

 

So, back to what a Spark Core is.  It is a small device, roughly the size of an oversize collector edition US postage stamp.  It’s designed to fit into a Solder-less breadboard for easy project development and comes in 2 flavors… one with an on-board “chip” antenna and one with a small antenna jack that allows you to install your own wifi antenna… I grabbed an antenna out of my pile of broken wifi routers.  I wasn’t sure it would work… but seems to work just fine and uses the same RF jack (imagine that?).

For more information on what a Spark Core is, go here: Spark Core Getting Started

So what am I doing with it? Well, I’m learning what it can do first… and that’s a tiny bit tricky. The documentation is written more geek than noob friendly and while I have no issue with the documentation in general, it does seem to have some gaps here and there. I suppose with time this will all get better.

For example; they did make it seem like it would do some automagic things to get it quickly “registered” in the cloud and that my phone app could talk to it right away. No such luck. My Phone app never found the device and the status LED said I was happily connected. I needed to go through a rather manual process of attaching to the device in a serial debug mode to capture my unique ID to claim my core manually. Again, it was supposed to just work… but a quick check says I’m not the only one this happened to. (ed. I did acquire an additional spark core and the second one installed and connected and was claimed without a hiccup)

With that initial stumble out of the way… I needed to see how Arduino compatible this is so I started writing some code. As long as I stick to true Arduino’s abstract language (and not hardware dependent short cuts like you might find in some existing libraries) all is well. This device does not have an AVR MCU at it’s heart. It uses an STM32 MCU which is a much more capable device coupled with a TI CC3300 wifi in-a-box chip to create a complete arduino-like wifi device in a seriously small package.

My first project on the device after playing with examples is a simple “always correct” LED clock using the SparkFun 4 digit seven segment serial LED. It works… and displays the correct time as soon as it boots up with no need for battery backup or an RTC chip. The part number COM-11629. This is a mildly depressing LED display due to the fact that it is running on 3.3 volts and has 1000 Ohm current limiting resistors on the LED’s. (Did I mention that the Spark Core is a 3.3V device? No? oops.)

Seriously… 1000 Ohms at 3.3 volts is not the ideal value of the current limiting resistors. It should be around 47 Ohms… not 1000 Ohms. The end result is you can only really see the display in the dark.

2014-12-05 14.10.37

Anyway… the code part works… It uses built in features like wire library and time library that are already in the API. Here, see for yourself*…


//==============================================================================
//  III  2222   CCCC  CCCC L     OOOOO  CCCC K   K
//   I       2 C     C     L     O   O C     K  K
//   I    222  C     C     L     O   O C     KK
//   I   2     C     C     L     O   O C     K K
//  III  22222  CCCC  CCCC LLLLL OOOOO  CCCC K   K
//==============================================================================

//==============================================================================
// Program:      I2Cclock
// Author:       Pete Willard
// Version:      1.0
// Target:       SparkCore
// Date:         2014/12/04
// Time:         08:14:45
// Notes:

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

//
// Reference:
//  Used rather sketchy Sparkfun serial LED display "datasheet"
//  Part #  COM-11629 - Note: it's a rather dim display.
//==============================================================================
 # define bitSet(value, bit)((value) |= (1UL << (bit)))
 # define bitClear(value, bit)((value) &= ~(1UL << (bit)))

//=====[ CONSTANTS ]============================================================
// # define DEBUG 0 // 0 = debugging disabled, 1 = enabled
//This is the default address of the OpenSegment with both solder jumpers open
 # define DISPLAY_ADDRESS1 0x71

// definitions from sparkfun for bitwise led controls (decimal/colon/dot)
 # define COLON 4
 # define DOT 5

// Time Sync and Time Zone settings
const int syncInterval = 60 * 60 * 8; //sync every  4 hours

static signed char const DEFAULT_TIME_ZONE = -4;

//=====[ VARIABLES ]============================================================
long millisTimer;
int lastSync = 0;
boolean colonOn = false;
boolean ampm = true;
char bits; // used to track binary values for bitwise

//=====[ SETUP ]================================================================
void setup() {


	Spark.connect();
	 while(Spark.connected() == false) {
	     delay(100);
	 } while(Time.year() == 1970)
	  {
	     Spark.syncTime();
	     Spark.process();
	     delay(100);
	  }
	 Spark.disconnect();
	 while (Spark.connected() == true) {
	     delay(100);
	     Time.zone(DEFAULT_TIME_ZONE);
	 }
	 
	Wire.begin(); // join i2c bus as master
	Wire.beginTransmission(DISPLAY_ADDRESS1); // transmit to slave device #4
	Wire.write('v');
	Wire.write(0x7A); // Brightness control command
	Wire.write(100); // Set brightness level: 0% to 100%
	Wire.endTransmission(); // stop transmitting

}

//=====[ MAIN PROCESS LOOP ]====================================================
void loop() {
	ampm = Time.isAM();
	showTime();
	delay(1000);
	adjustTime();
}

//==============================================================================
void adjustTime() {
	if (lastSync + syncInterval < Time.now()) {
		Spark.syncTime();
		lastSync = Time.now();
	}
}

//==============================================================================


//==============================================================================
//  Must be called after a "begin.transmission()" command.
//==============================================================================
void colonFlash() {
	//Blink the colon every other second

	if (colonOn == true) {
		colonOn = false;
		bitClear(bits, COLON);

	} else {
		colonOn = true;
		bitSet(bits, COLON);

	}
	Wire.write(0x77); // control command
	Wire.write(bits); // Turns on colon
}

//==============================================================================
//  Must be called after a "begin.transmission()" command.
//==============================================================================
void setPM() {
	if (ampm == true) {
		bitClear(bits, DOT);
	} else {
		bitSet(bits, DOT);
	}

	Wire.write(0x77); // control command
	Wire.write(bits); // Turns on colon

}

//==============================================================================
void showTime() {
	char out[] = {
		0,
		0,
		0,
		0
	}; // place holder for time array

	char hour = Time.hourFormat12();
	char min = Time.minute();

	sprintf(out, "%2d%02d", hour, min); // format current time into char array
	Wire.beginTransmission(DISPLAY_ADDRESS1); // begin I2C transmit to device

	setPM();
	colonFlash();

	for (byte x = 0; x < 4; x++)
		Wire.write(out[x]); //Send a character from the array out over I2C
	Wire.endTransmission(); //Stop I2C transmission

}


Being creative in electronics as a hobbyist

I am not an Electronics Engineer. I am not officially trained and have no related certifications. I am however, what I would call “experienced”. I was introduced to electronics as a hobby in the late 1960’s as a kid in home where electronics was paying the bills, so to speak. My father was, at the time, an electronics systems technician working for a large military contractor.

It probably started the day I “went to work” with him and he showed me the project he was working on… It was a missile launch system loaded with cool control panels and of course, Nixie number indicator tubes.

So, at around age 13 or 14, I wanted to know how all this stuff worked. Unlike today, we had nothing like the Internet so find out how stuff worked involved going to the library and reading books or the magazines of day like Popular Electronics. My dad also had a collection of technical books and schematics that I would read over and over again.

So it started to become clear to me that a “designer” would use a collection of parts and arrange them in a particular way to take advantage of their physical “laws” to achieve a particular result. It also became clear that the characteristics of each individual part were as important as how they were assembled together. A particular device is chosen based on the effect it’s value and parameters have on the overall assembly. It sometimes became clear to me that some parts are chosen based on availability and commonality making them what the assembly is built around.

In my case, I started to understand schematics and the meaning of the symbols rather quickly. I also discovered that unless I truly know what a part does, I don’t try to design with it. This lead to the start of a collection of component “data books”. Logically, these are no longer produced as it requires dead trees and we are much better served by online PDF files known as “Data Sheets”.

So, what does it mean to be a hobbyist?

Well, we are actually able to willfully misuse parts in ways they were never intended to be used, which is a luxury a professional designer doesn’t have. We don’t have a boss looking over our shoulder saying “Is it done yet? We are on a schedule here!”. In short, we can play. We can be creative. We can build and not be driven by time constraints and production budgets. We can have fun.

Where to start?

1) Try to learn some electronics theory. Nothing too deep. You should not have to go far beyond learning OHMS Law to be good enough. Lot of web resources exist already
2) Sketch your ideas out on paper before starting on the breadboard.
3) A solder-less breadboard and some jumper wires
4) Datasheets are king. Don’t try to use a part, especially a transistor or integrated circuit without one
5) Get some tools. You can get a good “temperature controlled” solder station for as little as $14. Wire cutters, needle-nose pliers and solder-sucker are all also high on the list of “should have’s”. A cheap un-controlled “fire-stick” or a “gun” type soldering iron are unsuitable for electronics.

With that out of the way… what’s next?

Find what interests you. For example, even after 50 years, we still use discrete transistors. It is still a major building block in electronics. Learning how they work can be a fun adventure so I’ll tell you about how I learned about transistors. I found a book in the library about transistor “multi-vibrators” and not having a clue what a multi-vibrator was, I started reading it. It turns out, it’s a circuit family based on a design using at least 2 transistors with a feedback path where the state of one transistor affects the state of another. Such a nice place to start. I learned about R/C (resistor/capacitor) interaction and how it could create a time delay and how this R/C behavior could create an oscillator or a circuit that could extend a small pulse into a long one.

Thus began my long journey of learning something new nearly every day… and the start of a fun hobby.

Yes, I can make a .65 Pitch breakout

Last week-end I wanted to prototype with an INA219, but I only bought the SMD version for my final design. I still wanted to play with it a bit, so I needed to mount on one a Solderless compatible format. I just didn’t have a pre-made one handy. So I made one.

Screenshot
Quick Sprint Layout Drawing


Layout File

2014-03-22_13-34-51_315_zps958360ea

2014-03-22_13-05-50_190_zps8cbc8dad

2014-03-22_14-21-17_177_zps82a3a6f6

1-wire Power Injector

One way that I get reliable 1-wire communication is to use a power injector. This means that the along with the 1-wire signals, I inject a supply voltage into additional cable pairs.  Since  the most readily available commodity cable currently is 8 conductor Cat-5 cable, chances are that you also use this cable for 1-wire cabling and have spare wires going unused. Dallas called the 1-wire bus a MicroLAN, so I will continue to use their terminology here.

For short runs, where the total length of the MicroLAN is < 30 meters and the network only has maybe 6 to 10 slave devices on it, cable selection for use on the MicroLAN is reasonably simple, as even flat modular phone cable can work with a small numbers of 1-Wire slave devices. However, the longer the MicroLAN, the more important cable properties and therefore cable selection becomes more critical.  However, since I’m dealing with 30M or less, I’ll focus on that here and leave the research for  better cable techniques for when I run into a problem.

One of the remaining issues with using 1-wire driven from an Arduino pin directly is the fact that it is also providing power to all of the devices on the the 1-wire LAN when in parasitic mode.   While 1 or 2 devices are of little concern, I started to worry about building a reliable 24/7 full time  MicroLan configuration that would report weather data from 8 or so sensors, most of which were located at the garden bed outdoors.  It became clear that some of my devices were really not performing as desired  when “parasitically”  powered when I finally put all the pieces together.

Experimentation showed me that the signal from the Arduino pin was just not up to that task of powering and communicating with all the devices without some random miscommunication here and there.  I would get values like 185F and not the 70F I was expecting from a 1-wire temperature sensor, for example.

My solution was reasonably simple.  I would create an external “middle-man” device that would insert power into the CAT-5 cable after leaving the Arduino board.  Its really just a dual supply from typical commodity wal-wart power source.  The unmodified 12VDC supply will be fed into the cable on a spare pair and treated as “unregulated” and a 5V regulator will be added to another spare pair and considered to be “regulated”.  All code will now be written to comply with the “non-parasitic” mode of 1-wire.

The Design:
1wire-power-injector

The PCB:
PI

LC Meter – Working…

This is a variation of many many other LC meters already published. It owes much of it’s design to the AADE LC meter that relies on the oscillation of a standard Analog Comparator using a capacitor and a coil. This solution is an attempt to take Kerry Wong’s Arduino implementation and simplify it a bit and to make use of latching relay for mode selection.

Notes: Initially I used a 2% tolerance .001uF capacitor and a small 5% tolerance RFC 220uH coil. results were OK, but not real close to actual values even after some tweaks so I looked for an alternative in my junk box.

I found a 1800pF Mica capacitor with 1% tolerance and a 82uH radial choke coil (Basically, the kind used in higher current situations). I did some quick math and determined that frequency of oscillation would increase to somewhere between 414473 HZ and 419973 HZ with the former being the mathematical ideal. (which I modded to an even 420000 for simplicity.)

My changes (completed and planned) to the Kerry Wong’s solution includes:

1) Software controlled backlight – no switch – I just turn it on… that works for now
2) Implementation of Latching Relay to eliminate a DPDT manual switch
3) Using an 8×2 LCD for smaller footprint
4) Battery Voltage sensing. If battery is low, shut off the backlight.
5) Push-on/push off power control with timer based auto shutoff. (5 minutes)

Testing showed me that I really didn’t like using the KHM Library from Martin Nawrath. I mean, it basically worked and that is what Kerry Wong used… but, I found that it was impacting my mode switch and calibrate button sensing. And that was just not good now that I was using a latching relay instead of a DPDT switch for mode change.

In the end, I opted for the Frequency counting library from PJRC instead:

CODE

Sprint Layout File:
Sprint Layout (V6)

Schematic:
MyPCB-LC-Chematic

Layout (only 2 minor errors crept in during etching):
MyPCB-ASBuilt

Etched PCB (tinned and sealed with matte clear laquer AKA Dullcote):
2013-05-04_21-37-03_810_zps5de5a16b

Silkscreen: Toner Transfer to TOP SIDE PCB, sealed with Future floor wax (clear acrylic)
2013-05-04_21-36-33_802_zps7ff47096

Front Panel:
panel2

You probably already knew this but… latching relays are neat

So, I’m hanging out in IRC and a guy wants to be able to use a latching relay (and hasn’t bought one yet) and wants to know how it can help his battery operated Arduino device switch contacts but not lose power to an engaged relay coil. “Simple”, I say, and then realize that I had intended on researching small current latching relays for my own project.

So here’s the circuit.

latchrelay
…and here’s the explanation.

The relay that was chosen is from the very likable OMRON G6 series of tiny relays. It is a dual coil type that latches to a position after a brief “impulse”. In this case… after the Arduino briefly supplies a connection to GND for the coil using an NPN transistor.

The specifics of the part are: G6SK-2-DC5 (You can check out the the full specs HERE )

This device is a 5V unit with a pair of 125 Ohm relay coils. (works out to be about 40 mA, too much for a MCU pin… so NPN drivers are required, not optional)

So, why do we have a DPDT unit? Because we need a spare pair of contacts to let the Arduino know which state the relay is in after power up… since it can be in either position when power off. The Arduino can know the relay’s current state by checking to see if (pin 7 in this case) a high is seen on the sense pin. The sense pin is set to draw 0.5 mA when in the SET state and 0 mA in the RESET state.

For the curious: Mouser.com stocks this part