Which stamp to use as pulse generator / emulator?
I am considering using a basic stamp to emulate/generate a automotive crankshaft position sensor signal to allow test-benching and development work of a car ECM, but am unsure which stamp would be most appropriate.
The signal to be generated emulates a magnetic sensor that reads a wheel with 7 notches; 6 evenly spaced and 1 extra notch (sync) which allows the ECM to determine crankshaft position.
Max output would be ~42khz.
Initial plan was to count pulses from external source, turn on/off stamp output pin appropriately.
TIA
The signal to be generated emulates a magnetic sensor that reads a wheel with 7 notches; 6 evenly spaced and 1 extra notch (sync) which allows the ECM to determine crankshaft position.
Max output would be ~42khz.
Initial plan was to count pulses from external source, turn on/off stamp output pin appropriately.
TIA

Comments
The fastest Stamp (BS2px) is not fast enough to handle this. It executes about 20K instructions (not statements necessarily) per second.
A Propeller or an SX would be more than adequate for the task. The Propeller has the advantage of being able to directly handle a PS/2 keyboard and can provide either VGA or NTSC video for a display. It uses a crystal timebase and would not need an external timing source. Have a look at the Propeller Protoboard with the Accessory Kit.
Thanks for the recommendation on the SX or Propeller - will check them out.
'' This object emulates/generates a automotive crankshaft position '' sensor signal to allow test-benching and development work of a car '' ECM. The signal to be generated emulates a magnetic sensor that '' reads a wheel with 7 notches; 6 evenly spaced and 1 extra notch '' (sync) which allows the ECM to determine crankshaft position. '' To start the emulator (if the object is called OBJ): '' OBJ.start( pin, cyclesPerSec, pulseWidthUS, pulsesPerCycle) '' This returns a non-zero value if successful, zero on failure '' if unable to start a new cog or the timing values are zero. '' pin : The I/O pin number to be used for the output '' cyclesPerSec : The number of "revolutions" per second '' pulseWidthUS : The output pulse width in microseconds '' pulsesPerCycle : The number of "spokes" on the timing wheel '' Note that this does not include the sync pulse '' which is produced once per cycle midway between '' the first two "spokes" of a cycle. '' To stop the emulator and free the cog used: '' OBJ.stop '' This can be called even if the emulator has never been started. VAR long cog ' Holds cog number + 1 PUB start(pin, cyclesPerSec, pulseWidthUS, pulsesPerCycle) | usTicks stop ' Stop cog if already started if cyclesPerSec == 0 or pulseWidthUS == 0 or pulsesPerCycle == 0 return 0 usTicks := clkfreq / 1_000_000 ' Clock ticks per microsecond pinMask := |< pin ' I/O pin bitmask between := clkfreq / cyclesPerSec ' Clock ticks per cycle width := usTicks * pulseWidthUS ' Clock ticks per output pulse between := between / 2 - width ' 1/2 cycle less pulse width pulses := pulsesPerCycle ' Number of pulses per cycle cog := cognew(@entry,@cyclesPerSec) + 1 waitcnt(clkfreq/1000 + cnt) ' Wait for cog to start return cog ' and grab its parameters PUB stop if cog ' If cog was started, cogstop(cog~ - 1) ' stop it DAT org 0 entry andn outa,pinMask ' Set up output pin to output low or dira,pinMask mov time,between ' Initialize timer to some time add time,cnt ' a little bit in the future cycle mov count,pulses ' Overall loop pulse waitcnt time,width ' Start of pulse or outa,pinMask waitcnt time,between ' End of pulse andn outa,pinMask cmp count,pulses wz ' See if first cycle waitcnt time,width if_eq or outa,pinMask ' Do sync pulse on first cycle waitcnt time,between if_eq andn outa,pinMask djnz count,#pulse jmp #cycle pinMask long 0 ' I/O pin mask between long 0 ' Clock ticks between pulses ' in the case of a sync pulse width long 0 ' Width of pulse in clock ticks pulses long 0 ' Number of pulses per cycle count long 0 ' Counter for pulse number time long 0 ' Next system time to wait forIt has a single output.
Using a BS2, I sent the output to PIN0 and if HIGH set PIN1 to high to blink the led.
I'm am trying to get a pulse to use with a clock project, but i can't get the pulses to be consistant or the timing to be slow enough.
Any suggestions... I'll apologize now for the poor schematic.
Here is the BS2 app code.
' {$STAMP BS2}
' {$PBASIC 2.5}
Blink PIN 1
Pulse PIN 0
TSeconds VAR Nib 'tenths of a second.
Seconds VAR Byte 'seconds count
Minutes VAR Byte
TSeconds = 0
Seconds = 0
Minutes = 0
DO WHILE Minutes < 1
IF (Pulse=0) THEN
LOW Blink
ELSE
HIGH Blink
IF(TSeconds<9)THEN
TSeconds = TSeconds + 1
ELSE
GOSUB ADDSecond
TSeconds = 0
ENDIF
'GOSUB DisplayTime
ENDIF
LOOP
END
ADDSecond:
IF(Seconds < 59) THEN
Seconds = Seconds + 1
ELSE
Seconds = 0
GOSUB ADDMinute
'GOSUB DisplayTime
ENDIF
RETURN
ADDMinute:
Minutes=Minutes + 1
GOSUB DisplayTime
RETURN
DisplayTime:
DEBUG "Time is: ", DEC Minutes, ":", DEC Seconds, ":", DEC TSeconds, CR
RETURN
If you want an accurate clock, you will need to use a 32768Hz crystal oscillator and a divider to get 1Hz pulses. Here's one example. You can leave out the CD4027 if you're willing to use a 2Hz clock pulse.