Button problem

SpokePOV kit for bikes

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
tcharron
 
Posts: 59
Joined: Tue Oct 13, 2009 7:15 pm

Button problem

Post by tcharron »

I just made three blue spokepov units.
2 of the 3 work as expected. The third one doesn't respond well to the button push to turn it off.

When the batteries are inserted, the lights sequentially light. Pressing the button during this does nothing (this is the same as my other two units).

While 'idle', pressing the button for a short or long amount of time has no effect. On my other two units, holding the button for a second or so and then releasing causes the device to turn off.

When the lights are running (due to passing a magnet over the hall sensor), pressing the button 'freezes' them until the button is released. This is the same as my other units.

If I leave the device for 3 minutes, it shuts itself off fine.

I tried swapping the atmega chip with a working unit. The problem follows the chip. Is it possible that one of the timers or something internal to the chip is causing the problem? I have flashed the latest firmware to no avail.

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: Button problem

Post by adafruit »

did it work before you reflashed the firmware?

User avatar
tcharron
 
Posts: 59
Joined: Tue Oct 13, 2009 7:15 pm

Re: Button problem

Post by tcharron »

I don't know. I did about 4 seconds of testing before I reflashed it (with the version on the support page at adafruit).
I'll spend some time comparing my three units and see if I can debug the problem. It does seem like a chip or firmware problem to me, and given that the chips usually don't fail I'm thinking it's more likely firmware.

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: Button problem

Post by adafruit »

4 seconds isnt a lot of testing ;)
if youre sure its the chip you can email support@adafruit and ask for a new chip with link to this post

User avatar
tcharron
 
Posts: 59
Joined: Tue Oct 13, 2009 7:15 pm

Re: Button problem

Post by tcharron »

I isolated the problem and it isn't a hardware problem.

In SIGNAL(SIG_INT0), I added a set_led(timer%32,FRONT) in the first while statement. It seems that this loop is running very slowly (which can only be caused by the delay_ms routine). By changing BUTTON_DEBOUNCE to 2 and the 500 in this routine to 15, I got the desired results. The 'progressing' lights while the button is held down help too.

I think that the pre-installed firmware is slightly different than the one I generated from the published source code. I didn't try to decode the delay_ms routine. I'm using WINAVR 20090313 - not sure if that makes a difference.

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: Button problem

Post by adafruit »

wow thanks! :)

User avatar
tcharron
 
Posts: 59
Joined: Tue Oct 13, 2009 7:15 pm

Re: Button problem

Post by tcharron »

Further update...

Replacing delay_ms with the following fixed the issue entirely (without requiring changes to the other timing parameters):

Code: Select all

void delay_ms(unsigned char ms) {
  while ( ms-- ) _delay_ms(1);
}
I imagine that this also has the benefit of a smaller binary image too.

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

Return to “SpokePOV (discontinued)”