Shop OBEX P1 Docs P2 Docs Learn Events
IR sensor with the BS2 PX24 — Parallax Forums

IR sensor with the BS2 PX24

GumbyGumby Posts: 24
edited 2006-01-21 07:16 in BASIC Stamp
Hello,
I am using the same schematic as in the BOE bot IR sensing for a project (IR LED, IR sensor) but using the BS2 PX 24. I know my sensor is functional, as it picks up button press from my DVD remote and my IR LED worked on my last project.
I am using the program on page 273-4 'testing left frequency sweep'. I tried using a value of 6 instead of 1 as in 'Freqout 8,6, irFreq' as the time delay, to approximate 1mS but that did not work. Maybe 6 is not the correct value. Would the irdetect mode need to be done differently?
Does anyone have any idea on how to make this work? Thanks for your replies.

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-12-31 17:48
    Gumby -

    There is no such Parallax Stamp Product as a "BS2 PX 24" so I have included both the BS2p24 and the BS2px, along with the BS-2 in the information provided below. Just use whichever line fits the actual Stamp that you have.

    The general format of the PBASIC FREQOUT Commnd is as follow:

    FREQOUT pin, duration, frequency1 {, frequency2}

    The duration parameter is measured in terms of timer units. Timer units vary, based on which Stamp platform you are using. Here are a few of those values, most or all of which can be found in the PBASIC Help File or the PBASIC Stamp Manual:

    /code

    Stamp····· Seconds Per
    Platform···· Timer Unit
    ··
    BS-2······· ·· 1 mS
    BS-2p24· .265 mS
    BS-2px··· .166 mS

    code/

    By way of example, if a program is written for the BS-2 each timer unit is 1 millisecond in duration. If a program is written for the BS-2px then each timer unit is 166 micro-seconds in duration. All you need to is to mathematically extrapolate the values from the BS-2 Stamp program to "fit" the faster, BS-2px program, simple as that. All time based commands (PULSIN, PULSOUT, PAUSE, SLEEP, COUNT, etc) will need the same change of duration considerations during conversion.

    Regards,

    Bruce Bates

    Post Edited (Bruce Bates) : 12/31/2005 5:51:04 PM GMT
  • GumbyGumby Posts: 24
    edited 2005-12-31 20:18
    Bruce,
    Thanks for the reply and info. Also sorry for the confusion about the micro., it is the BS2 PX that I am referring to. I was trying to be very specific, on the module (chip) itself it is labeled/printed as BS2px24.

    Anyway the BOE BOT manual states that the key to make the IR LED/detector work is to send a 1ms of 38.5 kHz FREQOUT harmonic and then immeddiately store the IR detector input in a variable. So, I figured that since the PX has a .166ms FREQOUT you need to multiply by 6 to bring that value to close to 1ms. (1ms/.166ms=6.024..). I tried using 6 as a duration value with no luck. Also the frequency range of the PX is from 0 to 197585 Hz but the BS2 range is 0 to 32767. Does this change anything in how we handle the 'frequency1' value in the FREQOUT command? Finally Because the PX is faster do we have to poll the IR reciver somehow to 'wait' for a return signal?

    Regards,

    Gilles
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-12-31 20:22
    Bruce Bates said...(trimmed)
    Gumby -
    There is no such Parallax Stamp Product as a "BS2 PX 24" so I have included both the BS2p24 and the BS2px, along with the BS-2 in the information provided below. Just use whichever line fits the actual Stamp that you have.
    Bruce,

    ·· The BS2px is the BS2px24, as the BS2p is also known as the BS2p24.· In fact, the BS2p24 modules are marked as such, as are the BS2px24 modules.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-12-31 21:33
    Chris -

    Perhaps the Parallax web site should be so updated. It refers to it as the BS-2px, as does the update document that was published when it was first announced. I only know what I read smile.gif

    Regards,

    Bruce Bates
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-12-31 22:44
    Bruce,

    ·· No need to update.· There is no incorrect information being presented.· For simplicity the BS2px24 is being referred to as a BS2px.· This is okay since we have no BS2px40.· With the BS2p there is a 40-pin module, so many folks refer to the BS2p as a BS2p24 or BS2p40 (Depending on the module being referred to).· Simply calling it a BS2p is not incorrect.· Take care!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • GumbyGumby Posts: 24
    edited 2006-01-01 16:11
    OK now that we have the name all taken care of van we go back to the main issue of timing for the IR sensor.
    Does anyone have any insight on this. Chris.....?

    Thanks
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-01-01 19:03
    Gumby,

    ·· I don't know if the value of 6 is correct or not, because I don't know what you used on the previous Stamp Module you had to calculate the difference.· A value of 6 corresponds to a frequency of 36.18 Hz, which won't do much of anything.· What was your previous value before the BS2px24 was used?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-01-01 19:24
    Just went back and re-looked at your first post...6 is the duration, and your frequency is in a variable.· Which property are you having trouble with?· The Duration or the Frequency or both?· In any event, please list what you had in your old program, and what Stamp Module you used, and that will make it easy to calculate the new values.· Thanks.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • GumbyGumby Posts: 24
    edited 2006-01-01 19:44
    Chris,

    I did make this work with my BS2 module, currently I used with the LED a 1K ohm R and 220 ohm R, the IR detector has a 220 ohm R on it's input lead. The spec. sheet says that the receiver has a centre frequency of 38kHz and could pick up + - a few thousand Hz. When I try a program to detect 5 values bw 37500Hz and 41500Hz I get some hit when I use my DVD remote but not from my IR LED!
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-01-01 20:33
    Okay, given that your duration of 6 is correct.· As for the frequency value, that should be 6385, from my calculations.· Let me know if that works.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • brunoviannabrunovianna Posts: 1
    edited 2006-01-11 14:27
    What would be these values for the basic stamp sx? I'm using 3 and 15400, but I get inconsistent results.

    Thanks!
    Bruno
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-01-11 16:05
    Bruno,

    ·· Those values sound right...What do you mean by inconsistent results?· You could also try a 2 in place of your 3 for the duration to see if that helps.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • DougMM.comDougMM.com Posts: 4
    edited 2006-01-21 02:14
    Please help? How do I convert the normal Boe-Boe comands to use the BS2PX stamp?? I can't get anything to work...· It would be nice to see a pulse out, freqout chart???
    Thanks DougMM

    Post Edited (DougMM.com) : 1/21/2006 2:20:42 PM GMT
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-01-21 07:16
    The easiest way is to use conditional compilation -- that lets the program adjust itself to whatever module you decide to use. The manual and help file have several examples.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
Sign In or Register to comment.