Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools
Old 27th October 2009, 01:40 AM   #1
Arrow Capturing High Low Pulses Code Problem

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
Attached Thumbnails
Capturing High Low Pulses Code Problem-bit-stream.png  
Suraj143 is offline  
Old 27th October 2009, 05:50 AM   #2
Default

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
AtomSoft is offline  
Old 27th October 2009, 06:01 AM   #3
Default

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 by AtomSoft; 27th October 2009 at 06:03 AM.
AtomSoft is offline  
Old 27th October 2009, 06:29 AM   #4
Default

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

Last edited by Mr RB; 27th October 2009 at 06:31 AM.
Mr RB is offline  
Old 27th October 2009, 08:07 AM   #5
Default

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
colin55 is online now  
Old 27th October 2009, 10:56 AM   #6
Default

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.
Suraj143 is offline  
Old 27th October 2009, 11:06 AM   #7
Default

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 by Suraj143; 27th October 2009 at 11:11 AM.
Suraj143 is offline  
Old 27th October 2009, 01:05 PM   #8
Default

Why does the timing change from one string to the next string???
Mr RB is offline  
Old 27th October 2009, 01:17 PM   #9
Default

We need a little more information,

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.
Pommie is online now  
Old 27th October 2009, 02:49 PM   #10
Default

Quote:
Originally Posted by Pommie View Post
We need a little more information,

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.
Suraj143 is offline  
Old 27th October 2009, 03:06 PM   #11
Default

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.
Pommie is online now  
Old 27th October 2009, 03:15 PM   #12
Default

Quote:
Originally Posted by Pommie View Post
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.
Suraj143 is offline  
Reply

Tags
capturing, code, high, low, problem, pulses

Thread Tools
Display Modes


Similar
Title Starter Forum Replies Latest
Logic high/low carlson Electronic Projects Design/Ideas/Reviews 4 14th June 2009 07:02 AM
low noise, high gain, low frequency amplifier max1000000 Electronic Projects Design/Ideas/Reviews 2 29th June 2007 09:10 PM
converting active low pulses to DC ikalogic Electronic Projects Design/Ideas/Reviews 4 16th April 2007 11:50 AM
Capturing high frequency pulses Reynard General Electronics Chat 24 11th September 2006 04:29 PM
Simpel code for registrating high/Low on input pins gobbles Micro Controllers 0 26th September 2005 03:57 PM



All times are GMT. The time now is 06:35 AM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker