38 kHz Pulses for IR Beacon

erco

Senior Member
I'm interested in using an 08M2 as an IR beacon. I would like to send continuous bursts of 38 kHz carrier at around 1 kHz. IROUT sends SIRC-coded signals, which take too long. Is there another way to send continuous tone burst pulses as I described?
 

manuka

Senior Member
SIRC too long? Just what is being attracted to this beacon- and how? Forum maestro Hippy has previously nailed IR bit banging.
 

erco

Senior Member
On the tracking end, I want to count 10-20 pulses in a 10 ms interval. The BASIC Stamp has a FREQOUT command that can send short IR bursts, I was hoping there was a comparable PicAxe command.
 

hippy

Technical Support
Staff member
The usual way to bit-bang IR is to set PWMOUT going at 38kHz as the carrier and then bit-bang the modulator on an output pin, connect an IR LED + R between the two pins.

That does have the issue that the IR LED current can never be greater than what the PICAXE can handle and if one wants to use a transistor or FET then one also needs to use an external logic gate to combine carrier and modulator to create a single signal to drive that.

One could use a comparator and save on external logic but the M2's have a bit of magic no one reading the datatsheets seems to have noticed; the Digital Signal Multiplexor (DSM). This is effectively a hardware or software controlled internal SPDT switch which routes one of two carriers depending on the modulation level. That's handy for FSK ( if two PWM's available ) and particularly for doing IR modulation; route 'off' or '38kHz' to the output.

There's no Basic command for controlling the DSM but it's easy enough to poke the SFR's to get it working. This is thrown together and could probably be done at a lower operating speed ( and with better 1kHz modulation ) using PAUSEUS rather than PAUSE ...

Code:
#Picaxe 08M2
#No_Data

'  .----_----.                              IR LED
' -|+V     0V|-                        ___
' -|SI  SO/O0|--> Modulated Carrier --|___|--|>|--.
' -|X4     X1|-                                   |
' -|I3     X2|--> Carrier (N/C)                  _|_ 0V
'  `---------'

SetFreq M32

PwmOut 2, 210, 421       ' 38kHz @ 32MHz

PokeSfr $FD, %00000000   ' SFR $39D MODSRC
PokeSfr $FE, %00000000   ' SFR $39E MDCARL
PokeSfr $FF, %00000100   ' SFR $39F MDCARH

Do
  PokeSfr $FC, %11000000 ' SFR $39C MDCON
  Pause 3
  PokeSfr $FC, %11000001 ' SFR $39C MDCON
  Pause 3
Loop
 
Last edited:

Goeytex

Senior Member
This might work ... Untested


setfreq m8
do
pauseus 700
pwmout C.2, 52, 105
pauseus 700
pwmout C.2 , off
loop

'//adjust pauseus for 1khz
 

erco

Senior Member
@hippy & Goeytex: EXACTLY the kind of magic I was hoping for. Thanks, I will try both.

That DSM is a useful well-kept secret.
 

Goeytex

Senior Member
The previous code I posted was off.

This works pretty well and a Freq Meter shows a carrier of 38.05 Khz.
Tested on a 20x2. The 08m2 should be close

setfreq m32

Carrier_On:
pwmout C.5, 209, 421 : pauseus 295 : goto Carrier_Off

Carrier_Off:
pwmout c.5, off : pauseus 295 : goto Carrier_On

'// Tested on 20X2 Carrier = 38.04Khz
 

erco

Senior Member
Goeytex: Beautiful work! Thank you, that is fantastic news. You are incredibly helpful and a true credit to the forum.

Best,

erco
 

westaust55

Moderator
@erco,

While you have already been given information to help you, you may also wish to have a look at the basic IR comms tutorial here:
http://www.picaxeforum.co.uk/showthread.php?17303-Infrared-(IR)-Communications-Basic-Tutorial

Amongst other things, this covers generating a 38 kHz carrier using PWM on one PICAXE pin and switching that via a second PICAXE pin and transistor to general comms other than the inbuilt SIRC format.

Searching to forum can help you find the data you need - often without needing to post a new question.
 

TAMeyer

Member
Hiding in plain sight?

Wishing to learn more about DSM, I looked for the 08M2 Datasheet and could not locate such.
Where would I find it?

The forum moderators and top posters are ***unbelievably*** patient of those who refuse to pre-study before asking an "oft" answered question.
Out of respect for your tolerance (and a personal fear that the answer will be embarrassingly simple), please know, I actually did look. Detail below.

Many thanks,
Terry

=================================================================

Page 16 of the Manual Ver 7.7, provides this cross reference to the Microchip P/Ns.

PICAXE Type Engraving on top of chip
• PICAXE-08M2 PICAXE-08M2+
• PICAXE-14M2 PICAXE-14M2
• PICAXE-18M2 PICAXE-18M2
• PICAXE-20M2 PICAXE-20M2
• PICAXE-20X2 PIC18F14K22
• PICAXE-28X1 PIC16F886
• PICAXE-28X2 PIC18F25K22
• PICAXE-40X1 PIC16F887
• PICAXE-40X2 PIC18F45K22

...as does page 1 of the X2 product brief referring to the new base chips for the X2 release.
http://www.rev-ed.co.uk/docs/picaxex2.pdf

So for all items except the M2s, finding the relevant Microchip D/S is straightforward.

------------------------------------------------------------------------------------

The bottom of page 1 for the "PICAXE-M2 Information" states:

The M2 parts are new custom parts factory manufactured by Microchip Inc. solely
for Revolution Education and so are factory engraved with the full PICAXE-M2 name.
http://www.rev-ed.co.uk/docs/picaxem2.pdf

This would explain why there are no returns on the Microchip site for the term "08M2" or "DSM".

------------------------------------------------------------------------------------

Using the tag engraved on my 08M2s, "T241116" also returned nothing on MC's site. Batch number?

------------------------------------------------------------------------------------

Searching inside PE Ver 5.4.0 provided no information. Screen shot attached....

------------------------------------------------------------------------------------

Searching "Digital Signal Multiplexor" in Google returned:

"Did you mean: "Digital Signal Multiplexer"
and a link to this post.

Searching ""Digital Signal Multiplexer" Microchip" returned 5 hits of little value.

------------------------------------------------------------------------------------

??
 

Attachments

srnet

Senior Member
Wishing to learn more about DSM, I looked for the 08M2 Datasheet and could not locate such.
Where would I find it?
You wont, I believe Rev Ed are under a non-disclosure agreement to reveal which PIC the 08M2 actually is.

Not difficult to work it out though, just use the Microchip product selector using the published features of the 08M2, there are not 'many' 8 pin PICs with those features.
 

westaust55

Moderator
PICs approx corresponding to M2 parts

Wishing to learn more about DSM, I looked for the 08M2 Datasheet and could not locate such.
Where would I find it?

------------------------------------------------------------------------------------

The bottom of page 1 for the "PICAXE-M2 Information" states:

The M2 parts are new custom parts factory manufactured by Microchip Inc. solely
for Revolution Education and so are factory engraved with the full PICAXE-M2 name.
http://www.rev-ed.co.uk/docs/picaxem2.pdf

This would explain why there are no returns on the Microchip site for the term "08M2" or "DSM".

------------------------------------------------------------------------------------

Using the tag engraved on my 08M2s, "T241116" also returned nothing on MC's site. Batch number?

------------------------------------------------------------------------------------
As the Rev Ed documents indicate, The M2 parts are new custom parts factory manufactured by Microchip Inc. solely for Revolution Education.
The extent of "specialisation" is only known to rev Ed and Microchip.
at the kleast, it may be nothing more that the marking on the top but there may be unidentified silicon changes as well.

Notwithstanding the above, Technical has previously given some suggested reading guidelines as:
08M2 ==> see ~ PIC12F1840
14M2 ==> see ~ PIC16F1825
18M2 ==> see ~ PIC16F1827
20M2 ==> see ~ PIC16F1829
 
Last edited:

hippy

Technical Support
Staff member
@Hippy: On a different note (!) I believe your 2-pin PWM/modulator method would also work to allow audio tone generation (just simple beeps) that (as a task) would not halt multitasking operations. I hit that wall here: http://www.picaxeforum.co.uk/showthread.php?19233-Play-Tune-Stops-All
I had thought about PWM as a solution there but what held me back is that PWMOUT only generates a range of specific frequencies. If they are suitable then no problem.

You wouldn't have to go to the complexity of using the DSM or even a two pin solution; for slower speeds you could just turn the PWMOUT on and then off.

The main reason for not doing that with IR is to achieve faster execution, a simple HIGH, LOW or TOGGLE is faster than setting PWMOUT. The control by poking MDCON here allows an internal hardware bit to be used to set whether modulated or not. It can be configured to use an external input and, by looping an output back into that pin, control can be done using HIGH, LOW and TOGGLE commands which will be faster than POKESFR at the cost of slightly more complicated I/O wiring and use of an additional pin - I haven't checked or tested that for 08M2.

The DSM looks useful but I haven't identified many uses for it in practice other than as an IR modulator or a SPDT digital switch. That could just be me not thinking hard enough :)
 

erco

Senior Member
The forum moderators and top posters are ***unbelievably*** patient of those who refuse to pre-study before asking an "oft" answered question.
Roger that, Terry. Fortunately in this instance, this noob's "oft answered question" bore unexpected fruit: the knowledge of DSM which you seem particularly taken with.

Good thing I asked, huh? :)

