How can I measure Duty-Cycle???
Beagle
Posts: 7
This is my first project with a Propeller.· I've out-grown the Basic Stamps, and am impressed with the power of the Propeller.· I am trying to interface a IST-506F temperature sensor to the Propeller.· The IST-506F uses a wierd one-wire communication scheme to speak to a micro-controller.
I need to decode the duty cycle of a Manchester code (not exactly Manchester code, but kinda like it) into 1's and 0's, then build the 1's and 0's up into 8-bit bytes.· The total word is 11-bits long.· The coding starts with a 50% duty cycle start bit (negative edge then positive edge transition)· next there are eight bits of either 25% or 75% duty cycles to represent 1's and 0's.·Finally a parity bit then 1-1/2 stop bits...
The 50% duty cycle start-bit begins with a negative transition· ¯¯¯¯¯¯¯¯|__|¯¯|· (the total negative and positive cycle is 125 µSec)
The Logic-1 is·represented by a 75% duty cycle begining with a negative transition |_|¯¯¯|· (again the total cycle is about 125 µSec, the·low part is about 30 µSec)
The Logic-0 is represented by a 25% duty cycle begining with a negative transition |___|¯|· (again the total cycle is about 125 µSec, the·low part is about 90 µSec)
Using the fastest Basic Stamp, I could measure the negative transitions using PULSIN.· It was almost working, but when there was a 0 followed by a 1, then the Basic Stamp would miss the transition, and melt several bits together.· I've spent the last couple days figuring out how to deal with serial communications with my LCD and radio MODEM.· I've got that stuff understood, but this Manchester-esque Code has me befuddled.
Any help would be appreciated,
Thank you,
Clint
I need to decode the duty cycle of a Manchester code (not exactly Manchester code, but kinda like it) into 1's and 0's, then build the 1's and 0's up into 8-bit bytes.· The total word is 11-bits long.· The coding starts with a 50% duty cycle start bit (negative edge then positive edge transition)· next there are eight bits of either 25% or 75% duty cycles to represent 1's and 0's.·Finally a parity bit then 1-1/2 stop bits...
The 50% duty cycle start-bit begins with a negative transition· ¯¯¯¯¯¯¯¯|__|¯¯|· (the total negative and positive cycle is 125 µSec)
The Logic-1 is·represented by a 75% duty cycle begining with a negative transition |_|¯¯¯|· (again the total cycle is about 125 µSec, the·low part is about 30 µSec)
The Logic-0 is represented by a 25% duty cycle begining with a negative transition |___|¯|· (again the total cycle is about 125 µSec, the·low part is about 90 µSec)
Using the fastest Basic Stamp, I could measure the negative transitions using PULSIN.· It was almost working, but when there was a 0 followed by a 1, then the Basic Stamp would miss the transition, and melt several bits together.· I've spent the last couple days figuring out how to deal with serial communications with my LCD and radio MODEM.· I've got that stuff understood, but this Manchester-esque Code has me befuddled.
Any help would be appreciated,
Thank you,
Clint
Comments
there are two commands "WaitPeq" and "WaitPne" that you could use
second idea: as you are coming from the basic stamp in the obex there is a object BS2 Functions
that mimics PBasicfunctions.
In the first step this might be an easier approach. But as PBasic has its limitations this is the smae on the propeller
best regards
Stefan
Post Edited (Mike Green) : 9/13/2009 2:45:33 PM GMT
You might want to setup one of the counters to measure the low-going pulse for the "start" bit
[noparse][[/noparse]Edit] Here's some *real* (albeit untested) code to go along with the above idea:
Again, this is predicated on the timing you specify. You'll need to pass the pin # and the counts in something just lower and just higher than 63 microseconds. For example:
This gives a little variablity to detecting the 62.5us low-going start pulse, yet the high end is safely less than the low pulse of a 0 bit and can be used as the sample delay from the 1->0 transition at the start of each bit.
Post Edited (JonnyMac) : 9/13/2009 5:46:08 PM GMT
Here's a little more clarification to the bit stream.
I'll try Mike's and JonnyMac's ideas.· JonnyMac's idea is very similar to what I was thinking of doing, but I'm still trying to get used to the spin code.· Thank you guys very much.
Clint