Hello all,
I am 60 years old and doing my first picaxe projects.
I do have some basic electronics knowledge, some (probably outdated BASIC experience..) and the drive to learn "new" stuff.
This project is a Rallye Meter - with several electromechanical counters (10m).
I am using a 20m2 - enough reserves ..
The signal source is a industry std. proximity switch (Hall Sensor NPN, NO).
The maximum expected frequency should be about 150 HZ.
I have tried 2 ways to count the incoming pulses
- setint %00000010,%00000010
- if pinc.1=1 then ....
Both approaches do work.
The correct calibration (for this one set of tires) is 2535 pulses per km.
The electromechanical counters are fired by:
-pulsout B.6,2000 - a Darlington does the switching - works fine
I have an OLED display that should display:
- signal source - works ok.
- driven meters in 10 m increments - works ok.
- an speed output (averaged over the last 3 seconds) - does not...
My problems:
- I am firing the darlington when the count reaches 253 (and and not 253,5 - introducing some error here)
- how do I calculate a speed over the last few seconds (no decimals)
- I need to make the calibration adjustable - via switches, thumbwheels and such (like +-30)
Here is the code:
The formulas I have modified back and forth to get "any" output ..
Any help would be greatly appreciated!
oh yes, I did search this forum - and that is what got me as far as i am now - most of the code are snippets stolen from different projects...
Future developments would include
- average speed since last start
- Input a target average speed
- show deviation of that target average speed.
- many more...
Greetings
Mike
I am 60 years old and doing my first picaxe projects.
I do have some basic electronics knowledge, some (probably outdated BASIC experience..) and the drive to learn "new" stuff.
This project is a Rallye Meter - with several electromechanical counters (10m).
I am using a 20m2 - enough reserves ..
The signal source is a industry std. proximity switch (Hall Sensor NPN, NO).
The maximum expected frequency should be about 150 HZ.
I have tried 2 ways to count the incoming pulses
- setint %00000010,%00000010
- if pinc.1=1 then ....
Both approaches do work.
The correct calibration (for this one set of tires) is 2535 pulses per km.
The electromechanical counters are fired by:
-pulsout B.6,2000 - a Darlington does the switching - works fine
I have an OLED display that should display:
- signal source - works ok.
- driven meters in 10 m increments - works ok.
- an speed output (averaged over the last 3 seconds) - does not...
My problems:
- I am firing the darlington when the count reaches 253 (and and not 253,5 - introducing some error here)
- how do I calculate a speed over the last few seconds (no decimals)
- I need to make the calibration adjustable - via switches, thumbwheels and such (like +-30)
Here is the code:
Code:
; Rallye Tripmeter
; triggers electromechanical 10m counter
; displays Pulses, Time, Meters and inst. Speed on OLED
; Speed not working yet
;
; Initialise variables
symbol counter=w0
symbol speed=w1
symbol distance=w2
symbol meter=w3
symbol calibration=w4
symbol counter2=w5
symbol kph=w6
counter2=0
calibration=3 ;Impulses/km/10 set low for Bench testing actual 2520-2540
distance=0
meter=0
pause 3000 ;OLED init
Serout B.7,N2400,(254,1) ;OLED clear
;TIME=0
counter=0
pause 30
debug
setint %00000010,%00000010 ; C.1 on high
main:
Serout B.7,N2400,(254,128) ; OLED Move to Z1 S1
Serout B.7,N2400,("Imp ",#counter," ",#TIME)
if counter>=calibration then ; Calibration number Impulse/km/10
pulsout B.6,2000 ;10m Puls an B7
meter=meter+10 ;
counter2=counter
counter=counter-calibration
Serout B.7,N2400,(254,138); OLED Move to Z1 Sxx
serout B.7,N2400,(#meter,"m") ;
endif
pause 2000 ; Wait 2 Sec for the inst Speed calc
distance=counter2/calibration*100 ; distance=counter2/calibration*circumference
speed=distance/Time ;m/s
kph=speed*36/100 ;km/H
Serout B.7,N2400,(254,192) ; OLED Move to Z2 S1
serout B.7,N2400,(" ");
Serout B.7,N2400,(254,192) ; OLED Move to Z2 S1
serout B.7,N2400,(#distance,"m ",#TIME,"sec ",#kph,"km/h") ;
TIME=0
counter2=0
distance=0
; endif
goto main
interrupt:
inc counter ; increase w0
intwait: if pinc.1=1 then intwait ; wait for int to clear
setint %00000010,%00000010 ; C.1 on high
return ; return from sub
Any help would be greatly appreciated!
oh yes, I did search this forum - and that is what got me as far as i am now - most of the code are snippets stolen from different projects...
Future developments would include
- average speed since last start
- Input a target average speed
- show deviation of that target average speed.
- many more...
Greetings
Mike