And agreed, thanks to all posters & moderators for their patience and indulgence as I ramp up on the PicAxe. I look forward to learning from you all and paying back when I can.
 

TAMeyer

Member
Apologies / Clarification

@ erco

Thank you for your note.

Maybe I shouldn't be posting at 2AM PDT, pharmaceutical assistance or not.

As the post's author (and a smoke carrying noob), I am responsible for the entry's clarity.

Apologies for any offense.

-----------

My reference to the ""oft" answered question", was not regarding your inquiry concerning IR, SIRC, 38 kHz.

But rather to mine:
Paraphrase~~ "Where are the baseline Microchip data sheets for RevEd's 08M2s?"


Your entry remains an informative conversation starter that solicited "hippy's" response concerning DSM.


Had my question not been specific to M2s, that post should be seen as RTFM leakage.

I was just being careful as to "The datasheets are here, somewhere...?"



All good I hope....




--------------




Now, what's a MDCON register?





----OK----



That was a joke...no links please....





I'll look it it up....



Really.


Thanks

Terry
 

manuka

Senior Member
While we're at the detective work,just why is that "+" added to the 08M2 DIP chip? AFAIK the other M2 don't have it.

08M2.jpg
 

Goeytex

Senior Member
Back to the original topic for a moment ...

Sometimes I forget how useful some analog devices can be when integrated with a micro.
Attached is a diagram that shows using a 555 timer for the 38Khz oscillator and the Picaxe
1 Khz PWM to modulate. This frees up the Picaxe to do other stuff without affecting the modulated
output. Also the 555, if properly selected , can source up to 200ma ( Non CMOS).
 

