output from TrainTimer program by Hippy

richtell

New Member
I'd like advice on .reading output from the circuit below from a thread on timing rocket cars. The code was written by "HippY"
I am measuring the initial velocity of a potato fired from a spud gun.
This is my first use of a Picaxe. I have built this circuit using two IR LEDs/phototransistor pairs, 25 cm apart anticipating an initial velocity of 25-50 m/sec.
I have built the circuit and downloaded the file. The signal is fed thru a 4011 quad NAND gate. With a scope I have confirmed visually that CounterIn, C.0, only pulses between the start and stop signals, passing my hands at varying speeds thru the sensors. So, the input and output work, but where do I read the output? The output should be a count of a train of pulses, correct? I then multiply the number displayed by the duration of each pulse ( currently .1oo usec) to get durution in useconds>
Once I get this to work I will use the Pwmout wizard to try and use 100kHz or even 1MHz.

The trouble is, where does the output go? I should see "ElaspedTime= XXX us. where?
I'm perplexed. When I run Simulate the program just cycles in the WaitForTimerStarted loop, despite the fact I can see a pulse train stop and start on the scope monitoring C.0.
After I download the program, which I have done many times, a curious screen shows up with Serial Terminal N 9600 8,N,1 in the Title bar, and spaces for input and output buffers below. I don't know what to do here, and have been just closing the dialogue box. Is this causing a problem?
Thanks


#Picaxe 28X2
#Terminal 9600
#No_Table
#No_Data

' ___ ___
' 1ST >----| \ ___ ___
' ___| & >O---.-------| \ .---| \
' | |___/ | | & >O---| | & >O---> Counter In
' |_____ _____| .---|___/ `---|___/ C.0
' \ / |
' X |
' _____/ \_____ `---------------------------< PWM Output
' | ___ | C.1
' |___| \ |
' ___ | & >O---'
' 2ND >----|___/


Symbol CounterIn = C.0
Symbol PwmOutput = C.1

Symbol T1CON_SFR = $CD
Symbol TMR1L_SFR = $CE
Symbol TMR1H_SFR = $CF

Symbol elapsedTime = w0
Symbol elapsedTime.lsb = b0
Symbol elapsedTime.msb = b1

Symbol lastElapsedTime = w1

SetFreq M8

Do
Gosub ConfigurePwmOutput
Gosub ConfigureAndResetTimer
Gosub WaitForTimerStarted
Gosub WaitForTimerStopped
Gosub CalculateAndDisplaySpeed
Loop

ConfigurePwmOutput:
PwmOut PwmOutput, 199, 400 ' 10kHz @ 8MHz, 50% duty
Return

ConfigureAndResetTimer:
PokeSfr T1CON_SFR, %00000111
PokeSfr TMR1L_SFR, 0
PokeSfr TMR1H_SFR, 0
Return

WaitForTimerStarted:
Do
PeekSfr TMR1L_SFR, elapsedTime.lsb
PeekSfr TMR1H_SFR, elapsedTime.msb
Loop Until elapsedTime <> 0
Return

WaitForTimerStopped:
Do
lastElapsedTime = elapsedTime
PeekSfr TMR1L_SFR, elapsedTime.lsb
PeekSfr TMR1H_SFR, elapsedTime.msb
Loop Until elapsedTime = lastElapsedTime
Return

CalculateAndDisplaySpeed:
SerTxd( "Elapsed Time = ", #elapsedTime, "00 us", CR, LF )
Return
 

hippy

Ex-Staff (retired)
The output should be appearing on the Terminal screen which pops-up after you download the program. With the screen shown, triggering the timing should then show the result on the screen.
 

richtell

New Member
output from TrainTimer

Thank You- I was closing this dialogue box before I knew what it was for.
I changed the PWMOUT settings to 9,20 to generate a 100KHZ signal, as I need to measure 2-8 msec with at least 1% resolution. This is working

I would like to use the AXE033 LCD so I don't have to carry my computer out to the field where we are firing potatos. I used these commands:
CalculateAndDisplaySpeed:
SerTxd( "Elapsed Time = ", #elapsedTime, "0 us", CR, LF )
serout 7, N4800, (254,128)
serout 7, N4800, (#elapsedTime, "0usec")
Return

The LCD, top line, flashes for a very brief period, < 1 sec, and goes blank. Somehow it is not holding the data, or the device is bad ( i have to admit I dropped it twice onto a concrete floor, but it powers up OK with CLK jumper installed, per directions), or the commands are wrong.
Am I mis-interpreting what variable #elapsedTime holds? How do I get the LCD display to stay on?
Thanks
 
Top