Continue to Site

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.

  • 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.

using Com port for signalling

Status
Not open for further replies.

xiptron

New Member
Hi all

I am new on here and may not be in the right section, but here goes anyway.

This one is related to computers: Is there a program or application written that will produce a momentary high (assertive +12v) on the RTS (or DTR) pin (relative to the ground pin) on the com port on a PC (running XP Pro), after certain periods of time.

I need to be able to enter four sets of h/mm/ss times that, when reaching zero after counting down, cause the rts (or dtr) pin to go momentarily high, thus there will be four pulses issued as each counter in turn reaches zero. These four timings would all start together, as if the timers are all operating in parallel. The duration of the output pulse isn't critical, 250-500ms is fine.

Settings, for example, might be: Timer 1 - 00h:03m:18s, Timer 2 - 00h:08m:51s, Timer 3 - 02h:00m:30s, Timer 4 - 02h:06m:10s.

The com output pin will be coupled to an external controller incorporating a npn transistor to close a relay.

The timing needs to be started via the serial port also, possibly by grounding the DSR pin.

The initial timing start would not be related to time of day i.e can be started anytime.

Hope someone can help me or perhaps direct me to a more appropiate site for this project.

Thanks
 
I think you'd have to write code for that it might be a little too single purpose to just find code for it out there already. Are you familiar with C programming at all? It shouldn't be excessively difficult to program something like that.
 
If you can find a routine, or write one, that toggles those lines individually (then exits), you can use the Windows XP scheduling feature to execute it. There may even be DOS commands to set the DTR and DSR lines on a com port which you could execute using the XP scheduling feature to execute.
 
Thanks guys, I knew it would be a curly one, that's why there's nothing out there that I can find will do the job. The nearest are timers for irrigation purposes tec, but they are linked to time of day and don't do seconds either.

Sorrry, but I know NOTHING about programming - I'm a complete dummy in that regard.

This has been frustrating me for a long time, and until I can do it on the pc I am having to punch numbers into hardware type timers.

Beyond my original request, I also need to be able to recall about six sets of entries as they are often repeated.

Now that's really setting me apart lol!
 
If you are prepared to have your PC running 24 hours/day why not google for some "PC controlled relays" there are a lot of kits and cheap prebuilt units out there.

And there is also freeware/shareware for your PC that lets you turn the relays on and off at specific times of day. This is a very common application and is well supported by the kits and shareware market.
 
I threw the attached program file together. It has fixed time delay values of 60, 12, 90 and 16 seconds hard-coded. If the program suites you, I can modify it to have the time delay values read from a file. The timers start when the DSR input changes state. You can test it by shorting RTS to DSR. When each timer expires, a 500 ms pulse is output on DTR.

It uses the COM1 PC serial port.
 

Attachments

  • MULTIT~1.zip
    21.4 KB · Views: 183
Last edited:
Thankyou ccurtis. This seems to have promise, even though I haven't the foggiest idea of how to implement it yet. I presume it just runs by shorting the pins - is there anything else I need do?

I need to run 4 or 5 timing periods at a time, and they must sequence off each other after starting the first one.

I could put the timings in as text or code that would be good. tell me more, I am intrigued by the apparent simplicity of your program. :)
 
You can short the RTS and DSR pins together, or bring the DRS pin to +5 to 12 volts. That's all you need to do to start the timers. I suggest you run and test the program attached before going any further. Yes, I would have the program read a timing set from a text file you can create with any text editor, like Wordpad for example.
 
Well, bless my cotton-pickin' socks ccurtiss! It works great!! I can use it I think.

Here are some requests:

1. You have the times entered as seconds - can it be arranged to shows these as h:ms:ss?

2. As you have them, the timers are operating in parallel. That's ok, but a refinement for my application would be to have them sequencing i.e. T1 triggering T2 and so on. If not, I can use the parallel system ok.

3. Is it possible to have the program remain on screen after ending, with the timers resetting back at the entered values? (rather than running the script again).

4. Would it be possible to recall various "sets" of values? For example, a Timer set of 1 to 6 for one application, then another set of T1 to T6 with different values.

