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.

A signal from a PC

Status
Not open for further replies.
Hi Ron,
Nice little program. I have just tried it on a system running XP and it works fine with one of the cheap FTDI usb to serial modules that are sold on ebay using the FT232RL chip. All 3 inputs and both outputs work. I first tried on my W7 system but it did not install. This was probably because I did not have VB installed on that system. The only program I have written using VB gave me a .EXE file that seems to run without having VB installed.

Les.
 
After some tests, i decided that the Task scheduler of Windows is not a reliable tool . Crontab, in the Linux environment is a complete different story: robust and reliable.
But i need to use MS Windows.
So i try the DOS "mode" command, to manage the DTR and RTS control signals of my serial port.
When i use:
>mode COM6: dtr=on
i see a LED on the DTR blinking two times for a short period.
>mode COM6: rts=on
i see a LED on the RTS blinking two times for a short period.
what is the reason for these two pulses ?
How can i get a single pulse ?
 
The only program I have written using VB gave me a .EXE file that seems to run without having VB installed.

Way back when I messed with VB 6.0 writing an executable wasn't all that difficult but the systems it ran on did need to have what was called the VB Runtime installed. Eventually I want to remember all of the VB Runtimes were incorporated into Windows. When writing in VB later it was just a matter of using the package and deployment wizard. I want to also mode COM6: dtr=on the MS Comm component went away with Visual Basic 7.0 as things moved along into what Microsoft called Visual Studio. Been going on four years since I have even looked at anything code, since I retired. Still have some books laying around.

Eric at one time had some great code I believe he wrote in VB 5.8 for using the old Parallel Port (LPT Port). That if I recall was available somewhere on these forums. Really good stuff Eric wrote.

Martino, glad you found the little program interesting. Initially it was part of an idea that if one of the inputs received a logic 1 input (high). The system would send me a text message on my cell phone. It actually worked but while I was muddling along I accidentally had my Send under a timer. I sent myself over 100 text in a matter of seconds. :)

Ron
 
if you know programming languages you could write a Visual Studio app that runs as a "windows service", they work even when you are not logged on. they have always been reliable for me and even recover after brownouts.
I like VS over VB they way they use objects for everything vastly simplifies things... after I learned the difference between objects, parameters and functions.. PLus! i have plugins to use VS for programming arduino and android now too! I highly recommend!

OR else

may I suggest the belkin Wemo, it has on board scheduling and works great on my android, but it may not suit the application you are switching... also im not sure if they have windows software yet, maybe there is a close relative near by, or maybe the scheduler is adequate, (?)
 
Hello Dr_Doggy
i take in consideration your suggestion about VS for the time when I will begin to study programming.
About the Belkin Wemo, it is interesting but not suited for the kind of switch i need now:
something like this:
**broken link removed**
But i still need to get a RTS (or DTR) stable for some seconds when i want.
 
unfortunately, idk too much about dos commands, except the terrible flashbacks i have of trying to just get the cdrom to work, or switching paths. so i cant help with that.

Again as an alternative to task scheduler i recommend running as a service, that would mean program runs in the back ground all the time even when not signed in to windows ... you can do this with any exe using 2 files called instsvc and strtsvc from the "windows resource toolkit" and and a few command prompt instructions required to install...
doing this would also mean you need to adjust or rebuild the prebuilt vb6 program to include auto serial connect, as well as time tracking and parameters to switch the data bit at your specific times ... and to run as console application with privileges.
I could be wrong but it may be difficult to find custom code to meet custom requirements.

Also what are the requirements for switching times, ie.. when/how long?
 
For my tests, i'd like do drive ON the RTS (or DTR) for n seconds and OFF for m seconds.
If this is not possible, or too complex, a pulse of some seconds with RTS ON should be ebough.
 
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 ?
It may be worth checking the MB for a D9/ribbon connector, I picked up some Asus fairly high end MB's, and they had the 10pin COM port connector on board.
Max.
 
what I have done is a quick little program in my free version of visual studio 2012 express that will do what you want .... with about 20 lines of code
it is setup for default 9600 baud, Port6, 5second on time, 5second off time

in the main folder is the exe, if it doesn't run you may need the installer in the publish folder, for those who like source code it is in the project folder

