Author Topic: show ADC on a webpage  (Read 1645 times)

parotin

  • Jr. Member
  • **
  • Posts: 8
    • View Profile
show ADC on a webpage
« on: March 01, 2015, 01:01:45 AM »
Hello,

I'm monitoring a 24 v value with an analogic imput on my SBC68EC configured for 5v, using three resistances as a divisor, so I'm reducing the original value from 24v max to 4v, taking the value between the resistances (I don't know if I explain it properly, my english is not so good). At the end, using the default web pages, I have 4v when the real value is 24, 5v when it is 30 etc.
I whould like to display the real valor, but I don't know how to convert localy on the browser. I gess it is easy with an script. On the htm page thre is the value %n27 and this displays the valor.

Could somebody tell me where I can get a manual about how to use this valor as a number and be able to multiply it x6?

thank you very much

gr

  • Hero Member
  • *****
  • Posts: 171
    • View Profile
Re: show ADC on a webpage
« Reply #1 on: March 01, 2015, 10:39:58 AM »
This is very easy to do - anyone who knows javascript can do this in about one line of code.

In aval.cgi (or any other cgi page) just change this:
%n27
to this:
Code: [Select]
    <script type="text/javascript">
      document.write((%n26 * 6).toFixed(1));
    </script>

Note that the ".toFixed(1)" is optional and sets the number of decimal places to show.   

There is a bug with the %n functionality (I posted about it somewhere in these forums) such that it's only accurate to 2 significant digits (the last 2 digits are always the same e.g. 1.322V or 1.333V but never 1.325V (if I remember all this correctly).

If you know any javascript programmers they can help you do other similar things.

parotin

  • Jr. Member
  • **
  • Posts: 8
    • View Profile
Re: show ADC on a webpage
« Reply #2 on: March 01, 2015, 11:18:58 AM »
Thank you very much. I suposed It was going to be something easy.. but easy just for the people who know how! like you ;-) thanks again.

You talk about a bug which is the numbers after the dot are just the two more significant the ones that works, and the the therth or more, are just the same... but I have an other question. I don't need it because it is enought accurated to monitor my battery, but I know you are realy curious so I just tell... I noted that the values of %n27, in 5V scale (as it is in default), just can take some values. I mean it's always 4.00 4.10 4.21 4.31 4.33 4.43 4.53 4.55 4.65 4.75.. but never between them! I wander why because is suposed you can get realy accurated samples...

Anyway, thank you very much. Now I have a nice system to manage the engine! with my phone, tab or pc