Black Lives Matter - Action and Equality. ... Adafruit is open and shipping.
0

Ice Tube Clock Programming Tricks
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: Ice Tube Clock Programming Tricks

by jarchie on Wed Nov 13, 2013 11:48 pm

I apologize for not replying sooner to my own thread, but I'm still considering the possibilities that Russell 27 and PhilD13 suggested.

I have flashed the firmware on my xmas-icetube hardware revision dozens of times over the past two days, but with mixed results. Unfortunately, most things I tried worked, but nothing has worked consistently--not even my jumping R2 "solution"!

I discovered that my 2x3 pin cable seems to have an intermittent open circuit, so all the "testing" I've done over the past couple of days has been worthless.

All of this makes me wonder... was it just a bad cable that made me report the initial "problem" of this thread? My intuition says "no." The jumpering-R2 solution has worked with 100% effectiveness for the past 4 months, and it's hard for me to imagine that my cable started going bad 4 months ago and then worked perfectly for the next 4 months... but I am forced to admit that it is possible.

EDIT: I had intermittent problems for months before making the initial post in this thread. So my cable would have had to be "intermittent" for months, then work perfectly for months, then be "intermittent" again... That seems unlikely to me--especially since Adafruit does not guarantee the clock can be programmed in system (see the original post), so this seems to be a known problem.

So I'm still not sure what the problem is, but I thank Russell 27 and PhilD13 for suggesting possibilities. I will post to this thread if I can uncover the problem... even if that problem happens to be my own stupidity!
--John <www.jarchie.com/email>

jarchie
 
Posts: 595
Joined: Sun Jun 24, 2012 2:16 pm
Location: Santa Cruz, California, United States

Re: Ice Tube Clock Programming Tricks

by Russell 27 on Thu Nov 14, 2013 11:40 am

The USBTINY I use is LADYA's design but made by a different outfit, I believe it can supply more current.

USBTINY.png
USBTINY.png (241.19 KiB) Viewed 665 times
Russell 27
 
Posts: 240
Joined: Thu Sep 12, 2013 3:59 pm

Re: Ice Tube Clock Programming Tricks

by phild13 on Thu Nov 14, 2013 5:04 pm

I made a usbtinyisp that can be externally powered and can send up to about 250mA (size of fuse I used) to the device being programmed as well as programming the chips out of circuit via zif socket. I don't currently have a clock I wish to mess with, but should fairly soon.

The USB spec for 2.0 is 100mA per unit and the spec for usb 3.0 is 150mA with a maximum ( I think) of 5 units for 2.0 and 6 units for 3.0 giving 500mA and 900mA maximums. A usbtiy device (as well as all devices initially) is 1 unit unless there is an additional driver request after device initialization requesting additional units. The tiny programmers are made to work off of any usb bus and so I don't think there is any provision in the driver for a high power request which would mean that most usbtiny programmers would provide about the same current to a device.

However I think the idea is to find a way to enable the clock chip to reliably accept programming from any programming device while in the clock. People tend to break pins on the chips when removing/inserting them for programming as well as stab their finger with the chips pins when removing them. Don't ask how I know :)

John have you tried continuously reading from the chip (verifying) to see if you get any failures? With cygwin you can use something similar to the following:
Code: Select all | TOGGLE FULL SIZE
for ((n=0;n<2;n++));do avrdude -c usbtiny -p m328p -U flash:v:"C:\Data\xmas_firmware\icetube_flash.hex":a -U eeprom:v:"C:\Data\xmas_firmware\icetube_eeprom.hex":a; done
change the n<2 to a higher value (n<200) to run it more. You can figure an average of about 12.5 seconds per run to give you an idea of time it takes. This might help determine if there is a issue with the programming device.

phild13
 
Posts: 247
Joined: Mon Sep 10, 2012 1:05 pm

Re: Ice Tube Clock Programming Tricks

by Russell 27 on Fri Nov 15, 2013 5:17 pm

The standard ICE TUBE CLOCK circuit, with the tube removed for programming, shouldn't pull much more than 20 milli amps from the power supply.
Russell 27
 
Posts: 240
Joined: Thu Sep 12, 2013 3:59 pm

