Pulse Measurement Help
lardom
Posts: 1,659
I want to be able to measure 2.4ms, 1.2ms and 0.6ms. I looked at 'pos detector' and counter mode 24 26. They both look the same to me but I'm trying to figure out how to get it to return once the i/o pin goes low.
Will this work?
Will this work?
PUB test_counter_mode
frqa := 1
ctra := 0
dira[1]~
repeat
ctra := (%11010 << 26 ) | (1) ' accumulate while A = 1
waitpne(0 << 1, |< 1, 0)
waitpeq(0 << 1, |< 1, 0)
pulseWidth := phsa
phsa:=0

Comments
PUB test_counter_mode frqa := 1 ctra := 0 dira[1]~ ctra := (%11010 << 26 ) | (1) ' accumulate while A = 1 repeat waitpne(0 << 1, |< 1, 0) ' wait for pin to go low phsa = 0 ' Reset count waitpeq(0 << 1, |< 1, 0) ' wait for pin to go high waitpne(0 << 1, |< 1, 0) ' wait for pin to go low pulseWidth := phsa ' Get the countBean
pub main | pw setup ctra := (%01000 << 26) | PG_PIN ' POS DETECT mode frqa := 1 repeat waitpne(PG_MASK, PG_MASK, 0) ' wait for low phsa := 0 ' clear accumulator waitpeq(PG_MASK, PG_MASK, 0) ' wait for pulse waitpne(PG_MASK, PG_MASK, 0) pw := phsa / US_001 ' convert to microseconds term.dec(pw / 1000) ' display as x.xxx term.tx(".") term.rjdec(pw // 1000, 3, "0") term.tx(13))The attached program (tested on Propeller Activity Board) starts a pulse-generator in in a background cog so that the foreground code (above) can measure it. This is one of my favorite things about the Propeller: I can use a spare cog to simulate an input from a device that I don't have connected.@JonnyMac, thanks for the zip. I'll be testing both IR and ASK. Testing wireless communication with only a single Propeller will make life 'so' much easier!
Bean
@lardom Are you wanting to do this for SIRCS coms? If yes, I have an object that you're welcome to. I'm sitting in the Dallas office of a laser-tag client at the moment. The product using SIRCS type packets in the IR coms ("bullets" and command and information packets)
"@lardom Are you wanting to do this for SIRCS coms?"
Yes, kind of. I plan to tweak it a bit.
"If yes, I have an object that you're welcome to. I'm sitting in the Dallas office of a laser-tag client at the moment. The product using SIRCS type packets in the IR coms ("bullets" and command and info`rmation packets)"
Yes, I would appreciate it. I had success with the nRF24L01 transceivers even though my modules turned out to be clones. I would have posted the code but I didn't get the sense that there's much interest in the project that I built with it.
Now I want to see what I can do with 433Mhz modules.
I don't know why wireless transmitters that use data as opposed to multiple channels aren't more popular but I think there are definite advantages. I can imagine some pretty amazing things if the code is written in PASM!