I finished a couple of TinyBlinkys this evening. I had made them over the weekend and discovered that I was out of the correct kind of tactile button for them. So I placed an order with DigiKey and they arrived today. I had already gone so far down the process of placing components that I decided at the time to reflow all of the components except for the button, so when I came back to them today all that was necessary was to paste and reflow the buttons themselves.
Rather than stick them in the oven, I decided to just use my hot air rework station to melt the paste on just the buttons.
That worked just fine, but then my daughter asked if I could make her a blinky with alternating white and blue LEDs. So since I had everything out, I said "sure!"
So I pasted and placed one. I was about to get up and run it out to the garage to stick it in the reflow oven, but then I realized that I had the hot air gun going.... why not?
Long story short, it worked beautifully. Not only that, but it was really neat to watch the paste grey, then contract in on itself and ball on top of the pads and "suck in" the part (the surface tension and pad geometry conspire to center most parts).
For such a small board (1 inch in diameter), it was probably quicker to do it this way than in the oven. Anything much larger, and the oven probably wins. But faster or not, it's pretty cool to watch.
If you want to try it yourself, set your air station to 250°C and set the airflow to around "medium" or so. That should work for traditional (non-RoHS) tin-lead solder paste.
Thursday, May 29, 2014
Friday, May 16, 2014
DC-DC conversion
Trading volts for amps and vice-versa was what won The War of the Currents for Westinghouse. And for a century or more it's what's made AC our power distribution mechanism.
But at least on the small to medium scale, such shenanigans are possible with DC as well - they're just not quite as easy.
I've been using "canned" DC-DC converters from CUI for the Hydra so far with great success. But in putting together the GPS Pack project, I was introduced to the concept of the "Boost" converter, as well as it's polar opposite analog the "Buck" converter. Both are switching power supplies designed to output a different voltage than that which they are supplied. For the GPS pack, the NCP1401 is used with a couple of discrete external components to get 5 volts DC from one or two alkaline cells (so somewhere around 2-3 volts in).
For a boost converter, an inductor, a switch to ground and a diode from a "T". When the switch is closed, a circuit is formed from the input through the inductor to ground. The inductor is, effectively, "charged," in more or less the same way as a capacitor in parallel is (in fact, inductors are the opposite of capacitors in many ways, including how they behave in series or in parallel). When the switch is opened, the current through the inductor suddenly drops to a fraction of what it was. Inductors resist changes in current. In this case, it does so by creating voltage. That voltage passes through the diode (which, when the switch was closed prevented the driven circuit from shorting to ground through the switch), and powers the load, now at a higher voltage. As the voltage drops, the controller in charge of the switch closes it to start another cycle. Lather, rinse, repeat.
For a buck converter, the T is rearranged so that the switch is on the left, the inductor on the right, and the diode vertical. While the switch is closed, the supply will attempt
To raise the voltage supplied to the load through the inductor. When the voltage rises too high, the switch will open. The diode will "connect" the input lead of the inductor to ground, and the inductor - since it resists a change in current by supplying voltage - will power the circuit.
The CUI converters are certainly convenient. And I will still probably use the bipolar ones if for no other reason than to save space. But the next version of the Hydra may be powered by a discrete 5v buck converter from the 12v supply instead of a module.
But at least on the small to medium scale, such shenanigans are possible with DC as well - they're just not quite as easy.
I've been using "canned" DC-DC converters from CUI for the Hydra so far with great success. But in putting together the GPS Pack project, I was introduced to the concept of the "Boost" converter, as well as it's polar opposite analog the "Buck" converter. Both are switching power supplies designed to output a different voltage than that which they are supplied. For the GPS pack, the NCP1401 is used with a couple of discrete external components to get 5 volts DC from one or two alkaline cells (so somewhere around 2-3 volts in).
For a boost converter, an inductor, a switch to ground and a diode from a "T". When the switch is closed, a circuit is formed from the input through the inductor to ground. The inductor is, effectively, "charged," in more or less the same way as a capacitor in parallel is (in fact, inductors are the opposite of capacitors in many ways, including how they behave in series or in parallel). When the switch is opened, the current through the inductor suddenly drops to a fraction of what it was. Inductors resist changes in current. In this case, it does so by creating voltage. That voltage passes through the diode (which, when the switch was closed prevented the driven circuit from shorting to ground through the switch), and powers the load, now at a higher voltage. As the voltage drops, the controller in charge of the switch closes it to start another cycle. Lather, rinse, repeat.
For a buck converter, the T is rearranged so that the switch is on the left, the inductor on the right, and the diode vertical. While the switch is closed, the supply will attempt
To raise the voltage supplied to the load through the inductor. When the voltage rises too high, the switch will open. The diode will "connect" the input lead of the inductor to ground, and the inductor - since it resists a change in current by supplying voltage - will power the circuit.
The CUI converters are certainly convenient. And I will still probably use the bipolar ones if for no other reason than to save space. But the next version of the Hydra may be powered by a discrete 5v buck converter from the 12v supply instead of a module.
Tuesday, May 13, 2014
GPS Pack v1.1 is a go
The prototype boards came, and they worked flawlessly.
I am, however, going to roll a v1.2 for the hardware. This version will add a connection between the PPS pin on the GPS module and D3 on the ATMega. It will also add an LED connected to the FIX pin on the GPS module. As I tweeted a few days ago, it costs nothing to NOT stuff parts you don't need, but you have to roll a board revision ($$$) if you want parts that are not on the board.
I'm adding the PPS output in case someone wants to build a particularly accurate clock. I may rework my GPS clock sketch to run on this board. Not 100% sure about that, though (it doesn't need to be battery powered, for instance).
But in any event, the first version of the reverse geocache sketch is just about ready for GitHub. I want to spend a few more minutes checking it out this evening before I release it.
The sketch has three "modes" - Setup, Open and Game. Under normal circumstances, the box alternates between "open" and "game" mode. If it's in game mode, you push the button and if the box is in the right location, it will congratulate you, unlock the servo and switch to "open" mode.
In open mode, it will ask you if you're SURE you're ready to lock the box. If you are, then it will lock the servo and switch back to "game" mode.
In open or game mode, if you hold the button down for 5 seconds when it's asleep, it will prompt you for the "cheat code" (more on that later). If you enter the cheat code correctly, it will unlock the box and switch to "setup" mode (the very first time you start it up after a firmware update it will start in setup mode too).
In setup mode, you'll be shown the current fix and can, if you wish, convert that into the target location. You can also edit the target location if you wish. You can then specify a "target radius," which represents how close the box must be to the target for a "win." This distance can be 10, 20, 30... 100 meters in radius. It then asks you for a "hint type." When in game mode, if you push the button in the wrong location, the box won't open, but will give a hint. That hint can be either both the distance and direction (as a compass cardinal - ENE, SW, W, etc), just the distance, just the direction, or no hint at all. The next step will be setting the 4 digit cheat code. After all of that, it will ask you if you wish to exit setup mode. If you do, the box will revert to "open" mode.
While operating, the unit draws about 140 mA from two alkaline batteries. When sleeping, it draws less than 1 mA. If you do the math, a pair of 2000 mA-hr AA batteries should last either 14 hours of power-up time, or 90 days of standby time. Operating parameters are, however, stored in EEPROM, so if you can design a box where the batteries can be replaced without opening it, then you can replace the batteries without having to reprogram everything. There is a battery voltage sampling connection on the ATMega, and the current firmware is programmed to show a "low battery" error and shutdown when the voltage drops below 2 volts (lower than this and the GPS unit will lose it's warm start abilities). Given what the discharge curve for most alkaline cells looks like, there's a pretty good "knee" right after 1 volt (each) anyway. Still, even if the battery is low, it will allow you to attempt to enter the cheat code, which should let you open the box if it's necessary to do so to get at the batteries.
Like all "backpack" boards, the boards cost me around $7.50 from OSHPark. The LCD is around $12, and the rest of the parts are close to $10. But the Ultimate GPS module from AdaFruit is $30.
So I'm going to sell the "quick kit" without the GPS module for $35; a complete "quick kit" for $65 or a fully assembled unit for $75.
Thursday, May 8, 2014
A sub-second accurate GPS clock
I was able to finish a project from some time ago. I wanted to have a sub-second accurate GPS clock. The idea is that you could stick this clock in the background of something you're filming and get reasonably good and accurate timestamps. Of course, since it's using an LCD display, it's not going to be tremendously good, but for the price, I don't think anyone can complain.
To make it work, you connect up a GPS module of your choice to the RX and TX lines (experiments with SoftwareSerial on other lines were a failure) and the PPS pin to digital pin 2. You'll also need to connect up an AdaFruit RGB LCD shield, or replace LiquidTWI2 with LiquidCrystal and wire the display parallel-style.
This sketch is time-zone and DST aware, so you may need to edit the "summer" and "winter" timezone rule declarations. Depending on your GPS module, you may also need to change the GPS_BAUD or change the interrupt from RISING to FALLING.
#include <Wire.h>
#include <LiquidTWI2.h>
//#include <SoftwareSerial.h>
#include <TinyGPS.h>
#include <Time.h>
#include <Timezone.h>
#define PPS_PIN 2
#define PPS_INT 0
#define RX_PIN 4
#define TX_PIN 3
#define GPS_BAUD 4800
#define LCD_I2C_ADDR 0x20 // for adafruit shield or backpack
LiquidTWI2 display(LCD_I2C_ADDR, 0, 0);
//SoftwareSerial gps_port(RX_PIN, TX_PIN);
#define gps_port Serial
TinyGPS gps;
time_t prevTime = 0; // when the digital clock was displayed
unsigned int prevTenths = 99; // not 0-9
boolean complained = false;
unsigned long last_pps_millis;
/*
For this to work, an extension must be made to the Arduino Time library. This
method's intent is to designate the precise start of a second. It does this by
replacing the prevMillis value saved in the library with the current value of
millis(), but preserving any "owed" updates.
void syncSecond() {
unsigned long now_millis = millis();
while (((int)(now_millis - prevMillis)) > 500) { // 500 so we sync to the *nearest* second
// we're owed at least one update
now_millis -= 1000;
}
prevMillis = now_millis;
}
*/
void pps_interrupt() {
last_pps_millis = millis();
syncSecond();
}
void setup() {
gps_port.begin(GPS_BAUD);
pinMode(PPS_PIN, INPUT);
attachInterrupt(PPS_INT, pps_interrupt, RISING);
display.setMCPType(LTI_TYPE_MCP23017);
display.begin(16, 2);
setSyncProvider(gpsTimeSync);
display.setBacklight(WHITE);
display.print("GPS clock");
delay(2000);
display.clear();
}
TimeChangeRule summer = { "PDT", Second, Sun, Mar, 2, -7*60 };
TimeChangeRule winter = { "PST", First, Sun, Nov, 2, -8*60 };
Timezone zone(winter, summer);
time_t gpsTimeSync() {
unsigned long fix_age = 0;
gps.get_datetime(NULL, NULL, &fix_age);
if (fix_age < 2000) {
unsigned int tenths = ((millis() - last_pps_millis) / 100) % 10;
tmElements_t tm;
int year;
gps.crack_datetime(&year, &tm.Month, &tm.Day, &tm.Hour, &tm.Minute, &tm.Second, NULL, NULL);
tm.Year = year - 1970;
time_t out = makeTime(tm);
if (tenths >= 5) out++; // round to the nearest second given our PPS discipline
return out;
}
return 0;
}
void updateDisplay(time_t Now, unsigned int tenths) {
tmElements_t tm;
char buf[16];
breakTime(Now, tm);
display.setCursor(0, 0);
sprintf(buf, " %02d:%02d:%02d.%1d %s ", hourFormat12(Now), tm.Minute, tm.Second, tenths, isPM(Now)?"PM":"AM");
display.print(buf);
display.setCursor(0, 1);
sprintf(buf, " %2d-%s-%04d ", tm.Day, monthShortStr(tm.Month), tmYearToCalendar(tm.Year));
display.print(buf);
}
void loop() {
while(gps_port.available()) {
gps.encode(gps_port.read());
}
time_t Now = zone.toLocal(now());
if (timeStatus() != timeNotSet && timeStatus() != timeNeedsSync) {
unsigned int tenths = ((millis() - last_pps_millis) / 100) % 10;
if (Now != prevTime || prevTenths != tenths) {
prevTime = Now;
prevTenths = tenths;
complained = false;
display.setBacklight(GREEN);
updateDisplay(Now, tenths);
}
} else {
if (!complained) {
complained = true;
display.setBacklight(RED);
display.clear();
display.print("Waiting for sync");
}
}
}
Sunday, May 4, 2014
Hydra II EVSE variant now available
If you've ever wanted to use a Hydra at home, but wanted to wire it directly to a dedicated circuit or plug it into a dedicated 240 volt outlet instead of connecting it to a host EVSE, then your day has come!
The Hydra II EVSE variant boards have now arrived in the store! This variant trades the inlet handling and outlet proximity signal for a GFI and a real-time clock chip. With it, you can build your own double-head EVSE capable of connecting to two cars simultaneously and either charging both with half the current allowance of your circuit or sequencing the two vehicles automatically.
Not only that, but the real-time clock chip allows you to set up to 4 events, each with a time-of-day and a day-of-week mask - enough to set up two independent time-of-use charge schedules - perfect for weekday and weekend scheduling (if you want more, you can simply change a constant in the firmware and re-upload). There's even timezone support so that the clock will automatically correct for daylight savings time.
As with the original Hydra II, if you order the assembled and tested board, then you can complete your Hydra without doing any soldering at all (you can buy a pre-wired button from the OpenEVSE store - just tell Chris you need long wires), and it takes about a half a day of basic mechanical assembly.
The Hydra II EVSE variant boards have now arrived in the store! This variant trades the inlet handling and outlet proximity signal for a GFI and a real-time clock chip. With it, you can build your own double-head EVSE capable of connecting to two cars simultaneously and either charging both with half the current allowance of your circuit or sequencing the two vehicles automatically.
Not only that, but the real-time clock chip allows you to set up to 4 events, each with a time-of-day and a day-of-week mask - enough to set up two independent time-of-use charge schedules - perfect for weekday and weekend scheduling (if you want more, you can simply change a constant in the firmware and re-upload). There's even timezone support so that the clock will automatically correct for daylight savings time.
As with the original Hydra II, if you order the assembled and tested board, then you can complete your Hydra without doing any soldering at all (you can buy a pre-wired button from the OpenEVSE store - just tell Chris you need long wires), and it takes about a half a day of basic mechanical assembly.
Subscribe to:
Posts (Atom)