Re: Ice Tube Clock Programming Tricks

by jarchie on Sat Nov 16, 2013 3:24 pm

I think I might have discovered a clue. If I try to program an Adafruit clock with the tube in place (externally powered clock, no USBtinyISP power jumper, and no jumper across R2), system voltage stays constant, but the output of Q3 gradually falls to a lower voltage during programming. When the microcontroller is being programmed, all I/O pins change to inputs with pull-ups disabled. My suspicion is that the residual charge at the gate of Q3 keeps the transistor in the on state for a while, but as that charge is lost, the output falls. And as the output falls, so does the voltage of the programming signals. Before avrdude reports a programming failure, the signals from the USBtinyISP are probably below two volts. When I remove the MAX chip, programming works fine. So it seems like the MAX chip, when unpowered, is sourcing a significant amount of current from the CLK and DIN pins and dumping that current to it's VCC pin, where it flows through the tube filament to ground.

Assuming that jumpering R2 actually works as I initially claimed, my suspicion is that doing so fully removes the power to the MAX chip before programming begins. During programming, that may prevent the behavior of the MAX chip inputs from changing while the current supplied to the MAX VCC pin falls. But that's little more than a theory at this point. I'll do some more testing when I have time.

PhilD13 wrote:John have you tried continuously reading from the chip (verifying) to see if you get any failures? With cygwin you can use something similar to the following:
Code: Select all | TOGGLE FULL SIZE
for ((n=0;n<2;n++));do avrdude -c usbtiny -p m328p -U flash:v:"C:\Data\xmas_firmware\icetube_flash.hex":a -U eeprom:v:"C:\Data\xmas_firmware\icetube_eeprom.hex":a; done
change the n<2 to a higher value (n<200) to run it more. You can figure an average of about 12.5 seconds per run to give you an idea of time it takes. This might help determine if there is a issue with the programming device.

Update: Last night, I tried something similar to what you suggested. I ran the Perl script (code below) to repeatedly program an Adafruit Ice Tube Clock modified with both the GPS and extended battery hacks. As before, I used the AC adaptor, no USBtinyISP power jumper, no jumper across R2; but there was no display attached this time. There were no errors after 100 flashes and verifications. It seems like I was wrong: jumpering R2 seems unnecessary.

I can't be certain, as I observed the need to jumper R2 on a different clock, and the script below does not fully replicate real-world conditions. But at the moment, I'm leaning toward my being mistaken in the original post of this thread.

Code: Select all | TOGGLE FULL SIZE
#!/usr/bin/perl

use warnings;
use strict;

use constant TRIALS => 100;

my @write_test = qw/avrdude -B 4 -P usb -c usbtiny -p atmega328p -u -U lfuse:w:0x62:m -u -U hfuse:w:0xD1:m -u -U efuse:w:0x06:m -U flash:w:icetube_flash.hex:i -U eeprom:w:icetube_eeprom.hex:i -U lock:w:0x2B:m/;

my @read_test = qw/avrdude -B 4 -P usb -c usbtiny -p atmega328p -u -U lfuse:v:0x62:m -u -U hfuse:v:0xD1:m -u -U efuse:v:0x06:m -U flash:v:icetube_flash.hex:i -U eeprom:v:icetube_eeprom.hex:i -U lock:v:0x2B:m/;

for(my $i = 0; $i < TRIALS; ++$i) {
    print "TRY $i\n";

    if(!system @write_test) {
        print "WRITE SUCCESS\n";
    } else {
        print "WRITE FAILURE\n";
        exit;
    }

    sleep(5);

    if(!system @read_test) {
        print "READ SUCCESS\n";
    } else {
        print "READ FAILURE\n";
        exit;
    }

    sleep(5);
}
--John <www.jarchie.com/email>

jarchie
 
Posts: 595
Joined: Sun Jun 24, 2012 2:16 pm
Location: Santa Cruz, California, United States

Re: Ice Tube Clock Programming Tricks

by Russell 27 on Sat Nov 16, 2013 6:53 pm

Don't think of it as a mistake, I found all this very useful.
Russell 27
 
Posts: 240
Joined: Thu Sep 12, 2013 3:59 pm

Please be positive and constructive with your questions and comments.