Ice Tube Clock shows garbage ... see here

For RTC breakouts, etc., use the Other Products from Adafruit forum

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
pstemari
 
Posts: 310
Joined: Sun Mar 21, 2010 6:10 pm

Re: Ice Tube Clock shows garbage ... see here

Post by pstemari »

stinkbutt wrote:

Code: Select all

  if (brightness <= 30) {
    OCR0A = 30; 
  } else if (brightness <= 35) {
    OCR0A = 35;
  } else if (brightness <= 40) {
    OCR0A = 40;
  } else if (brightness <= 45) {
    OCR0A = 45;
...or we're all independently determining that codeblock makes the Baby Jesus cry. But I digress...."
Baby Jesus is crying and Ada Babbage is rolling in her grave, no doubt.

That said, and not knowing AVR assembler, is it possible that code is smaller/faster than

Code: Select all

if (brightness <= BRIGHTNESS_MIN) {
  OCR0A = BRIGHTNESS_MIN;
} else if (brightness >= BRIGHTNESS_MAX) {
  OCR0A = BRIGHTNESS_MAX;
} else {
  brightness = BRIGHTNESS_INCREMENT
    * ((brightness + BRIGHTNESS_INCREMENT - 1)
         / BRIGHTNESS_INCREMENT);
}
I can certainly imagine a series of branch compares being faster than multiple/divide operations.

User avatar
stinkbutt
 
Posts: 593
Joined: Wed Feb 17, 2010 2:40 am

Re: Ice Tube Clock shows garbage ... see here

Post by stinkbutt »

Faster? Possibly. That's a quality, however, that counts for very little in a clock. So long as the operation doesn't get in the way of the interrupts there's no value to being faster.

However, it's definitely a larger binary to be uploaded to the clock. And removing it is one of the ways people are making room for all the firmware modifications they're making.

Stock firmware:

Code: Select all

C:\Users\XXX\Desktop\firmware09-30-09>avr-size iv.hex
   text    data     bss     dec     hex filename
      0    9108       0    9108    2394 iv.hex
Firmware with only the change being the simplification of the PWM code:

Code: Select all

C:\Users\XXX\Desktop\firmware09-30-09>avr-size iv.hex
   text    data     bss     dec     hex filename
      0    8812       0    8812    226c iv.hex
Better than a kick in the crotch, at least.

As for the code you posted, I'm not precisely sure what

Code: Select all

  brightness = BRIGHTNESS_INCREMENT
    * ((brightness + BRIGHTNESS_INCREMENT - 1)
         / BRIGHTNESS_INCREMENT);
actually does. It looks like this code increments brightness by ( BRIGHTNESS INCREMENT -1 ). And does so in a very roundabout fashion.

pstemari
 
Posts: 310
Joined: Sun Mar 21, 2010 6:10 pm

Re: Ice Tube Clock shows garbage ... see here

Post by pstemari »

The file size pretty much confirms the chip has hw multiply/divide, which what I wasn't sure about.

That if block is rounding brightness up to the next multiple of brightness_incr. With int math, the general technique for rounding a number x up to the next multiple of another number i is to take i * ((x+i-1) / i). The division truncates, so by adding i-1 to the top, you force it to round up instead of down.

mtbf0
 
Posts: 1645
Joined: Sat Nov 10, 2007 12:59 am

Re: Ice Tube Clock shows garbage ... see here

Post by mtbf0 »

pstemari wrote:The file size pretty much confirms the chip has hw multiply/divide, which what I wasn't sure about.
the chip has an 8 bit multiplier with a sixteen bit result, but no divide.

datasheet.

the multiply and divide routines are probably called elsewhere.

AnnaOnWeb
 
Posts: 24
Joined: Sat Apr 25, 2009 4:12 pm

Re: Ice Tube Clock shows garbage ... see here

Post by AnnaOnWeb »

Ice Tube clock "D" is running very well now - see here: http://www.AnnaOnWeb.com - unmodified, just soldered.

But: I had to leave out C5 - the 100nF 100V capacitor - which was missing on the kit (I got 1 more of the other 104 caps) and I would not like to annoy Lady Ada for a 30 ct missing part again.. she helped me out so many times already - thanks a lot!
She mentioned that this part is only for stabilizing - so I tried to operate the clock without it.

My question is: Can I leave out C5 for ever? I do not like to annoy someone or have to drive into THEEE CITY - which is not NY but HH ;-) ... the THEEE-2nd :-) And I am running out of cotton gloves ...

Something else:
Many thanks to all the people - esp. stinkbutt - who provided very helpful hints for dimming - but why do you do not open a new thread about dimming? I haven´t found these very important information on the forum before.

I would not like to close this thread completely before I haven´t presented the solution for "C" - the clock I totally gave up onto (schräges Englisch - or not?). But I still have here 1 soldered well working tube on pcb and another tube and small pcb as spare parts. Lady Ada sent me today her pcb and Mouser should help too- available in Germany also. But 20 EUR shipping costs and 19% Tax on all (including shipping costs).

Thanks for your interest and help in this case
and with my best regards,

AnnaOnWeb

Locked
Please be positive and constructive with your questions and comments.

Return to “Clock Kits (discontinued)”