How to control a relay with a PC


Results 1 to 6 of 6

Thread: How to control a relay with a PC

  1. #1
    Registered NeoMoses's Avatar
    Join Date
    Apr 2003
    Location
    Prolly' in the Shop :)
    Posts
    292
    Downloads
    0
    Uploads
    0

    Default How to control a relay with a PC

    I need help. I'm trying to do some development on a project, and I would like to be able to energize a circuit with a PC or other device that would give me an adjustable and repeatable on/off signal. For example, I may want to turn the circuit on for 1 minute, then off for 5 minutes, or I may want to have the circuit on for 45 minutes then off for 30 minutes, depending on the circumstances.

    The on/off will be controlled with a relay. That part I'm comfortable with. What I'm not comfortable with is how to control a PC port from windows to send the on/off signal. I don't care if I use a serial, parallel, or USB port.

    Are there any readily available programs to send a signal like this? Or am I gonna have to find someone who is comfortable with C or C++ to help me with this? Any help would be much appreciated.

    I'm not dead-set on using a PC to control this, so if there is another method of making a timer that has the needed flexibility, I am all ears.

    Similar Threads:
    My name is Electric Nachos. Sorry to impose, but I am the ocean.
    http://www.bryanpryor.com

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)


  2. #2
    Member wms's Avatar
    Join Date
    Mar 2003
    Location
    wyoming
    Posts
    927
    Downloads
    0
    Uploads
    0

    Default

    NeoMoses,

    How about a cheap Plc, (programable logic controler)?

    That's what they are made for. To turn things on and off and time things or to sense presure or voltages, current ect....

    I don't know tons about them, but maybe someone here does.

    I also have a friend that works with this stuff for a living.
    I could ask if need be.

    Here's a quick link:http://www.thomasregister.com//Catal...1&uuid=TRGuest

    Sorry this link doesn't get you all the way to the plc's. So you'll have to navigate to them> products>plc.
    Then look at the Nano series. They have starter packages.

    Last edited by wms; 08-05-2003 at 01:07 AM.
    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)


  3. #3
    Registered bunalmis's Avatar
    Join Date
    Jul 2003
    Location
    Turkey
    Posts
    246
    Downloads
    0
    Uploads
    0

    Default

    I send simple hardware and software.

    Hardware and software use max 8 relay.
    System uses PC parallel port.
    I wrote for dos but not problem for Win 98.



    unsigned port=0x378;
    unsigned char rly0,rly1,rly2,rly3,rly4,rly5,rly6,rly7;

    void on_off()
    {
    unsigned char dat;

    dat=rly0;
    dat=dat|(rly1<<1);
    dat=dat|(rly2<<2);
    dat=dat|(rly3<<3);
    dat=dat|(rly4<<4);
    dat=dat|(rly5<<5);
    dat=dat|(rly6<<6);
    dat=dat|(rly7<<7);
    // printf("%02X ",dat);
    outportb(port,dat);
    }


    void main()
    {

    rly0=0;rly1=0;rly2=0;rly3=0;
    rly4=0;rly5=0;rly6=0;rly7=0; on_off();

    // rly0 on 1 sec
    // rly1 on 1 sec
    // rly0 and rly1 off 5 sec (relay0 2 sec on, 5 sec off)
    // loop again (relay1 1 sec on, 5 sec off)



    while(rly0==rly0)
    {
    rly0=1;on_off();delay(1000);
    rly1=1;on_off();delay(1000);
    rly0=0;rly1=0;on_off();delay(5000);
    }


    }

    Attached Thumbnails Attached Thumbnails How to control a relay with a PC-relay-jpg  
    Last edited by bunalmis; 08-05-2003 at 03:19 AM.


  4. #4
    Registered abasir's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    361
    Downloads
    0
    Uploads
    0

    Default

    NeoMoses,

    A trivial VisualBasic code could achieve what you want (unless you timing is very critical, i.e., milliseconds accuracy).

    For such things, I normally use a PIC (www.microchip.com) microcontroller (programming required). In most cases, it just need a chip and some transistors (& resistors, caps) and switches. Accuracy to microseconds and fully repeatable.

    I could offer some help on both methods. I do need to know your 'circumstances' before suggesting a solution.

    Regards

    Stupid questions make me smarter...
    See how smart I've become at www.9w2bsr.com ;-P


  5. #5
    Registered ToyMaker's Avatar
    Join Date
    May 2003
    Location
    United States
    Posts
    325
    Downloads
    0
    Uploads
    0

    Default

    NeoMoses:
    for a relatively cheap (<USD100) highly portable (it's smaller than a credit card) solution look into the BASIC Stamp controller. It has to be programmed but you could learn everything you need in a couple of hours. The manual is free online at http://www.parallaxinc.com in .pdf format.

    robotic regards,

    Tom

    p.s. I have no connection with Parallax, just a satisfied customer. I have purchased several hundred of their units over the years and only had one DOA, which they replaced over-nite free of charge.



  6. #6
    Registered NeoMoses's Avatar
    Join Date
    Apr 2003
    Location
    Prolly' in the Shop :)
    Posts
    292
    Downloads
    0
    Uploads
    0

    Default

    I think I'm gonna go with this. It's a kit that I get to put together, and it's got some data acquisition channels along with it!

    My name is Electric Nachos. Sorry to impose, but I am the ocean.
    http://www.bryanpryor.com

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


About CNCzone.com

    We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

Follow us on


Our Brands

How to control a relay with a PC

How to control a relay with a PC