• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

A signal from a PC

Status
Not open for further replies.

martino

Member
I'd like to drive a rele on then off at certain times, via a signal coming from a PC, scheduled via the task scheduler.
How can i do this ?
 

dr pepper

Well-Known Member
Most Helpful Member
An arduino is a good start, do a google and find out some more.
Or if your computer has a parallel port that could be used.
 

spec

Well-Known Member
Most Helpful Member
This is along the same lines as Nigel's suggestion and, while it may seem like gross overkill, the Arduino Nano microcontroller is small, cheap and easy to use. All you would need is a trivial bit of software downloaded to the Nano.

In case you have never programed an Arduino before, it is dead easy: just download the free integrated development environment (IDE) on to your PC and use the IDE to program your Arduino, over the USB interface. Your PC will even power the Nano via the 5V line of the USB interface. It could not be easier.:)

Once that is done, you can shut down the IDE and send commands down the USB interface from your PC to command the NANO. Then use one of the many Arduino I/O pins, parallel and serial, to control what you like. Incidentally there is a wide range of cheap interface boards (called shields) for controlling motors, relays, etc etc.

spec
 
Last edited:

Les Jones

Well-Known Member
Most Helpful Member
If you have a serial port (Com port) you could use the DTR (Modem control signal) to control a relay. If you don't have a serial port you could use one of the FDTI USB to serial adaptors such as this one. Yet another way would be to use an ESP8266 wifi module and you could control it from your web browser.

Les.
 

Nigel Goodwin

Super Moderator
Most Helpful Member
This is along the same lines as Nigel's suggestion
Is that a different Nigel?, because I haven't posted here :D

However, I concur that the easiest way (in the light of no information about the computer been used, and that ports other than USB are rare these days) would be to use a Nano - or any other microcontroller of course, but a Nano is cheap and easy.
 

spec

Well-Known Member
Most Helpful Member
Is that a different Nigel?, because I haven't posted here :D
oopps sorry Nigel & Dr Pepper

IHowever, I concur that the easiest way (in the light of no information about the computer been used, and that ports other than USB are rare these days) would be to use a Nano - or any other microcontroller of course, but a Nano is cheap and easy.
I know you have a load of experience with micocontrollers so that is good news. Increasingly, I am finding that, even the most simple of functions, is best done with a microcontroller, either chip level but more often than not, board level.

spec
 

AnalogKid

Well-Known Member
Most Helpful Member
A USB connection to an Arduino
The serial port DTR signal
Any parallel printer port data pin
WiFi app
...
None of these address the central part of the question. How do you create a program or what program can you buy or download and install, that the Windows scheduler runs to create any of these signals. With DOS and QuickBasic this was 10 lines of code that compiled to a standalone COM or EXE file that any scheduler could run. Nowadays, ???

ak
 

spec

Well-Known Member
Most Helpful Member
A USB connection to an Arduino
The serial port DTR signal
Any parallel printer port data pin
WiFi app
...
None of these address the central part of the question. How do you create a program or what program can you buy or download and install, that the Windows scheduler runs to create any of these signals. With DOS and QuickBasic this was 10 lines of code that compiled to a standalone COM or EXE file that any scheduler could run. Nowadays, ???

ak
This is so trivial that I don't believe the OP could be asking that question.:)

spec
 

AnalogKid

Well-Known Member
Most Helpful Member
You know I respect your work, but that answer is so useless I can't believe you killed electrons to post it.

And no, those electrons aren't converted to another form of energy. They are dead, gone, tango-upstart, lost to physical reality, never to spin again, all thanks to you. They are ex-electrons.

ak
 

spec

Well-Known Member
Most Helpful Member
You know I respect your work, but that answer is so useless I can't believe you killed electrons to post it. And no, those electrons aren't converted to another form of energy. They are dead, gone, tango-upstart, lost to physical reality, never to spin again, all thanks to you. They are ex-electrons.
ak
I am not interested in respect or any other emotions. Please stick to technical matters- your post makes no sense. It is just reaction. Try ti be objective. I am making a perfectly rational and sensible statement that writing a routine to control a port on a PC is trivial. Either you agree with that or you don't. So you have three options either agree disagree or be quiet.

spec
 

martino

Member
Thank you all,
after some googling, i find the Windows CLI command:
mode comx rts={on|off|hs|tg}
that should set the RTS "Request to Send" control circuit, on, off, handshake or toggle.
The last two options are not well explained.
The command works only if the PC has a native serial port or also with (more common today) USB to serial adapter connected to a USB port of the PC ?
 

AnalogKid

Well-Known Member
Most Helpful Member
It works much better with a native port. Don't know about today's parts, but 4-5 years ago the USB-to-serial converters just plain sucked.

ak
 

spec

Well-Known Member
Most Helpful Member
Thank you all,
after some googling, i find the Windows CLI command:
mode comx rts={on|off|hs|tg}
that should set the RTS "Request to Send" control circuit, on, off, handshake or toggle.
The last two options are not well explained.
The command works only if the PC has a native serial port or also with (more common today) USB to serial adapter connected to a USB port of the PC ?
You were right AK.:)

spec
 

spec

Well-Known Member
Most Helpful Member
OK . . . . . about what?
You were right when you said that the OP wanted to know how to do the software in his PC. And I was wrong in saying that I did not think that was the case.:)

spec
 

Reloadron

Well-Known Member
Most Helpful Member
This is a link to something I wrote a long time ago. It is a tiny program written to test the RS232 Comm Port. The old RS232 Port allows three digital inputs and two digital outputs. This was originally written for Windows XP but has run on everything including Windows 10. My old RS232 card does not work with Windows 10 but I have an old Keyspan USB to RS232 adapter I tried and it actually works. The little program looks like this:

Comm 1.png

The user selects a Comm Port from the drop down menu:

Comm 2.png

On my system it was Comm 4. Once a port is selected the user would click Open Port to open the selected port.

Comm 3.png

At this point the black Input displays will turn Blue for Low inputs and Green if any of the inputs go High. Those are the CTS, DSR and DCD Inputs. The user can also click the DTR and or RTS Outputs driving those pins High or Low. Checking or Un Checking the output boxes controls the two output pins:

Comm 4.png

There is really not much to it and it could easily be modified to do whatever someone wants including start and load when the system boots and open minimized when it loads. It was originally written in VB 6.0 (Visual Basic). There may be a way to open the MS Comm just using VBScript but I am not sure how to go about it as it has been a long, long time. Anyway, if you have any interest feel free to download the program and experiment with it. I can tell you this. With the Keyspan USB to RS232 adapter logic levels of 0 to 5 Volts will toggle the inputs. The outputs swing from about -5.0 Volts to 5.0 Volts and could easily drive a transistor. Been a long time since I used any of this stuff or wrote any code at all. The program itself could likely be modified to do whatever anyone wants to do using the DIO of a RS232 port.

Ron
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top