(I don't want to load you up with too much redevelopment of course, but I do repeat a lot of the same operations so easy recall of "sets" of times would be great.)

5. Lastly, is a Windows GUI possible? (don't hit me lol)
 
Well, bless my cotton-pickin' socks! It works great!! I think I can use it.

Here are some questions/refinements:

1. You have the time entered as seconds - can it be arranged to show these as h:mm:ss? (even if entering as seconds)

2. As you have them, the timers are operating in parallel. That's ok, but a refinement for my application would be to have them sequencing i.e. T1 triggering T2 and so on. If not, I can use the parallel system ok.

3. Is it possible to have the program remain on screen after ending, with the timers resetting back to the last entered values?

4. Would it be possible to recall various "sets" of values? For example, a Timer set of 1 to 6 for one application, then another set of T1 to T6 with different values.

(I don't want to load you up with too much redevelopment of course, but I do repeat a lot of the same operations so easy recall of "sets" of times would be great.)

5. Lastly, is a Windows GUI possible? (don't hit me lol)

Many thanks
 
Yes, I would have the program read a timing set from a text file you can create with any text editor, like Wordpad for example.


Despite my complex wish list, I could get by with just loading the time values as you described above. Can you describe how to do this with a text editor. I am anxious to get this going. Thanks so much.
 
I'll have some time this weekend to work on it. The Windows GUI is out of the question with the tools I have handy here. You probably noticed that the program hogs most of the cpu. That is the nature of the beast. I take it that is tolerable to you. The parallel system should suffice as you can simulate one timer triggering the other by setting the timers to end after any delay you want to and since the timers are started together, all at the same time. I'll do the remaining refinements.

I'll give an example text file to show how to enter the time delays for each timer. I assume four timers are enough, but more can easily be added.
 
All good. Dos is fine as I can dedicate a spare comp to running just the prog. CPU usage doesn't matter. I have wired the interface and it's all set to go. I am using a 1300E sensitive reed-relay in series with a led which closes from RTS to Pin 5. That works fine, you couldn't get a more simple interface.

Can you program it for six timers? This will give me room to add some extra commands I've always needed.

Having the displays read h:m:s lets me know at a glance how long I have to go in real time on the longest periods.

Parallel operation is ok, it's just means that if want to, say, shorten the duration of Timer 2, then I have to shorten the following timers T3, T4 etc by the same amount.

I think this will make more sense when I explain that with each timer, the countdown is always progressively longer e.g T1 3m 18s, T2 7m 56s, T3 1h 30m 45s, T4 1h 47m 34s etc. Obviously then sequencing the timers, and altering only one, avoids having to also alter the others. (Individual periods would be entered for each one, as opposed to running-totals when in operating in parallel).

Anyway, I'm happy to give your updated ver a whirl. I'll check in later . Thanks again.
 
Okay. Here you go Xiptron. Let me know how it works out for you. The txt file and the program file must be in the same directory.
 

Attachments

  • MULTI6.zip
    24 KB · Views: 110
It's working well now CC. I have installed it on an old 286 laptop as it seems to be prefer running under dos in W95. On my current XP machines the program sometimes won't load, or it'll crash or trigger on entering a filename. Not to worry.

One thing is that it won't start by connecting DSR to DTR, but will start with 9V (from a small battery) connected to DSR via a remote switch. (I found that getting it to start by connecting DSR to DTR is dependant on how the DTR interface is configured).

Abort (Control-Break) doesn't function but that's not really an issue.

For now I have to close the program and relaunch it with a new filename for my different timings. This is a bit of a pain and a refinement would be, if you're willing : ), to load a new file without having to close first. Perhaps after timing completion it could ask "Enter new filename"?

I really do appreciate your efforts in preparing the program for me CC, thankyou.
 
Last edited:
It's working well now CC. I have installed it on an old 286 laptop as it seems to be prefer running under dos in W95. On my current XP machines the program sometimes won't load, or it'll crash or trigger on entering a filename. Not to worry.

I made some improvements that may solve some of the above. It works for me in an XP cmd window. I cleaned up the counter display to make it easier to read, also.

One thing is that it won't start by connecting DSR to DTR, but will start with 9V (from a small battery) connected to DSR via a remote switch. (I found that getting it to start by connecting DSR to DTR is dependant on how the DTR interface is configured).

You need to short RTS to DSR, not DTR to DSR. Also, the timers start when a change of state is detected on DSR, so holding DSR high will not restart the timers on the next go-around. When running in an XP window there is a couple second delay from the moment a state change on the DSR pin occurs and it is passed to the program. This delay occurs when the program is first run, only. Nothing can be done. The delay is not seen again if the s key is pressed and the timers are restarted with another DRS trigger. That should do it. Of course, the battery applied to DSR will work too.

Abort (Control-Break) doesn't function but that's not really an issue.

Yeah, I see that. It only functions once the counters are running.

For now I have to close the program and relaunch it with a new filename for my different timings. This is a bit of a pain and a refinement would be, if you're willing : ), to load a new file without having to close first. Perhaps after timing completion it could ask "Enter new filename"?

Okay, done. Your welcome xiptron. I've done very little bug testing, so I leave it to you to let me know if anything else needs fixing.
 

Attachments

  • MULTI6B.zip
    24 KB · Views: 105
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top