Connect with us

Magnet movement -> com port type thing.

Discussion in 'Electronic Basics' started by Tim, Sep 7, 2003.

Scroll to continue with content
  1. Tim

    Tim Guest

    Hello.

    I want to be able to detect when my door opens, (on my computer), so I
    can do various fun things (switch workspaces :)

    I've got a strong flat magnet, so I stuck (well, will stick) it to the
    bottom of my door, and then I got some thin wire from a motor, and made a
    small sensing coil, so that when to door opens, the magnet goes over the
    coil, and induces a small current. And then somehow I get this to my
    computer.

    But how? I'm new to electronics... well, I know lots of physical law type
    things (v=ir, etc), but not how to apply them to make actual complicated
    ciruits. I'm guessing I use transistors or something, to amplify the
    signal, and then convert it to a digital signal (how?)...

    The current/voltage from the coil is very small...


    +5V O--------,
    |
    __________|/ <--- transistor.
    C 8 |\
    O 8 |__________ COM data pin
    I 8
    L 8_______________________
    |
    0V O--------`

    That's what my inexperienced brain is thinking.


    I'm guessing it wouldn't work though... Any ideas?
     
  2. Tim

    Tim Guest

    Also, IRC channel anywhere? If not why not? :)
     
  3. Chris

    Chris Guest


    Hi, Tim. Using a coil to drive a transistor probably won't work very
    well, because the moving magnet only induces current when it's moving,
    and it's a small current at that.

    It doesn't look like you'll hurt anything trying your idea. However,
    if you want something that works, you might want to use your magnet to
    close a reed switch (think door security switch), and then read that
    switch on an RS-232 port. If you've got a port to spare, you might
    want to try this -- it's worked for me.

    Reed Switch

    _/ 7 (4)
    .---o/ o----------oRTS
    |
    |
    | 8 (5)
    |------------------oCTS
    |
    |
    | ___ 4 (20)
    '---------|___|----oDTR

    10K


    created by Andy´s ASCII-Circuit v1.22.310103 Beta www.tech-chat.de

    The pin numbers are for a DB-9 connector, and the pin numbers in
    parentheses are for a DB-25.

    This QBASIC snip will work to read the switch, if you've got it
    connected to COM1...

    OUT &H3FC, 1
    A% = INP(&H3FE)AND 16

    If the footswitch is on, A% = 0
    If it's off, A% = 16

    It seems a little extravagant to use a whole COM port to read one
    switch, but if you've got it to spare, go for it. Also, as an extra
    added bonus, the RS-232 port pins are generally a little less
    susceptible to ESD because of built-in protection on the ICs.

    Good luck.
    Chris
     
  4. Tim

    Tim Guest

    Someone else also emailed me, suggesting a reed switch, so I've ordered
    one (two actually) from maplin, and last night I spent ages trying to get
    a switch to work via the parallel port.

    I was trying to use D0->Gnd in reverse mode (as someone suggested on
    IRC), but this morning I realised that wouldn't work (as D0 is 0V in
    reverse mode ... I think) so shorting it to ground wouldn't change D0...
    So this morning I changed it to what I was originally going to do...

    D0 -> switch -> Ack. And then read ack, and it works like a charm.

    I measured the current, and if ye old meter is right it is 1.4 mA ..
    which means I dont need a resistor... right?

    Anyway I wrote some code to execute programmes when it closes and when it
    opens... Now I just have to wait for le reed switch...

    Its great I tell you! I can switch workspaces from doing stuff I
    shouldn't, to one full of work, just my closing a switch! Aye!

    Can you see the applications? :)))
     
  5. CFoley1064

    CFoley1064 Guest

    Can you see the applications? :)))

    It's a whole new world.

    For interfacing through serial/parallel/USB ports, see Jan Axelson's Lakeview
    Research website, and also Serial Port Complete/Parallel Port Complete/USB Port
    Complete books.

    http://www.lvr.com/

    There's enough on the links on the website to keep you busy for a while.

    Good luck.
    Chris
     
  6. Tim

    Tim Guest

    Ahh, how come google doesn't know about this? :) Thanks.
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-