This demo shows how to use our web server, Java Script, AJAX and DOM to display value from LPC2148 analog to a digital converter. Please refer to the source of this page.
We tested it with IE8, Firefox 3 and Chrome. The recipe is really short and simple:
Give a name to the tag where the data will go, in our case span tag with: id="volt"
Create XMLHttpRequest object:( see XMLHttpRequest ) xmlhttp=new XMLHttpRequest();
Write function "updateVOM()" which requests data and handles "onreadystatechange" event.
Use following line to inject new data into the "volt" tag ( see accessing nodes ) document.getElementById("volt").firstChild.nodeValue = xmlHttp.responseText.substr(0,6)
Add periodical call to the function "updateVOM()" (setInterval ) var int=self.setInterval("updateVOM('vom.php')", 500)
New samples from A/D are retrieved every 500ms. Only text with id="volt" is refreshed. The LPC2148 has 14 A/D channels so happy XMLHttpRequest()'ing.
Voltage = V
If you see this page on digitalshortcut.com then of course there is no A/D converter we can read, so two line PHP script generates random values and disables cache.
Embedded server actually ignores content of the "vom.php" file and instead uses file index as a trigger for predefined action.
Accessing serial port (when in ISE under Windows)
From time to time there is a need to send some configuration data to your FPGA.
All Digital Shortcut Inc development boards feature a RS232 port and it can be used it to exchange data with FPGA application.
Thanks to PicoBlaze small size practically always you can add it to your design and then use terminal emulation software for communication with it.
Alternatively you can send and receive data over RS232 port without leaving ISE development suite.
Just select a Tcl Console tab and load simple script: "source Tcl/ds.tcl"
It is an easy, error free way to send sometimes very cryptic command strings to your app inside FPGA
and nicely decode received strings.