Communicating With Arduino.
Two common ways a Computer program and Arduino interface are......
One.) The Software (Firmware) on the Arduino will“Ping”the serial port and wait for information from a specific location (file) that the U.I was used to“Post”a command to. The Arduino will require a specific command still, but that command will be stored and ready for the command that is stored on a separate file.
Two.) The Computer U.I. is used to connect to a specific port then a “Packet” is sent to that port, the Firmware (Arduino) processes specific commands and acts accordingly.
In example “One” a U.I. (User Interface) sends information to a file that the Arduino collects information from, this is great for PHP because a PHP Function does not cycle over and over like the Sketch does on the Arduino. If a command is typed or selected using a PHP / HTML form, the command can be stored someplace and recalled at the convenience of Arduino.
Keep in mind Arduino isn't very slow, it maybe slow it terms of your home computer but it's still processing information and requesting information at a very fast rate. CNC Machine-Software may function as described, however a parallel machine control software functions different, and as noted there is another way to communicate with a Logic Device like Arduino, leading to option number Two.
Option “Two” is the most common, just select the port Arduino is connected to and send it information; for accurate CNC situations option “Two” may require other server side processing, for example the information from the U.I just as in example “One” may want to use a server side language to “Post” then “Parse” the command to protect data, or, the U.I will just “Parse” from an existing file. Like a “Tap” file used with Mach3 or EMC.
Picture having a bunch of printers together, and having one computer.
All the printers have the same driver.
All printers will have to be named something else (networking) , but each action requested from every controller/ printer will remain the same.
For example say you send a number “1”to the printer with an expectation that the number sent switches something On, if the code is designed to use the number “1”is set to turn something Off, then... You get the idea.
Networking is a creation of the router:
On to the Code Examples written in PHP...
Really helpful links:
Example #2 http://arduino.cc
Please visit the following links for the two examples.
Note: This PHP covers Drop-Down boxes/ Radial-Buttons and many other interesting things worth experimenting with.