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.
Using the following command:
C:\>serial_ringer port=com12 loop=0 on=200 off=200 portdelay=0
Attempting the opening of port: com12
switching on for MilliSeconds: 200 at: 27/11/2016 19:53:24
switching off for MilliSeconds: 200 at: 27/11/2016 19:53:24
switching on for MilliSeconds: 200 at: 27/11/2016 19:53:24
switching off for MilliSeconds: 200 at: 27/11/2016 19:53:25
...
i get the signals DTR (yellow trace) and RTS (blu trace) with the amplitude shown in the right
and the frequency close to 2,5Hz as a result of 1/(0.2+0.2)ms
View attachment upload_2016-11-27_19-55-14.bmp
the following shows that the DTR anticipates the RTS of nearly 16ms:
View attachment upload_2016-11-27_20-12-37.bmp
As soon the command start to activate the serial port, there is a first unwanted short pulse, that anticipate of 2sec
the DTR and RTS as shown here:
the portdelay=0 option seems to change the position of the pulse (shorted then 2seconds but is not able to eliminate it completely).
View attachment upload_2016-11-27_20-56-3.bmp
Another useful thing is that i can get n independent signals if i connect n serial USB-RS232 converter to my PC.
I noticed that if i redirect the output of the command to a file, the log messages are no more visible on the screen.
It i s possible to get the redirection and also see the log messages on the screen ?
 

Attachments

  • upload_2016-11-27_19-54-52.bmp
    16.9 KB · Views: 118
Hello Dr_Doggy,
i am courius about the function of the portdelay option. How it works and how influences the DTR/RTS output ?
 
in code first one switches then the other, just like that, then it waits for the system clock to provide the next time interval

Code:
  private static void runloop()
  {
  if (!port.IsOpen) { port.Open();if(debug){ Console.WriteLine("Attempting the opening of port: " + portnum);} Thread.Sleep(portdelay); }
  DateTime now = DateTime.Now;
  port.DtrEnable = true; port.RtsEnable = true;
  if (debug) { Console.WriteLine("switching on for MilliSeconds: " + ontime + "  at:  " + now); }
  while (DateTime.Now < now.AddMilliseconds(ontime)) { }

  now = DateTime.Now;
  port.DtrEnable = false; port.RtsEnable = false;
  if (debug) { Console.WriteLine("switching off for MilliSeconds: " + offtime + "  at:  " + now); }
  while (DateTime.Now < now.AddMilliseconds(offtime)) { }
  }

I think now though we should talk briefly about your application, what exactly are you doing, switching a relay so fast will exhaust its life quickly, also it maybe a better idea for you use a separate micro controller to do the work and the serial terminal program to instruct it... if you need more accurate timing?
 
Yes,
here i post a drawing of the simple circuit i have assembled.
The purpose is to supply a square wave or other signal, time controlled (with very long on /off duty cycle),
to a simple counter (the DUT) that i need to test in these conditions.
I apologize for the hand written drawing, i do it now, whlie i listen to the clicks of the bistable rele' Finder 26.01.
The same job, should be carried on by an optocoupler (an opto-triac) in place of the rele', and in a second time i will modify
the circuit: now i need to see if it works or not, and the rele' was ready available.
All this "benchtest" is possible thanks to your Serial_Ringer.
The on period i used is 1sec (on=1000) and the off should be 15min so off=900000 so the rele' should not be stressed so much,
in any case i think will be replaced with an optocoupler or similar component.
So the DUT is driven for 15min with the square wave generator and for 15min no.
The timing is not required to be very very precise, but these long periods of time are difficult to obtain in the analog world.
And programming is not my craft (til now).

upload_2016-11-28_16-26-13.png
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top