I have posted this on the VSM forum but I hope I may get some help here.
I am trying to construct and simulate a Motorcycle Gear Position indicator.
It was a project with gear pedal input using Hall effect trs and magnets but I find that too unreliable and want to build a project using RPM and Road speed both of which are available to me.
I am able to read revs and I am able to read speed
I have a chart of revs vs road speed in each gear
If I input my Bike "Triumph Sprint GT" into this spreadsheet in the link below I get a neat chart of expected readings that the Pic should process
http://www.gearingcommander.com/
What I don't get now that I have VSM how I can simulate a frequency reading (a pulse or spike?) and how to handle that in my code.
The original cct with pedal inputs
The code for that
As you can see I am a bit stuck now!
Should I be posting this in another forum or am I in the right place?
I am trying to construct and simulate a Motorcycle Gear Position indicator.
It was a project with gear pedal input using Hall effect trs and magnets but I find that too unreliable and want to build a project using RPM and Road speed both of which are available to me.
I am able to read revs and I am able to read speed
I have a chart of revs vs road speed in each gear
If I input my Bike "Triumph Sprint GT" into this spreadsheet in the link below I get a neat chart of expected readings that the Pic should process
http://www.gearingcommander.com/
What I don't get now that I have VSM how I can simulate a frequency reading (a pulse or spike?) and how to handle that in my code.
The original cct with pedal inputs
The code for that
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
'assign variables b1 (byte1 =8 bits) to b4
'pins = $BA 'show NEUTRAL N later when switch by neutral light later
symbol gearposn = b1:symbol geardisplay = b2
symbol leverdown = b3:symbol leverup = b4: symbol neutral = b5
'----------------------------------------------------------------------------
gearposn = 2 : gosub showgear 'start in gearposn 0 gear neutral? = $BA = N
'---------------=================00000000 MAIN 0000000==================------------------------
Start:
'debug
readadc 0,leverup
if leverup > 150 then upshift 'if low to high volts they pushed the up switch or lever
readadc 1,leverdown
if leverdown < 150 then downshift 'if high to low volts they pushed the down switch or lever
goto Start
end '----------------------------------------------------------------------------------------------
' SUBS
'---------------=================0000000000 UP COUNTER 000000000000==================--------------
upshift:
gearposn = gearposn + 1 max 6 ' move up a gear unless at 6
'if gearposn > 6 then
' gearposn = 6
'endif
gosub showgear
wait_up_lever: 'in case they are resting on the switch or lever
readadc 0,leverup: pause 20
if leverup > 150 then wait_up_lever
goto start
'---------------=================00000000000 DOWN COUNTER 00000000000==================-------------
downshift:
gearposn = gearposn Min 2 - 1' move down a gear unless at 1
'if gearposn < 1 then
' gearposn = 1
'endif
gosub showgear
wait_down_lever: 'in case they are resting on the switch or lever'
readadc 1,leverdown: pause 20
if leverdown < 150 then wait_down_lever
goto start
'---------------=================00000000000 SHOW GEAR 00000000000==================-------------
showgear:
'___________________ display the gear selected!_________________________________________ ___
' gearposn 0 1 2 3 4 5 6
'showgear: '0 1 2 3 4 5 6
lookup gearposn, ($BA, $82, $DC, $D6, $E2, $76, $7E), geardisplay
pins = geardisplay
return
New project using rpm / road speed -- So far
[ATTACH=CONFIG]16971.vB[/ATTACH]
The code so far
Start:
main:
count 1, 1000, w1
'pulsin 1,1,w1
If w1 < 150 then gosub show
goto main
end
show:
pins = $82
'wait 5 'seconds
'debug
'w1 = 252
end
return
Should I be posting this in another forum or am I in the right place?
Last edited by a moderator: