reading a 10bit serial stream

hal9000

Member
Tech-supplies has no data on the IR pickup they supply, i can't be sure what frequency its for, so i have ordered some 38khz TSOP's from elsewhere which will be here in a week.

In the meantime i built a 555 circuit which seems to solve my problem, it inverts the signal, but goes high during the 38khz square wave. The PICaxe now fires on an interrupt as expected :



D0 = controller output
D1 = 555 timer circuit
D2 = output from PICaxe

The interrupt routine sets D2 high on entry, there is a 'pauseus 130' command and then it sets D2 low again. It rigidly sees this input now, no messing about.

So i tried the pulsin command that Hippy suggested, to read the new low-going pulses, and find that the PICaxe once again isn't consistent, its correct about 70% of the time. The pulsin command seems to ignore a high going pulse every now and then, or see one where there isn't one.

So i tried to use the settimer command in the interupt routine, but i find that this one settimer command takes 2.4ms which is longer that the pulses i'm trying to measure, so use of the settimer command is out of the window.

I'm stil using the SetInt command, could the problems i'm having be down to using this rather than hardware interupt? I'm still using SetInt instead of hardware intrupts because i can specify portC..

Are hardware intrupts only available on the first three pins of portB? Can anyone give me an example of the code for a hardware interupt to replace what i have now :

Code:
  setint %00000100, %00000100, C		'Set interupt for PinC.2
this one triggers the interupt on a high going signal on pin C.2. Am i missing something basic here?

I'm losing heart with the PICaxe.. can anyone convince me i'm going wrong somewhere and that all is not lost?
 

hippy

Ex-Staff (retired)
Am i missing something basic here?
Quite possibly, though I'm still not sure of the rationale of your approach or exactly what it is, what your algorithm proposed is for determining the bit times.

I'm also not sure exactly what the problem is that you are having; that the pulses times are too short to do what you need to ? If so then what speed are you operating the PICAXE at; running the PICAXE faster or hardware extending the pulse widths are both options open to you.

I'm still mystified as to why the PICAXE may be missing pulse edges but we saw that happening previously and that could still be down to the hardware interfacing.

I'm mainly finding it difficult to help though because it's partly working in the dark; we haven't seen a circuit diagram nor the code you are using or attempting to use, are having to second-guess things.

The way I see things is we have high-going pulses of around 250us width, and then need to time between one pulse and the next for ten pulses and turn those times into a numeric value. With the inter-pulse times of 1ms-2ms I can't really see a problem in doing that with a PICAXE running fast enough. Of course I don't actually have that signal in front of me to prove it would work but I would say that it should.
 

hippy

Ex-Staff (retired)
Here's something I've just tried.

First an 18M2 generating a signal similar to what your remote puts out but deliberately a little more stringent except for the repeat rate -

Sync Pulse of ~150us
Zero bit gap of ~1ms
One bit gap of ~2ms
Repeat rate of once a second
Pattern sent of 1100101010

Second a 20X2 which reads those pulses, converts them to a bit stream and displays them, so should show "1100101010" every second.

Works a treat for me :)
 

Attachments

Top