MCU/PLC

I am wanting some info on interfacing C++ with either a MCU or PLC. Basically I want to use a GUI to get info, use the info to either control a circuit or program a chip to control the circuit.I've done some googling and haven't found much. Any help would be appreciated.
just use interfaces available on pc and mcu like: usb, ethernet and serial port (most current motherboards doesnt have them in background but still has pins for serial communication).
Last edited on
That's another question I have. Where can I look up comands for serial data out using USB or Ethernet? Can I send serial data out straight from C++?
For USB you either use a chip with dedicated hardware interface or simulated inside the chip with software called a "bootloader" or just use a simple USB to serial converter. You can't communicate via USB without a driver, usually supplied with the MCU.

For serial just use it like a regular file, so every C or C++ function you know will work with it. If you need fancy things use operating system APIs directly. No driver will be needed.

For ethernet device just communicate with it like a regular network interface, using it's IP address. No driver needed, but you must correctly get device IP or MAC address first in your PC application. Another device, like a router will be required. Advantage: you can control it remotely :
Thanks very much for the replies. Can you point me to some reference material? Like the comands for outputting serial data from C++.
Use fopen/fwrite/fclose as you use a regular file.

Use something like /dev/ttyS0 if you are using Linux or COM1 for windows. For more fancy stuff use operatng system APIs directly:
http://www.codeguru.com/cpp/i-n/network/serialcommunications/article.php/c5425/Serial-Communication-in-Windows.htm
http://msdn.microsoft.com/en-us/library/ff802693.aspx
http://www.codeguru.com/cpp/i-n/network/serialcommunications/article.php/c2503/CSerial--A-C-Class-for-Serial-Communications.htm


THere should be similar libraries for Linux too.


On the MCU side there should be a USART interface and a ready available library that came with your embedded compiler for you to use.
Last edited on
Much appreciated!
Topic archived. No new replies allowed.