if you want to change parameters to something else when launching then use this syntax(all small letters in parameters!)
Serial_Ringer.exe on=5000 off=5000 baud=9600 port=com6

*note you need to call the port: com
on time and off time are measured in milliseconds

if that works for you then all you need to do is install as service , as mentioned above, i can help if needed, i did it once before! just not sure on if/how you can add parameters when running as service...
 

Attachments

  • publish.rar
    598.9 KB · Views: 127
Sorry for the delay,
i executed the command:
Serial_Ringer.exe on=5000 off=5000 baud=9600 port=com6
on the directory where i placed the .exe and it works as you stated:
C:\publish>Serial_Ringer.exe on=5000 off=5000 baud=9600 port=com6
Attempting the opening of port: com6
switching on for MilliSeconds: 5000
switching off for MilliSeconds: 5000
switching on for MilliSeconds: 5000
switching off for MilliSeconds: 5000
switching on for MilliSeconds: 5000
switching off for MilliSeconds: 5000

until i give a Ctrl-C to stop it. Also with differents on/off periods.
I can see the DTR and RTS LED on a little RS232 tester, go up together during the on period.
To get a better time precision, it is possible:
- avoid the message "Attempting the opening of port: com6" and related delay ?
- put a parameter like "n=x" to stop the iterations after x cycles (if x=0 it never stop, as it does now) ?
Thank you for this program.
 
sure i can provide option to turn output off , we will keep it though for debug purposes if we need it later, not likely that was cause for inaccurate time, I will tie it in to the system clock for better resolution, but i will keep units in ms to help you be able to tweak it

Also i should mention the parameters i listed are default.. so if you dont need to change it there is no point to write it,...
ie...
Serial_Ringer.exe <---- this will leave the parameters at default: on=5000 off=5000 baud=9600 port=com6
Serial_Ringer.exe port=com7 <-- this will switch to com7 but still 9600 baud and 5sec intervals
Serial_Ringer.exe port=com7 on=10000 <--- this will change com & on time, note they don't need to be in order
 
I much appreciate your work.
About the "n=x" option i mean something liker this:

C:\publish>Serial_Ringer.exe on=5000 off=5000 baud=9600 port=com6 n=1
Attempting the opening of port: com6
switching on for MilliSeconds: 5000
switching off for MilliSeconds: 5000
exit here.
C:\publish>
 
ok this should do it,
also you dont need to put it in publish folder if you dont want, can do anywhere you want really, but c:\somthing_simple\ is best for less complication when it comes time to running as service

I'v added 3 more parameters, with the following default values:
n=0 <--- number of iterations, 0=infinity
debug=true <--- Shows status' in the console
portdelay=2000; <-- sometimes serial port doesnt open right away, this gives the port time to respond before retrying, if 2s is too much feel free to turn it down
 

Attachments

  • publish.rar
    564.7 KB · Views: 127
It works.
Now i need to buy a NPN transistor and some components to drive a bistable relay to get the desired function, using your program in a batch DOS script.
This should be a simple job i should be able to do.
I need a few time and let you know.
VisualStudio 2012 express seems a great tool (or toolbox).
Thank you very much,
 
np! yes i very much enjoy VS, not only can i do windows apps but also android and arduino apps with just the one compiler(ver2015 though)
 
After some time, i try to connect a relay with a BJT to the serial port, i used again the program, using Windows7 but now it works only without the on off arguments:

C:\Prove\publish>serial_ringer.exe on=3000 off=3000 baud=9600 port=com9

Eccezione non gestita: System.FormatException: Formato della stringa di input non corretto.
in System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
in System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
in System.Convert.ToInt32(String value)
in Serial_Ringer.Program.Main(String[] args)

If i run it without the options on=3000 off=3000, it works fine.
 
oops found it!
I had to change the parameter for n,
it is now called:
loop
 

Attachments

  • publish.rar
    606.8 KB · Views: 131
Many thanks Dr_Doggy
now it works with parameters on and off but is not using the n= param.
It works forever, without look at the n value.
I tested it in MS Win7-Pro and MS Win10-Home (both 64bit).
 
Status
Not open for further replies.

Latest threads

Back
Top