Controlling 5 digital lines from a PC - Page 1
Forum section: electronics / beginners

author: Fulcrum
author_rank: Regular Contributor
timestamp: August 20, 2016, 06:53:19 pm
content: Hello everyone.I have a fairly trivial problem that I am not sure what the best solution to is. I need a way to control 5 digital lines with a PC. They are not meant to transfer data, so bitrates are irrelevant. I simply need an easy way to pull the individual lines low or high, preferably controlled by USB. My only requirement is that it is stable. These five pins will be resetting a host of arduinos in case they halt, and therefore the mean time between halts of the host must naturally be longer than that of the arduinos... Therefore I do not wish to use another arduino as the host. Any suggestions?

author: jesuscf
author_rank: Frequent Contributor
timestamp: August 20, 2016, 07:18:37 pm
content: One of those little USB to Serial/TTL boards/cables with an FTDI chip on it will do it easily. I have done something similar with the FT232RL and FT230XS configured in bit bang mode via ftd2xx.dll.

author: Fulcrum
author_rank: Regular Contributor
timestamp: August 20, 2016, 08:21:13 pm
content: Quote from: jesuscf on August 20, 2016, 07:18:37 pmI have never before fiddled with dll files - they are black magic for all I'm concerned. However if you have a guide you can direct me to I'm not going to turn it away. Certainly would be a simple and straightforward method.

author: Ian.M
author_rank: Super Contributor
timestamp: August 20, 2016, 08:51:43 pm
content: Seehttps://www.eevblog.com/forum/beginners/another-must-read-for-beginners/Anyone who believes they can improve reliability of a MCU by monitoring it with a PC and resetting it over a USB bus is suffering from a severe case of rectocranial inversion!

author: Kilrah
author_rank: Unknown
timestamp: August 20, 2016, 09:07:23 pm
content: Agreed. Take something easy, simple and reliable and use a bulky super complex thing of dubious reliability to monitor it?Yes another Arduino to monitor (or whatever other similar board) would be a lot more appropriate.

author: Monkeh
author_rank: Super Contributor
timestamp: August 20, 2016, 09:12:16 pm
content: Quote from: Fulcrum on August 20, 2016, 06:53:19 pmWhy would they halt?Why are their own watchdog timers not good enough?

author: bitslice
author_rank: Frequent Contributor
timestamp: August 20, 2016, 09:12:35 pm
content: Arduino's have a watchdog timer, surely employing that would be more efficient?edit: ninja'ed by post above

author: Aodhan145
author_rank: Frequent Contributor
timestamp: August 20, 2016, 09:15:46 pm
content: Is arduino as far as you have gone with micro controllers? You might have to learn a bit more, e.g how to use registers.

author: bitseeker
author_rank: Super Contributor
timestamp: August 20, 2016, 09:16:13 pm
content: If you must use a PC, a USB to Serial TTL module that supports all the standard signaling lines will work as you describe. However, I'd use the simpler Arduino to monitor and reboot the significantly more complex and unreliable PC when it hangs.Normally, a watchdog circuit is used to monitor the operation of a microcontroller- or microprocessor-based system and reset it if the expected response is not received within a given time period.

author: newbrain
author_rank: Super Contributor
timestamp: August 20, 2016, 09:31:30 pm
content: Heed the good advice others have given about watchdogs and reliability.If you really have to do this, did you check whether your PC has got a parallel port?A good percentage of motherboards still have it, at least the header, even if that's not brought out on the back panel.

author: jesuscf
author_rank: Frequent Contributor
timestamp: August 20, 2016, 10:10:16 pm
content: Quote from: Fulcrum on August 20, 2016, 08:21:13 pmhttp://hackaday.com/2009/09/22/introduction-to-ftdi-bitbang-mode/

author: Fulcrum
author_rank: Regular Contributor
timestamp: August 20, 2016, 10:36:17 pm
content: I'd quote you all if I could! Thanks a lot for your replies. My inexperience with microcontrollers is really on full display here...Well, one learns as long as one lives. I will definitely implement a watchdog timer in addition to the reset system I described in the first post. I consider this topic resolved.

author: Monkeh
author_rank: Super Contributor
timestamp: August 20, 2016, 10:38:05 pm
content: If you have the watchdog set up, why would you want to hook all of them to a massively complicated system which is vastly more likely to go wrong and end up holding all your targets in reset?Not to mention massively increasing the likelihood of external noise causing unintended resets.

author: Ian.M
author_rank: Super Contributor
timestamp: August 20, 2016, 10:55:26 pm
content: Its not impossible to implement a reliable remote reset for 1 MCU with good noise immunity - e.g. a 4N35 optocoupler at the MCU, pulling down the /RESET pin with a 150R resistor across the optocoupler LED to guarantee its off state, so that its input can driven by a digital 4-20mA current loop run over twisted pair. However implementing monitoring and control for multiple MCUs, improving on the reliability of a properly implemented on-chip or local watchdog is non-trivial. Have you considered the risk of a false-positive, when trying to detect if an individual remote MCU has crashed?

author: bitseeker
author_rank: Super Contributor
timestamp: August 20, 2016, 11:58:08 pm
content: Quote from: Fulcrum on August 20, 2016, 10:36:17 pmNo need to palm yourself. This is the Beginner forum, and that's what it's here for. We're happy to help.

author: John_ITIC
author_rank: Frequent Contributor
timestamp: August 23, 2016, 12:33:45 am
content: Quote from: Fulcrum on August 20, 2016, 08:21:13 pmhttps://www.amazon.com/Programming-Windows%C2%AE-Fifth-Developer-Reference/dp/157231995X/ref=sr_1_fkmr0_3?ie=UTF8&qid=1471912332&sr=8-3-fkmr0&keywords=petzold+DLL#reader_157231995XSearch for "DLL": Chapter 21.

author: hamster_nz
author_rank: Super Contributor
timestamp: August 23, 2016, 12:40:31 am
content: Quote from: Monkeh on August 20, 2016, 10:38:05 pmMaybe as a beginner he/she is expecting their Arduino code to be a bit flakey, and with an external PC they can at least SSH/VNC/RDP onto it and do something about it remotely.

author: Aodhan145
author_rank: Frequent Contributor
timestamp: August 23, 2016, 12:19:40 pm
content: This might not be the best solution. Post your code and we could make it more stable.

author: Pack34
author_rank: Frequent Contributor
timestamp: August 23, 2016, 01:23:38 pm
content: The quickest and dirtiest way to do this would be to change your architecture slightly to have a single Arduino interface directly with your PC. Then send it a command over the COM port to command the rest of your system.