Continue to Site

# Capturing High Low Pulses Code Problem

Status
Not open for further replies.

#### Suraj143

##### Active Member
I’m trying to capture hi low pulse timing & save them in a binary form.

I have attached my drawing that how the pulse streams are coming. In every stream the timing is T & 2T length of pulses.

If the high pulse is 2T then the binary must be 11
If the high pulse is T then the binary must be 1
If the low pulse is 2T then the binary must be 00
If the low pulse is T then the binary must be 0

I want to arrange like above format. Any idea how to do. No need code just tell me the idea. Do not suggest capture modules. Want to do it from a general I/O pin with a timer.

Thanks

#### Attachments

• Bit Stream.PNG
9.6 KB · Views: 166
Seems simple.... Since T is the normL length the count every T if it's high the OR in a 1 and shift left if it's low AND in a 0 and shift left. If u do this in every T u will get everything correct

to clarify... let's assume T= 10 us When u start counting check if high
if high then or in a one
if low and in a Zero

shift left by one

wait 1T (10us) then check if high
if so or a One
if low And a zero
shift left by one
repeat until complete and It should be good

Last edited:
(edit) deleted; sorry I posted wrong code, i didn't read your question clearly.

Last edited:
How long is "T" in uS?

We have to know how much time you have for housekeeping.

What PIC chip are you using?

Use Timer0 or Timer1

Hi for everybody thanks for the support you all giving.

The input pulses varying from 200uS to 2000uS.For example T=450uS,2T=900uS so the whole string goes with those two values.On next string it can start from T=550,2T=1100uS.

I'm using TMR0 I don't like TMR1.

I can prescale & give inputs.

Ok I'll tell whats my method.

First you wait for a mark pulse.When mark pulse detected turn on the TMR0.Wait until space pulse & when space pulse detect save the "Mark_Time" & reset TMR0.Wait until next mark pulse,when next mark pulse save the "Space_Time".

Now we have two values."Mark_Time" & "Space_Time".

Now subtract “Mark_Time” from "Space_Time". Check the carry bit status & arrange the result registers. Likewise on every after Period subtract “Mark_Time” from "Space_Time & arrange the result registers.

The problem with my method is when both the mark & spaces equal the result will be wrong.

Last edited:
Why does the timing change from one string to the next string???

How many bits are involved in a transmission?
Is the line low between bytes/words?
Is there a change that signifies the start of a byte or could a zero (or two?) come first?
Does a byte/word always contain 00,11,01&10 sequences?

Mike.

How many bits are involved in a transmission?
Is the line low between bytes/words?
Is there a change that signifies the start of a byte or could a zero (or two?) come first?
Does a byte/word always contain 00,11,01&10 sequences?

Mike.

Very good points mike. You have come up closer.

*Per transmission they are about 25-30 bits.
*Those are not bytes those are just high low pulses.
*The start of a string always 1(T) or 11(2T)

To detect end of the frame I'm checking the "space time" has gone above 2000uS.because the maximum T is 2000uS.So I can identify the frame is end or not.

Mike as you understand lets assume you get 2T “Mark Time” & a 2T “Space Time” on start of the frame. According to my method if I just subtract “Mark Time” from “Space Time” It will be “10” format. But it should be “1100”.Now see the error. I think you understood now.

I think you need to capture the whole data stream as a series of time values and look for the shortest pulse to work out the "baud" rate. If you are not guaranteed that the stream will contain a single T pulse then you will have to assume that the time for the shortest pulse that you received is a single T and see how many bits you have. If the bit count is less than 25 then recalculate with T=T/2.

Mike.

I think you need to capture the whole data stream as a series of time values and look for the shortest pulse to work out the "baud" rate. If you are not guaranteed that the stream will contain a single T pulse then you will have to assume that the time for the shortest pulse that you received is a single T and see how many bits you have. If the bit count is less than 25 then recalculate with T=T/2.

Mike.

Ok thanks for the input.I'll tell what I'm doing.

I'm trying to make a universal Infrared Remote Decoder.I need to store particular remote incoming data & compares the same remote code is coming on next time.

I'm ignoring start bit & the first space time.After that only I'm capturing incoming data.If you study all remote codes based on T & 2T format.

Many will tell that you can't make a UIR decoder.But at least I can make a one working for many remotes but not for all.

Any method to capture those stream.

Status
Not open for further replies.