Shop OBEX P1 Docs P2 Docs Learn Events
Controlling a CD Player — Parallax Forums

Controlling a CD Player

revrev Posts: 27
edited 2010-03-30 21:30 in BASIC Stamp
Hi-

I have a bs2sx and I would like to have it turn on a dvd player and activate the play function, then periodically stop and restart it. any ideas? thank you

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-03-02 01:54
    The best way to do this is to get a couple of 5V coil reed relays (SPST-single pole single throw, NO-normally open) and have the Stamp activate these with an I/O pin, then wire the contacts across the switches in the DVD player so it's just like the Stamp was pushing the buttons. If you pick the relays properly (coil current < 20mA), you should be able to drive them directly from the Stamp without a switching transistor. RadioShack carries 5V reed relays that will work this way. You'll need diodes connected across the relay coils to prevent them from damaging the I/O pin. See the Stamp Manual and Nuts and Volts Column #6 for diagrams.

    It might be possible for the Stamp to work like a remote control.· It depends on the DVD manufacturer and the coding scheme they use.· Look at Parallax's "IR Remote for the BoeBot" tutorial for a discussion of the issues and sample code for, I think, Sony's IR protocol.
    ·
  • revrev Posts: 27
    edited 2010-03-02 02:10
    great. thanks for your prompt reply! I was thinking that the stamp could maybe supply current directly to the button contact, is that harder than it seems? I am assuming from your reply that the 5v out from the pin is not the proper voltage, thus the mechanical solution... is a reed relay like a solenoid in that it has an external mechanical component? or does it require some modifications?
  • revrev Posts: 27
    edited 2010-03-02 02:26
    ok, a coil reed relay is not a mechanical solution but rather the exact one i was looking for...thank you
  • Peter KG6LSEPeter KG6LSE Posts: 1,383
    edited 2010-03-02 02:51
    If the direct IR from the µC does not work I would hack a remote with the reed relay idea . this way its harder to fry the player and also it keeps the player intact ...
    you could wire the µC to the remote control Chip but there may be some issues with source sink and also if its a matrix style it could get complicated to wire add code .

    I ran in to the same isolation and source sink issue with my hacked Cam I used for TL cam so I used reed relays (with a 2N3904 driver)
    to emulate the power and shutter buttons

    Peter KG6LSE

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "Carpe Ducktum" "seize the tape!!"
    peterthethinker.com/tesla/Venom/Venom.html
    Never underestimate the bandwidth of a station wagon full of tapes hurtling down the highway. —Tanenbaum, Andrew S.
    LOL
  • revrev Posts: 27
    edited 2010-03-04 17:17
    is the reed relay you guys describe something like on the following page?: www.cotorelay.com/html/reed_relay___dry_reed_switch_p.htm. I understand the contactor voltage on the control side needs to be 5V, what about the other side? does it have a min and/or max current?

    By wiring a diode across the coil you are preventing a voltage spike from getting back to the stamp as illustrated in the following image?:gd761q

    I have used the 2N3904 driver to give my stamp some more mojo in the past, but it would be nice to find another simpler way. thanks for the pointers guys, its been a while since I've delved into this.
  • revrev Posts: 27
    edited 2010-03-04 17:38
    hmm, the image should be here, sorry about that: files.me.com/revelever/7xublh
    276 x 181 - 35K
  • revrev Posts: 27
    edited 2010-03-04 18:22
    is this a good relay to use? www.sparkfun.com/commerce/product_info.php?products_id=101 seems a bit over powered perhaps.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-03-04 18:25
    That's about as simple as it gets, believe it or don't.

    There are 5V relays, but they verge on 20mA each.· If you have several relays then you could use an IC like the ULN2803, but, in my view,·that's a waste for one.
  • Mike GreenMike Green Posts: 23,101
    edited 2010-03-04 18:39
    Here's a 5V SPST reed relay that can be driven from a Stamp I/O pin:
    www.radioshack.com/product/index.jsp?productId=2062478

    Coto makes an equivalent one that has a 20mA coil current. You need something like a 1N914 diode (also available from RadioShack) wired as shown in your diagram, but without the switching transistor. If you're only activating one or two relays at a time as you would be in controlling a CD player, you'll be fine.
  • revrev Posts: 27
    edited 2010-03-05 04:27
    Just pick up a few of those very same relays today, also happened to noticed that they had a drawer packed full of the rangefinders #28015 that parrallax seems to be out of and which I happen to have been looking for [noparse]:)[/noparse] .

    Is a 1N914 switching diode interchangeable with a 1N4148 in this instance?

    For now, I'll only need to trigger 1 relay at a time. Shortly, I'll need to trigger 5 virtually simultaneous pins for 5 dvd players, would a ULN2803 do the job triggering 5 simultaneous reed relays? or should individual transistors be used, 2N3904 or 2N3906? or neither? ... perhaps I would control a universal remote that triggers all 5 DVD players, though I'd be a bit concerned about the longevity / reliability, and this circuit needs to last.
  • revrev Posts: 27
    edited 2010-03-08 15:17
    So, yes, those diodes are interchangeable, I'll answer that one myself. As far as the simultaneous relay triggering goes, anyone?

    Also, what are the potential risks of frying the DVD player? ie. how would one go about ensuring that doesnt happen?
  • Mike GreenMike Green Posts: 23,101
    edited 2010-03-08 17:18
    You don't want to trigger more than one or two reed relays at a time if you're driving them directly from a microcontroller. Unless you absolutely have to trigger several DVD players at the exact same time, you'll do fine with triggering them one at a time in rapid succession and you could use "direct drive" from the microcontroller for that. If not, then use a couple of ULN2803s or individual transistors. Either would work.

    Since the Stamps have only 16 I/O pins (except for the BS2p40), you may want some kind of I/O expander to handle more relays. If you have 5 DVD players, each with 4 or 5 buttons you want to control, you will need more I/O. The TI TPIC6595 combines a 74HC595-like serial shift register with a parallel latch along with 8 MOSFET switching transistors plus the protective diode suitable for controlling relays. You can cascade these like the 74HC595 for multiples of 8. All of the coding examples for the 74HC595 will work with the TPIC6595. Look in the StampWorks Manual and in the Nuts and Volts Columns.

    The whole idea of using a relay is to have something that works just like the switches in the DVD player and is completely isolated from the DVD player's electronics. If you connect the relay contacts carefully across each of the pushbutton switches involved, the DVD player can continue to be used normally, but can also be controlled remotely by the microcontroller.
  • revrev Posts: 27
    edited 2010-03-08 18:43
    Excellent info, thank you so much
  • skylightskylight Posts: 1,915
    edited 2010-03-08 20:34
    ok it may be fun hacking into the player but to then connect a stamp through relays and control this by IR remote seems a bit of overkill when yoiu could just use the remote for the player.

    What we call Heath Robinson and you guys call Rube Goldberg, overcomplicating a solution when a simpler one is available, now making the player drive itself to you to press the buttons when you want sounds a good idea. cool.gif
  • revrev Posts: 27
    edited 2010-03-08 21:28
    Skylight-

    what I am doing is creating 5 simultaneous 'loops' on 5 DVD players. If one simultaneously plays 2 or more tracks of the same length on two separate DVD (or cd, cassette, etc ) players, they inevitably go out of sync afte a while. This is unacceptable in this particular instance, hence the need for the Stamp. It was proposed that the syncing be done with 5 mac minis, which, while entirely feasible, is also much more expensive.

    So, the goal is ultimately to control 5 DVD players, using the basic stamp as a common time reference to which all of the DVD players are periodically synced, and thus keep all of them essentially in time.

    The idea was never to control the basic stamp with IR, but rather to control a universal IR remote with the basic stamp, and have that remote simultaneously restart the players at the end of their said loops, or some interval thereof.

    This is the automation component for an art project, so it's ultimate practicality IS certainly debateable, I suppose, however the collector who bought the piece finds the DVD syncing to be a real problem.
  • revrev Posts: 27
    edited 2010-03-12 16:51
    if i wire up one of these reed relays wrong what is the risk of frying a pin on the stamp, and, if I do fry a pin on the stamp does that necessarily mean that the stamp itself is fried? or just an IC chip, or other singular component? What does a voltage spike back to the stamp do?
    also, and my apologies in advance if this is seen as a silly question, what are the basic stamps capabilities as far as time keeping goes? Do I need something like the DS1302 for this project? For the fist project i will be restarting a dvd player every 8 min, 31 seconds, for the second project i will be triggering 5 dvd players every 4 hours or so. thanks in advance!
  • Mike GreenMike Green Posts: 23,101
    edited 2010-03-12 17:19
    1) If you wire up the reed relays wrong, you could fry the Stamp, but it's pretty obvious which terminals on the relay are the coil connections and which ones are the contacts. Wire up the coils first (before connecting to the DVD players) and write a little test program that closes each relay in turn for a second or so and check with an Ohmmeter or a battery, resistor, and LED to make sure that each contact works.

    2) The Stamp is at best "ok" at timekeeping. For the long time periods you're talking about, I'd use an external real time clock. You don't need to set the clock and you don't need a battery backup if you reinitialize the clock when the Stamp is reset. For something as simple as this project, you could get by without a real time clock. The Stamp may "drift" a little, but the various DVD players will stay in sync with each other, at least to within a couple of seconds. You really need a real time clock if you want everything to stay in sync with the time of day though.
  • revrev Posts: 27
    edited 2010-03-16 22:26
    Ok, finally got some time to sit down and do this. The reed switches are working nicely. The code portion is essentially a infinitely looping process that turns the DVD player on, waits for it to warm up , presses play, pauses 7'35", resets, turns it off, pauses a 1'35", and repeats. During the long pause where the DVD player is playing it opens and closes an optoisolator in a quazi random sequence to power a 120V 2.5A fan that controls an inflated membrane. At the beginning of the first cycle, it closes the opto circuit for 30 sec for initial inflation of the membrane.
    I am going to house the whole electronic component in this DVD player, the only thing lacking from the attached picture is a 120V receptacle for the optoisolator output. I would also like to have a button and a 2 way switch easily accessible on the exterior of the DVD player. With the button I need to trigger and terminate the process, which I can achieve simply by interrupting the power to the stamp via the regulated power supply's + line. Via the 2 way switch I would like to enable the choice from one of two loops for the optoisolator sequence that comprises the 7 minute pause during which the DVD player is in play mode. This switch wouldn't need to take place during the loop necessarily, as that would be a bit more complicated i imagine.
    the code for the optoisolator looks like this:
    ' {$STAMP BS2sx}
    ' {$PBASIC 2.5}

    inflate:
    HIGH 0
    PAUSE 30000
    '30 sec
    fan1:
    HIGH 0
    PAUSE 100
    LOW 0
    PAUSE 1900
    HIGH 0
    PAUSE 200
    LOW 0
    PAUSE 1800
    HIGH 0
    PAUSE 300
    LOW 0
    PAUSE 1700
    HIGH 0
    PAUSE 400
    LOW 0
    PAUSE 1600
    HIGH 0
    PAUSE 500
    LOW 0
    PAUSE 1500
    HIGH 0
    PAUSE 600
    LOW 0
    PAUSE 1400
    HIGH 0
    PAUSE 700
    LOW 0
    PAUSE 1300
    HIGH 0
    PAUSE 800
    LOW 0
    PAUSE 1200
    HIGH 0
    PAUSE 900
    LOW 0
    PAUSE 1100
    HIGH 0
    PAUSE 1000
    LOW 0
    PAUSE 1000
    '20 sec
    HIGH 0
    PAUSE 1000
    LOW 0
    PAUSE 1000
    HIGH 0
    PAUSE 900
    LOW 0
    PAUSE 1100
    HIGH 0
    PAUSE 800
    LOW 0
    PAUSE 1200
    HIGH 0
    PAUSE 700
    LOW 0
    PAUSE 1300
    HIGH 0
    PAUSE 600
    LOW 0
    PAUSE 1400
    '10 sec
    '1 minute
    LOW 0
    PAUSE 3200
    HIGH 0
    PAUSE 2000
    LOW 0
    PAUSE 6500
    HIGH 0
    PAUSE 8700
    LOW 0
    PAUSE 4400
    HIGH 0
    PAUSE 4000
    LOW 0
    PAUSE 8000
    HIGH 0
    PAUSE 500
    LOW 0
    PAUSE 500
    HIGH 0
    PAUSE 5000
    LOW 0
    PAUSE 6000
    HIGH 0
    PAUSE 700
    LOW 0
    PAUSE 2000
    HIGH 0
    PAUSE 500
    LOW 0
    PAUSE 800
    HIGH 0
    PAUSE 800
    LOW 0
    PAUSE 2000
    HIGH 0
    PAUSE 800
    LOW 0
    PAUSE 3600
    '2 minute
    ' ....etc, etc, etc,[noparse][[/noparse]
    LOW 0
    PAUSE 20000
    '20 sec
    '7 min
    LOW 0
    PAUSE 60000
    PAUSE 35000
    '35 sec
    GOTO fan1


    The fan is timed to mimic the speech from the DVD player by inflating a head shaped sculpture. I would like to have two fan sequences, one 'slouchier', and the other more 'perky', or one having a higher proportion of LOW state to the other, both sequences necessarily being the same 7'35" long. The fan state will be chosen via the toggle switch, which for simplicity's sake could be inactive when the basic stamp is on, that, or restart the whole process, whichever is easier.

    Now, the above code, if you can call it that, represents about 90% of my knowledge of pBasic, so please forgive the following inevitable syntax picadillos, but i would imagine the code for the toggle UI to look something like this or express this basic idea. Assume the toggle switch connects 5v to either pin 1 or pin 2 and is only relevant when the basic stamp is off.:
    if Pin 1 HIGH and Vss LOW
    then GOTO fan1:
    if Pin 2 HIGH and Vss LOW
    then GOTO fan2:

    Thanks
  • revrev Posts: 27
    edited 2010-03-30 21:30
    Ok, well this project worked pretty well, although it does behave differently when there is 110 V @ 1 A running through the isolated side of the solid state relay, which is designed to control up to 10A @ 220V. Any ideas?

    Also, I am interested in interfacing the BS2sx with a time keeping chip, (the 555?, or wht ever works) for the next project, wich will involve 5 dvd players, all of which need to be periodically triggered over the course of up to a few hours.

    As Mike pointed out earlier, the BS2sx doesn't have enough I/O pins to control all of the buttons on 5 dvd players, some kind of matrix type conrtol, darlington array etc. is in order. There is more money in the budget for this one, and it all needs to be controlled by IR, but only to turn it on and off. Theoretically i could use more than one stamp, if necessary.
Sign In or Register to comment.