Attachments

westaust55

Moderator
While we're at the detective work,just why is that "+" added to the 08M2 DIP chip? AFAIK the other M2 don't have it.

View attachment 8946
To distinguish between the 08m2+ and 08M2LE.

Both available in the PE drop down chip select menu.
LE is limited in terms of program memory capacity and presume the "+" is to indicate with 'extra' memory by comparison

According to past post by Tiscando:
The 08M2LE is marked "08M2", and the full 08M2 is marked "08M2+"
 

westaust55

Moderator
The past comment by Technical was:
The 08M2LE (E for "lite edition") is a special part for educational use which has 256 bytes of program storage
.

Thus I presume that it is not available for general purchase.
 
Last edited:

manuka

Senior Member
OK! One could take issue with such a notation, as surely just a simple "LE" could be used when needed... Globally "lite" is well established for trimmed down offerings. Having lobbied for decent PICAXE labelling (since 2002 !) I REALLY hope we don't begin again a ?%$&*!!? era as a result.

FWIW students here in NZ have already found this 08M2 "+" confusing. Given an educational insistence that IC codes be viewed VERY critically, this is praise worthy of course- the difference between the likes of even a 7805 and 78L05 is pretty significant.
 

erco

Senior Member
Back to the original topic for a moment ...

Sometimes I forget how useful some analog devices can be when integrated with a micro.
Attached is a diagram that shows using a 555 timer for the 38Khz oscillator and the Picaxe
1 Khz PWM to modulate. This frees up the Picaxe to do other stuff without affecting the modulated
output. Also the 555, if properly selected , can source up to 200ma ( Non CMOS).
@Goeytex: True 555/556 circuits are very useful. Some of my favorite websites:

http://www.kpsec.freeuk.com/555timer.htm
http://home.cogeco.ca/~rpaisley4/LM555.html#26

My last project (which inspired this post) used a 556 as an IR remote sending IR with several different modulation frequencies: http://forums.parallax.com/showthread.php?130927-Low-Tech-IR-Remote&highlight=homemade+ir+remote That explains why I couldn't use the slower SIRC protocol.

I'm trying the all-digital route now. Compared to the $50 Basic Stamps I have used, PicAxes seem almost free and barely more than the cost of a 556. I want to reproduce that 556 circuit with a PicAxe for starters.

As always, thanks for your feedback.
 
Top