Show Posts
|
|
Pages: [1] 2 3 ... 22
|
|
3
|
Using Arduino / Networking, Protocols, and Devices / Re: Inserting graph javascript into sample web server code?
|
on: April 28, 2013, 07:57:58 am
|
Thanks Guys. Finding it too hard and have switched to the HTML5 Canvas element. I am drawing the graphs from scratch which sounds arduous but isn't. For readers edification I list my rough test code below: client.print(F("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n<html>")); client.print(F("<meta http-equiv=\"refresh\" content=\"5\">")); client.print(F("<!DOCTYPE html>")); client.print(F("<html>")); client.print(F("<body>")); client.print(F("<canvas id=\"myCanvas\" width=\"1200\" height=\"650\" style=\"border:1px solid #d3d3d3;\">")); client.print(F("Your browser does not support the HTML5 canvas tag.</canvas>")); client.print(F("<script>")); client.print(F("var c=document.getElementById(\"myCanvas\");")); client.print(F("var ctx=c.getContext(\"2d\");")); client.print(F("ctx.rect(80,50,1000,500);")); client.print(F("ctx.font=\"20px Arial\";")); client.print(F("ctx.fillText(\"Sensor\",5,50);")); client.print(F("ctx.fillText(\"Reading\",5,70);")); client.print(F("ctx.fillText(\"Time\",1030,580);")); //client.print(F("ctx.fillStyle=\"#FF0000\";")); //client.print(F("ctx.fillRect(0,0,150,75);")); //client.print(F("ctx.moveTo(0,0);")); pointX = 80; pointY = 550; client.print(F("ctx.moveTo(")); client.print(pointX); client.print(","); client.print(pointY); client.print(F(");")); for(double i = 0; i < 1000; i++) { pointX = i + 80; //pointY = 550 - (i/2); pointY = 550 - ((i/45)*(i/45)); client.print(F("ctx.lineTo(")); client.print(pointX); client.print(","); client.print(pointY); client.print(F(");")); client.print(F("ctx.stroke();")); } client.print(F("</script>")); client.print(F("</body>")); client.print(F("</html>"));
|
|
|
|
|
4
|
Using Arduino / Networking, Protocols, and Devices / Re: Inserting graph javascript into sample web server code?
|
on: April 28, 2013, 03:26:42 am
|
Thanks Tim, I saw that JS and that is why I used this working webserver example to adapt in the first place. I inserted my JS in place of your 'alert' function thus (making no other changes so as not to break your code): Serial.println(F("Sending response")); client.print(F("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n<html>")); client.println(F("<head><script type=\"text/javascript\">")); //client.println(F("function show_alert() {alert(\"This is an alert\");}")); client.println("var myData = new Array([10, 2], [15, 0], [18, 3], [19, 6], [20, 8.5], [25, 10], [30, 9], [35, 8], [40, 5], [45, 6], [50, 2.5]);"); client.println("var myChart = new JSChart('chartid', 'line');"); client.println("myChart.setDataArray(myData);"); client.println("myChart.setLineColor('#8D9386');"); client.println("myChart.setLineWidth(4);"); client.println("myChart.setTitleColor('#7D7D7D');"); client.println("myChart.setAxisColor('#9F0505');"); client.println("myChart.setGridColor('#a4a4a4');"); client.println("myChart.setAxisValuesColor('#333639');"); client.println("myChart.setAxisNameColor('#333639');"); client.println("myChart.setTextPaddingLeft(0);"); client.println("myChart.draw();"); client.println(F("</script></head>"));
client.println(F("<body><H1>TEST</H1>"));
client.println(F("<form method=GET onSubmit=\"show_alert()\">T: <input type=text name=t><br>")); client.println(F("R: <input type=text name=r><br><input type=submit></form>"));
expecting it to work as previously mentioned. However when I click on the "Submit" button it should show the graph, but does nothing instead.
|
|
|
|
|
6
|
Using Arduino / Networking, Protocols, and Devices / Re: RSSI, 900mhz Vs 2.4ghz Xbees
|
on: April 27, 2013, 10:31:42 pm
|
Now that the RSSI values are more consistent, how can you use that info? As mentioned, the values do not correlate to any standard unit. In the RFM22Bs it is a value from 0 to 255 with 255 indicating perfect reception. From experience I have found that once this value drops down to around 60, there are going to be dropouts. Thats all I use it for. (I am getting about 1.6 to 1.8 kilometers before this occurs.) is why does the 900 mhz have zero RSSI resolution (making it even useless as a "rough" indication) when the 2.4 ghz has fantastic RSSI resolution? This could be due to a couple of things that are hard to tell without seeing the setup. Check that you have the correct antenna and short cable length from ant to xbee. I have only used the Atmel/Meshnetics zigbees but I know with them it is important that you read the RSSI after receiving a packet from the other zigbee. Check whether this is so in your case. I would be interested to know what antenna you are using. I thought that the 900 Pro should be getting better than 700 ft. Are you using line-of-site for these tests? Reflections and EMF noise may also affect your readings.
|
|
|
|
|
8
|
Using Arduino / Networking, Protocols, and Devices / Re: upgrade XBEE 802.15.4 to digimesh 2.4
|
on: April 26, 2013, 04:08:23 am
|
|
The X-CTU software for configuring and updating firmware on the unit, usually has an automatic online download of the latest firmware for the module. It usually gives you a range of options for which version of firmware you want to load into your module, all the while constraining you to only those firmwares suitable for your module.
|
|
|
|
|
9
|
Using Arduino / Networking, Protocols, and Devices / Re: Problem reading data of Power Meter via modbus protocol
|
on: April 26, 2013, 03:53:15 am
|
how can I make distinction between RTU and ASCII The documentation that comes not with the meter but the RS485 add-on module should specify which one it uses. 95% sure that it would be RTU as this is the most common. You can email the manufacturer to be sure. I have checked the Arduino library and it is an RTU implementation of the protocol. The meter is new, and only used a couple of times for testing purposes The unit most probably is not at fault however its a matter of removing the variables that could be causing problems. By using tried-and-tested software you can be fairly sure that problems with communication are not due to bugs in your code/library. Likewise, using a USB to 485 converter removes any doubts about your circuit. After getting comms up with the 3rd party software and converter, you can get a grasp of what values you should be getting from the meter which you can use later on to verify success when using your own code and RS485. Once you get successful comms, the next step would be to substitute in your Rs485 circuit and try it again. If that works, use your code rather than the 3rd party code, secure in the knowledge that everything else is working OK and any problem can only be in your code.
|
|
|
|
|
11
|
Using Arduino / Networking, Protocols, and Devices / Inserting graph javascript into sample web server code?
|
on: April 26, 2013, 02:25:29 am
|
I am using SurferTims web server example at http://playground.arduino.cc/Code/WebServerST to create a 'Hello World' sketch and note that it contains javascript. (I wasn't aware that arduino could handle javascript so I assume that all the processing is handled client side). I want to add a graph to the web pages served up, that shows readings of an analogue input, to the arduino, over time. I have found sample code at http://www.jscharts.com/how-to-use-line-graphs that gives a javascript example with the following code: var myData = new Array([10, 2], [15, 0], [18, 3], [19, 6], [20, 8.5], [25, 10], [30, 9], [35, 8], [40, 5], [45, 6], [50, 2.5]); var myChart = new JSChart('chartid', 'line'); myChart.setDataArray(myData); myChart.setLineColor('#8D9386'); myChart.setLineWidth(4); myChart.setTitleColor('#7D7D7D'); myChart.setAxisColor('#9F0505'); myChart.setGridColor('#a4a4a4'); myChart.setAxisValuesColor('#333639'); myChart.setAxisNameColor('#333639'); myChart.setTextPaddingLeft(0); myChart.draw();
Not having any experience at web programming, I was wondering how I insert this code into the web server HTML so that it is syntactically correct and compiles in the IDE?
|
|
|
|
|
14
|
Using Arduino / General Electronics / BT-138 and inductive loads
|
on: April 25, 2013, 12:04:29 am
|
I am looking at turning a small 240Vac motor off and on using the circuit described in http://arduino.cc/forum/index.php/topic,51671.0.html which uses a BT-138 Triac. (I will only being using two states: full on or 'full' off.) If I was driving a DC motor (inductive load) using a Mosfet I would need to use a diode to stop on/off spikes from damaging the semiconductor. Obviously this is not possible with an AC motor. Do I need to worry about spikes damaging the BT-138?
|
|
|
|
|
15
|
Using Arduino / Networking, Protocols, and Devices / Re: Problem reading data of Power Meter via modbus protocol
|
on: April 24, 2013, 08:15:42 pm
|
Maybe check that the unit is working properly with the 485 module by downloading their test software form the page that you gave above ( http://www.hobut.co.uk/images/HOBUT-MViewV02.zip) and, assuming that it uses the modbus protocol to extract data, verify that the unit is communicating properly. Also there are two frame formats that modbus devices use; RTU and ASCII. I think the modbus frame used by the library is ASCII so be sure that your meter is using ASCII. Without hooking up a test rig, there is little more that I can offer. I have been looking at using the modbus library to hook up to a VSD/VFD to control large motors, but have not got around to it yet. I have hooked up using a PC and a modus library for .NET from http://www.sapia-inc.com/ in the past. You can download a free, time limited version which you can use to interrogate the registers on the meter to see what you should be getting. Don't know if you can put this library into slave mode so that you can link the arduino to it to test your prog.
|
|
|
|
|