Shop OBEX P1 Docs P2 Docs Learn Events
BS1: SOUND cmd drive IR ? — Parallax Forums

BS1: SOUND cmd drive IR ?

MRM100MRM100 Posts: 24
edited 2012-02-01 19:17 in BASIC Stamp
Okay - so I have successfully made a garage door closer (closes door after checking to see if it has been left open for programmed period of time) based on BS2 development board and IR detector using FREQOUT command. I quickly ordered a BS1 project board to complete the project, since I needed only 3 I/O Pins, but of course neglected to check if FREQOUT could be used on BS1 (it can't).
I see that I can generate Square wave frequencies that might approximate 38500 Hz using the SOUND cmd with BS1, but will it work? Has anyone tried - is it worth the effort or doomed to failure?
I could just hook it up and try, I suppose, but my IR LED/detector is in position about 10 feet off the ground, and it's too late to do that tonight...

Thanks,

MRM

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-12-12 22:24
    The SOUND statement only generates signals up to about 10KHz. It won't work for what you want. Use an external 555 timer to generate the 38KHz signal. The 555 can easily drive more than one LED at full brightness. It's cheap and reliable. There's a sample circuit for this in "IR Remote for the BoeBot Robot" in Appendix C.
  • MRM100MRM100 Posts: 24
    edited 2011-12-12 22:48
    Wow, what a great idea - I just happen to have several 555's on hand (just learning how to use them). I thought sure the response was going to be "why not just use the BS2...".
    You always seem to have an answer, Mike.
    Thanks.
  • MRM100MRM100 Posts: 24
    edited 2011-12-19 21:24
    Mike Green wrote: »
    The SOUND statement only generates signals up to about 10KHz. It won't work for what you want. Use an external 555 timer to generate the 38KHz signal. The 555 can easily drive more than one LED at full brightness. It's cheap and reliable. There's a sample circuit for this in "IR Remote for the BoeBot Robot" in Appendix C.
  • MRM100MRM100 Posts: 24
    edited 2011-12-19 21:27
    Mike, I reviewed the material in "IR Remote for the BoeBot Robot" and the description is for use with the BS2. I am not saying that the 555 could not be driven wth the BS1, but the PBasic code uses the COUNT command to fine tune the timer to 38KHz and this command is, again, used only with the BS2... Any ideas how to get around this and program the 555 with the BS1?
  • MRM100MRM100 Posts: 24
    edited 2011-12-19 22:23
    Well - it seems I keep replying to my own posts. In thinking about this further, it seems that instead of the COUNT command to display results of the Timer Frequency on screen via DEBUG, I can simply rig an IR LED and Detector into a circuit and let the Detector signal when the IR LED fires as I manipulate the POT. Seems simple enough - I'll let you know if I have any trouble.
  • Mike GreenMike Green Posts: 23,101
    edited 2011-12-19 22:29
    You could use the PULSIN statement to measure the time from one pulse to another. To make it more accurate, you could use a decade counter chip to count 10 pulses and, using a PULSIN, measure the time it takes for 10 pulses and use that to set the 555 timer

    Another option would be to start at one end of the range of resistance, then slowly adjust the resistance until the IR detector first triggers and continue to adjust the resistance until the IR detector stops triggering, then set the resistance to the middle of that range.
  • MRM100MRM100 Posts: 24
    edited 2011-12-19 22:47
    Aha - are you referring to something like a 4017? I think I see how that could be done. (I just wish I had more free time to play around with this stuff).
    Thanks again, Mike.
  • ercoerco Posts: 20,256
    edited 2011-12-20 09:52
    You'll use a special 38 kHz receiver module, which is quite sensitive and will detect whatever modulation you put on the 38 kHz signal. You can't use a steady (unmodulated) 38Khz signal, such as a 555 generates. You need two 555s (which is a 556 dual timer). One timer generates the 38 kHz carrier, and the other pulses that on & off at a much lower frequency which your BS1 can read using PULSIN. Attached is a schematic of a modulated IR remote I made which will work for you. Delete the 4 resistors and 4 switches on the bottom left, just replace all that with a 15K resistor between pins 1 & 2, in parallel with the diode.
    630 x 600 - 68K
  • MRM100MRM100 Posts: 24
    edited 2011-12-21 22:35
    Thanks for the reply, erco. But all I really need to do is detect an IR LED with an IR sensor and be able to tell if the sensor "sees" the IR LED's output. The IR sensor sends a 0 or 1 based on whether the LED IR is blocked or not. Won't an unmodulated 38 kHz signal "light" the LED and be detected by the IR sensor?
  • ercoerco Posts: 20,256
    edited 2011-12-21 22:38
    MRM100 wrote: »
    Thanks for the reply, erco. But all I really need to do is detect an IR LED with an IR sensor and be able to tell if the sensor "sees" the IR LED's output. The IR sensor sends a 0 or 1 based on whether the LED IR is blocked or not. Won't an unmodulated 38 kHz signal "light" the LED and be detected by the IR sensor?

    Most IR detector modules will go low for less than a second then stay high afterward with an unmodulated 38 kHz signal. Try yours & see.
  • MRM100MRM100 Posts: 24
    edited 2011-12-22 20:01
    erco wrote: »
    Most IR detector modules will go low for less than a second then stay high afterward with an unmodulated 38 kHz signal. Try yours & see.

    Ah, yes I forgot that. But what I am doing is simply sending a 1ms pulse (every 15 minutes or so) to an IR LED and immediately reading the IR Detector's output to see if it received the pulse (Garage Door is down) or not (Pulse blocked = Garage Door is up). It works as expected using FREQOUT on the BS2; I am anxious to see if it will work with the BS1 using the 555.
    I appreciate your schematic of the 556 circuit; I have another project where that might be useful.
  • MRM100MRM100 Posts: 24
    edited 2012-01-10 21:47
    Mike Green wrote: »
    You could use the PULSIN statement to measure the time from one pulse to another. To make it more accurate, you could use a decade counter chip to count 10 pulses and, using a PULSIN, measure the time it takes for 10 pulses and use that to set the 555 timer

    Another option would be to start at one end of the range of resistance, then slowly adjust the resistance until the IR detector first triggers and continue to adjust the resistance until the IR detector stops triggering, then set the resistance to the middle of that range.

    Okay - so this is what i did: I used BS2 to rig up 555 timer according to description in Appendix C of IR Remote for the BoeBot Robot. Using COUNT command as described, the frequency is sent to the DEBUG terminal and adjusted with a 10K Pot. The POT is very sensitive, however, and I was concerned that this would not remain stable, so I tried using a Digital Pot, but I couldn't get it to work (I think because a ground connection is needed at Pin 6 which grounds Pin 7 of the 555). Anyway, I then got the idea to simply measure the resistance of the Pot (1.4K) and used 3 Resistors in series to give me what I needed. Next, will hook up to BS1 and see if it works...
  • MRM100MRM100 Posts: 24
    edited 2012-01-29 15:09
    I have hooked up BS1 to 555 with circuit (schematic below) modified from Appendix C of "Transmitting IR Remote Signals with the BASIC Stamp 2". All works with Standard LED, but no output when IR LED attached, even when removing transistor and attaching Pin 8 and 6 directly to VDD. I thought I might have a bad IR LED, so I hooked it up to BS2 and using FREQOUT with IR Receiver, all was OK. I suspect I am not getting adequate current to drive IR LED, so I will try hooking transistor to external power source.
    Any other ideas?
    480 x 640 - 20K
  • MRM100MRM100 Posts: 24
    edited 2012-01-31 23:27
    Still having trouble with 555 Timer and IR LED.

    I have returned to using the circuit exactly as described in Appendix C noted above and appended below. I used power from BS2 Servo port as well as from standard Vdd - no difference. Everything works fine with Green LED, but when I substitute IR LED I get no output to Pin7; Hz reads 0000. I get a Voltage reading to LED of 2.38 V and 8 mA. I figured this was not enough current for IR LED, so I decreased Resistor value at LED to 47 Ohm. This increases current to 35 mA and I was able to get frequency up to 2000 Hz, but no where near 38KHz I need. I tried increasing and decreasing the value of the 470 ohm resistor, but no help.
    Next I tried decreasing the value of the resistor at the LED to 18 Ohm. This increased the current to 96 mA, and i was able to increase the frequency to 3000 Hz. I have tried using IR LED from Parallax as well as one from Radio Shack - same response.
    I would like to use the BS1 with 555 timer to light IR LED at 38 KHz for a project. Of course, I have the alternative of using the BS2 with FREQOUT to the IR LED, but now I want to know why the described circuit won't work. It certainly appears to have something to do with an inherent difference between the standard LED and IR LED, but the circuit WAS originially written using the IR LED. Do you think the characteristics of the IR LED have changed since that circuit was described?
    Any other thoughts?

    MRM
    1024 x 531 - 56K
    555.jpg 55.6K
  • Mike GreenMike Green Posts: 23,101
    edited 2012-02-01 06:54
    There's very little difference in the electrical behavior of an IR LED vs. a red LED. The 555 circuit will work the same with either. For other color LEDs, you have to adjust the value of the 220 Ohm series resistor since the voltage across the LED is different with green / yellow / blue / white LEDs. Most LEDs are designed for a maximum current of 20mA. You can use a higher peak current, but the average current has to be kept to around 20mA or the LED will be destroyed. Too high a peak current will also destroy or shorten the lifetime of the device. Changing the current through the LED won't affect the frequency of the 555's operation. Changing the resistors attached to the Dis pin will do that. There are plenty of on-line tutorials on the use of the 555 that explain how it works and how those resistors affect the oscillation frequency.

    The circuit given does work as advertised. Check your wiring. You may have damaged your LEDs with the high current, so you may want to use a new one. Try a red LED first since you can see the output. You can also use a video camera to see the IR output of an IR LED.
  • MRM100MRM100 Posts: 24
    edited 2012-02-01 09:57
    Mike Green wrote: »
    There's very little difference in the electrical behavior of an IR LED vs. a red LED. The 555 circuit will work the same with either. For other color LEDs, you have to adjust the value of the 220 Ohm series resistor since the voltage across the LED is different with green / yellow / blue / white LEDs. Most LEDs are designed for a maximum current of 20mA. You can use a higher peak current, but the average current has to be kept to around 20mA or the LED will be destroyed. Too high a peak current will also destroy or shorten the lifetime of the device. Changing the current through the LED won't affect the frequency of the 555's operation. Changing the resistors attached to the Dis pin will do that. There are plenty of on-line tutorials on the use of the 555 that explain how it works and how those resistors affect the oscillation frequency.

    The circuit given does work as advertised. Check your wiring. You may have damaged your LEDs with the high current, so you may want to use a new one. Try a red LED first since you can see the output. You can also use a video camera to see the IR output of an IR LED.
    Mike, thanks again for responding.
    Your comment Re: lack of difference in the electrical behavior of the LEDs was exactly what I needed to hear, but is in direct contradistinction to what I have observed consisitently: ie circuit behaves exactly as expected when Green LED is in circuit, but when it is replaced by IR LED, no frequency output identified. I then take the same IR LED and put it in BS2 circuit with FREQOUT code and IR is detected by IR detector ( so LED is operational).
    I have looked at various 555 circuits on the Web for 38 KHz frequency and they are very similar. I have rewired this circuit multiple times on 3 different breadboards and it always works with Green LED and never works with IRLed ( which otherwise seems to be functioning). I will try your idea about using a video camera to confirm output. And I will re- wire again tonight (or maybe I will sleep tonight and do this tomorrow).
    Thanks again.
  • MRM100MRM100 Posts: 24
    edited 2012-02-01 19:17
    Ha! Finally figured out the problem. All a matter of misinterpretation of data: When I had Greeen LED in place, I could adjust the frequency in DEBUG. BUT, when I removed the Green LED and replaced it with the IR LED, the Frequency reported in DEBUG went to 0000Hz and I ASSUMED this meant there was a problem and that the 555 was no longer putting out 38KHz. Instead, when the IR LED is in place, the output of the 555 is not "available" to be sampled (for some reason), but in fact is being sent to the IR LED - and is detected by IR Detector. It only took me another 3 hours to figure this out...

    So, the circuit works and I thank Mike and ERCO for their input.
Sign In or Register to comment.