I have been trying for some time to perfect a motorcycle gear shift indicator
I am driving a 7 segment led with a Pixaxe 28x on a proto board.
Photo:
Program:
All works ok and I am about to program in the neutral light switch to indicate"0" on the display.
But before that I have a problem with the counter cct or program.
If you look on the accompanying picture you will see I am using two micro switches with component debounce buffered attached. One switch transitions High to low and the other Low to High as can be seen from the programming. Later I intend to replace theses switches with Hall Effect transistors and have both switch low to high.
Problem is:
Counter starts at DP (Dot Point) and counts and displays correctly to the extent of 7 or 1 in either direction without fail.
If I hold one of the switches down the counter waits until I release it before restarting the count as it should.
BUT
1. If i change direction of the counter it takes two -2 presses of the switch to reverse the direction of the count - in either direction.
2. It also take two presses to get off the bottom ie 1 or off the top ie 7.
All other counting and displaying takes the correct one switch action in either direction.
Any Ideas?
Duke
I am driving a 7 segment led with a Pixaxe 28x on a proto board.
Photo:
Program:
Code:
'2013 fifth version of m/c gear shift indicator
'Set Editor Program to Options Picaxe 28x
'Leverup is switch going low to high on Pin Analog 0 Pin 2 of chip
'Leverdown is switch high going low on Pin Analog 1 pin 2 of chip use striped wire
'work to do !!!!!!!!!!!!!!!!!!!!! 'need to take neutral out of loop out and have it switch by Analog 3 from neutral light or 'neutral switch
symbol gearposn = b1:symbol geardisplay = b2:symbol leverdown = b3:symbol leverup = b4 'assign variables b1 (byte1 =8 bits) to b4
'----------------------------------------------------------------------------
gearposn = 1 'start in gearposn 0 gear neutral?
pins = $01 'show no gear as a default display DotPoint
'---------------=================0000000000000000000000==================------------------------
Start:
' could be both set to read high or low volts
readadc 0,leverup: if leverup > 150 then upshift 'if low to high volts they pushed the down switch or lever
readadc 1,leverdown: if leverdown < 150 then downshift 'if high to low volts they pushed the up switch or lever
'debug
goto Start
end
'---------------=================0000000000000000000000==================------------------------
upshift: 'UP COUNTER
if gearposn = 7 then Start
gearposn = gearposn + 1 ' move up a gear NOTE starts at 2 above 1st or neutral
'____________________ display the gear selected!____________________________________________
' gearposn 0 1 2 3 4 5 6 7 DATA counts from 0 up
'showgear: '0 1 2 3 4 5 6 7
lookup gearposn, ( $BE, $82, $DC, $D6, $E2, $76, $7E, $92), geardisplay: pins = geardisplay
wait_up_lever: 'in case they are resting on the switch or lever
readadc 0,leverup: pause 2
if leverup > 150 then wait_up_lever
goto start
'---------------=================0000000000000000000000==================------------------------
downshift: 'DOWN COUNTER
if gearposn < 1 then Start
gearposn = gearposn - 1 ' move down a gear
'____________________ display the gear selected!____________________________________________
' gearposn 0 1 2 3 4 5 6 7 8
'showgear: '1 2 3 4 5 6 7
lookup gearposn, ($82, $DC, $D6, $E2, $76, $7E, $92), geardisplay: pins = geardisplay
wait_down_lever: 'in case they are resting on the switch or lever'
readadc 1,leverdown: pause 2
if leverdown < 150 then wait_down_lever
goto start
'-------------------------------------------------------------------------------------------------
All works ok and I am about to program in the neutral light switch to indicate"0" on the display.
But before that I have a problem with the counter cct or program.
If you look on the accompanying picture you will see I am using two micro switches with component debounce buffered attached. One switch transitions High to low and the other Low to High as can be seen from the programming. Later I intend to replace theses switches with Hall Effect transistors and have both switch low to high.
Problem is:
Counter starts at DP (Dot Point) and counts and displays correctly to the extent of 7 or 1 in either direction without fail.
If I hold one of the switches down the counter waits until I release it before restarting the count as it should.
BUT
1. If i change direction of the counter it takes two -2 presses of the switch to reverse the direction of the count - in either direction.
2. It also take two presses to get off the bottom ie 1 or off the top ie 7.
All other counting and displaying takes the correct one switch action in either direction.
Any Ideas?
Duke