Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Ice Tube Clock shows garbage ... see here
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

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

by pstemari on Sat Jun 12, 2010 7:51 pm

stinkbutt wrote:
Code: Select all | TOGGLE FULL SIZE
  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 | TOGGLE FULL SIZE
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.
--Paul

A wholly owned subsidiary of:
Persephone: DL R+W+B C 7 X L W C++ I++ T+ A E H++ S+ V-- F+ Q P B PA+ PL
Aldebaran: DM Rt H 5 Y L- W+ C+ I++ T++ A+++ E H++ S+ V+ F++ Q+ P B++ PA- PL--
User avatar
pstemari
 
Posts: 310
Joined: Sun Mar 21, 2010 6:10 pm
Location: Seattle, WA

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

by stinkbutt on Sun Jun 13, 2010 12:13 am

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 | TOGGLE FULL SIZE
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 | TOGGLE FULL SIZE
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 | TOGGLE FULL SIZE
  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.
Red M&M, Blue M&M: They all wind up the same color

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

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

by pstemari on Sun Jun 13, 2010 10:37 pm

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.
--Paul

A wholly owned subsidiary of:
Persephone: DL R+W+B C 7 X L W C++ I++ T+ A E H++ S+ V-- F+ Q P B PA+ PL
Aldebaran: DM Rt H 5 Y L- W+ C+ I++ T++ A+++ E H++ S+ V+ F++ Q+ P B++ PA- PL--
User avatar
pstemari
 
Posts: 310
Joined: Sun Mar 21, 2010 6:10 pm
Location: Seattle, WA

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

by mtbf0 on Mon Jun 14, 2010 12:18 am

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.
"i want to lead a dissipate existence, play scratchy records and enjoy my decline" - iggy pop, i need more
User avatar
mtbf0
 
Posts: 1645
Joined: Sat Nov 10, 2007 12:59 am
Location: oakland ca

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

by AnnaOnWeb on Wed Jun 16, 2010 6:21 pm

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
AnnaOnWeb
 
Posts: 24
Joined: Sat Apr 25, 2009 4:12 pm
Location: Hamburg, Germany

Please be positive and constructive with your questions and comments.