buzzlightyear
Member
I'm trying to come up with a pulsetrain device, using the 08m2, details in the comments in the code, but if anything is unclear let me know!
The pulses are only output once the input detects a rising edge, the input pulse is of unknown and changeable duration, and if a new input is detected the output pulse sequence is to restart.
The spaces between the output pulses will be in the milliseconds range (lets say 5-100ms variable, for now) the individual pulse length will be around 5ms, I want to be able to specify (by way of 3 pots) the number of pulses output, the rate of the pulses for example every 10ms, and the spread which will allow the rate to be non linear, for example 1-1--1---1----1-----1 or 1-----1----1---1--1 etc
Not quite sure how to implement all this, so any help is welcomed, thanks
Code:
symbol Trig = pinC.3
symbol PulseRate = b0 'Pot connected to pin 1
symbol PulseAmount = b1 'Pot connected to pin 2
symbol Spread = b2 'Pot connected to pin 4
main:
readadc 1, PulseRate 'this is the rate of the pulses
readadc 2, PulseAmount 'this is the number of pulses from 2 to 8
readadc 4, Spread 'this is the addition of delay between each individual pulse
if Trig = 1 then 'on rising edge of input pulse in C.3, C.0 to output pulses according to the pot settings
'if while a pulse sequence is active a new input pulse arrives then restart the pulse sequence,
'if no input pulse then set C.0 to low, loop around main.
goto main
The spaces between the output pulses will be in the milliseconds range (lets say 5-100ms variable, for now) the individual pulse length will be around 5ms, I want to be able to specify (by way of 3 pots) the number of pulses output, the rate of the pulses for example every 10ms, and the spread which will allow the rate to be non linear, for example 1-1--1---1----1-----1 or 1-----1----1---1--1 etc
Not quite sure how to implement all this, so any help is welcomed, thanks