http://www.perlmonks.org?node_id=936784


in reply to Re^6: Win32::SerialPort v. New computers
in thread Win32::SerialPort v. New computers

one of my pumps spins for a fraction of a second. This does not happen with the native RS-232 serial port. I fear the win32 device may have been infected with a certain virus.

Virus: Unlikely.

I think the adapter chip emits some noise on power-up. The RS-232 to RS-458 converter converts that noise to properly formated signal. And finally, the process control system misinterprets that as pump start / pump stop commands. The on-board RS232 COM port probably generates less noise, or has some extra hardware to keep the output lines on a sane level until the chip has reached stable conditions.

Note that USB ports can be powered off by software. This is not implemented in all USB ports, but in some of them. If you connect to an on-board port, try a different port. If you connect to an add-on card, try an on-board port. If you connect to a hub, try connecting directly to the computer. If not, try going through a hub. Look at the Windows device property pages. Some Windows versions can automatically shut down unused ports to save energy. Disable that feature, if enabled.

Other ideas:

UPDATE:

There is a standard for detecting devices connected to the COM ports. It toggles the handshake lines several times and waits for the device to identify itself by toggling other handshake lines and / or sending some characters at 1200-7N1. Windows seems to use this standard. The RS232-to-RS485 converter does not convert the handshake lines, simply because RS485 does not have handshake lines. How it responds to Windows toggling the handshake lines is not defined. If Windows is convinced that it has found a device because of the handshake lines response, it may send some identification commands to the RS485 device, something like ATI or AT+FCLASS for a modem. That bytes may switch on and off your pump, reliably and every time Windows decides it is time to test for a new PnP serial device.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
  • Comment on Re^7: Win32::SerialPort v. New computers

Replies are listed 'Best First'.
Re^8: Win32::SerialPort v. New computers
by hennesse (Beadle) on Nov 10, 2011 at 17:47 UTC

    Alexander,

    Brilliant work on the PnP - but the cause was actually a virulant agent: ME

    I originally set this system up under FreeBSD, and had no such problem. When I converted it to run on a Win32 platform (with tremendous help from BrowserUK and many others) I did most of the work in the office, only occasionally checking it out in the lab/production environment. I did hear some unusual noise, but couldn't identify it, and dismissed it as something unrelated. It was only when I started fooling with the USB->RS-232 converter that I positively identified the noise as the "hot liquor pump" starting up and then immediately turning off.

    While there was no ill effect, this condition just shouldn't happen, and I was (wrongly) convinced that it had something to do with the USB. I went back to the straight serial port and it still happened. I did have a ground-loop, and as you suggested, untied the RS-485 ground from the RS-232 ground. Still happened. After working through the PnP document, I started thinking - there is no way that Windows, or any kind of noise, could send an ASCII sequence of #9SB08 with the correct 2-character checksum appended.

    I finally realized that the culprit could only be ME, and after some searching, my face turned red with embarrassment.

    It turns out I had left an artifact in one of my threads while testing Thread::Queue communications - and it was turning the pump on. While my digital input/output PLC is configured to start or reset with all outputs off, my software initialization sequence explicitly turns each output off - just to make sure. So I was turning it on in one thread, and my init sequence in another thread was immediately turning it off - just long enough for it to make a brief noise.

    Thank you for all your help.

    Dave

      I finally realized that the culprit could only be ME, and after some searching, my face turned red with embarrassment.

      A friendly tip, make sure to vocalize these moments, it helps your blood pressure :)