Hi Joep
Thanks for your advice. What I'm actually doing is, on one side, record
timer values coming from TSOP interrupts (so I'm recording "how long do I
have bit 1", nothing about 0s). Then, on the other side, from these values:
-- "duration" is what I recorded, typically either 6 or 13)
TMR3H = 0xFF - duration + 1
TMR3L = 0 -- ignore (negligible ?), maybe hardcode to 170
onboard_led = high
T3CON_TMR3ON = on
while T3CON_TMR3ON == on loop
ir_led = !ir_led
_usec_delay(14)
end loop
While loop is producing ~36-38KHz oscillation. When I record timer ~ 6000, I
reloading with 255 - 6 + 1 = 250. This will trigger an interrupt when
rolling over to 0, ~6000 count after. During that time, IR led is
oscillating at 38KHz.
Trouble is I don't record 0 values, but I can guess that:
- If I recorded bit 1 for 6000, then there were 2 zeros before
- If I recorded bit 1 for 13000, then there was 1 zero before
as bit goes by 3 I understood correctly...
[image: signal.jpg]
Well, that's a lot of "guess & mess" :) I'd need to better record timings.
Cheers,
Seb
2011/7/24 Joep Suijs <[email protected]>
> Hi Seb,
>
> Modulating accurate with 38kHz in software (with isr) is not so
> straight-forward as it seems. Especially since it means two interrupt
> for each cycle the interval gets quite short and reload time (from
> interrupt assertion up to that particular statement in the ISR)
> becomes relevant.
> Although you did not ask for any, my advise would be to use a timer
> with auto-reload (timer2 on 16f chips), convert the measured time into
> # of 38kHz cycles and have that ISR take it from there - create pulse
> and count down.
>
> I do have some example (used to create a 40kHz ultrasonic pulse for
> position determination) laying around if you're interested.
>
> Joep
>
> 2011/7/24 Sebastien Lelong <[email protected]>:
> > OK, I guess this is because I don't modulate my 1s at 38KHz...
> >
> > 2011/7/24 Sebastien Lelong <[email protected]>
> >>
> >> Hi guys,
> >> Some progress, but more questions... I've been able to decode IR signals
> >> using TSOP4838, I can clearly identify my two distinct IR codes. I uses
> INT1
> >> and 16-bits TMR3 to measure IR length. Values are stored in a array
> (only
> >> high bytes -- MSB -- values from the 16-bits timer, I think low bytes
> aren't
> >> relevant, they change on each try).
> >> Now I'd like to play back these IR codes. I have IR LEDs in my box, I
> >> think I need to add a transistor to drive these IR LEDs. From previous
> step,
> >> I have a table with TMR3 recorded values. I was thinking about loading
> back
> >> these values on TMR3 (max value - recorded value) and drive an IR LED
> on/off
> >> with interrupts. Well, doesn't seem to work, I guess this is again about
> >> modulation ?
> >> Do you have some more guidelines ?
> >> TIA
> >> Cheers,
> >> Seb
> >>
> >>
> >> 2011/6/18 William <[email protected]>
> >>>
> >>> Hi Seb,
> >>>
> >>> You're probably seeing the carrier - around 40KHz, so using a device
> >>> that demodulates the carrier would definitely help. They are cheap,
> >>> for example the PNA4612M.
> >>>
> >>> Have fun!
> >>>
> >>> William
> >>>
> >>> --
> >>> You received this message because you are subscribed to the Google
> Groups
> >>> "jallib" group.
> >>> To post to this group, send email to [email protected].
> >>> To unsubscribe from this group, send email to
> >>> [email protected].
> >>> For more options, visit this group at
> >>> http://groups.google.com/group/jallib?hl=en.
> >>>
> >>
> >>
> >>
> >> --
> >> Sébastien Lelong
> >>
> >>
> >
>
--
You received this message because you are subscribed to the Google Groups
"jallib" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/jallib?hl=en.