Author Topic: IOR5E 5V vs 26V jumpers, SBC68EC  (Read 2586 times)

jcermak

  • Newbie
  • *
  • Posts: 2
    • View Profile
IOR5E 5V vs 26V jumpers, SBC68EC
« on: September 23, 2011, 11:53:58 AM »
If we were to change the jumper from 5V to 26V, do we also need to update the divisor in the code from 1023/5 to 1023/26 (see below)?

A related post: http://forum.modtronix.com/index.php?topic=164.msg474#msg474

webservr68_v310\src\cmd.c:

Code: [Select]
            #elif defined(APP_USE_ADC10)
            WORD tmpW;
            tmpW = AdcValues[tagVal & 0x0f];
            if (ref == HTTP_START_OF_VAR )
            {
                //Convert tmp value to voltage (2 decimal points) value for 5V reference
                strTmp[0] = (BYTE)(tmpW / (1023/5)) + '0';
                strTmp[1] = '.';
                tmpW = (tmpW % (1023/5));   //Get rest
                strTmp[2] = (BYTE)(( ((WORD)tmpW) * (WORD)10) / (WORD)(1023/5)) + '0';
                tmpW = (tmpW / 10);
                strTmp[3] = (BYTE)( ( ((WORD)tmpW) * (WORD)100) / (WORD)(1023/5)) + '0';
                strTmp[4] = '\0';  //Terminate with 0
            }

eagleeye

  • Full Member
  • ***
  • Posts: 24
    • View Profile
Re: IOR5E 5V vs 26V jumpers, SBC68EC
« Reply #1 on: September 23, 2011, 11:27:37 PM »
I believe on my Old version Ior5E its 2200k
so


' // 510 / (510 + 2200)
' // = 0.188191881
' //
' // Full range of divider  0 to (5V/0.188191881)
' // = 0 to  26.568628V
' //
' // so each AD bit will be 26.568628/1024 = 0.0259459 V

And YES the resistor network must be taken into account


Eagleeye

jcermak

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: IOR5E 5V vs 26V jumpers, SBC68EC
« Reply #2 on: September 26, 2011, 10:56:49 PM »
Thanks for the information!  It didn't look like the program interface MPLAB liked the float number.  I didn't see any use of float numbers in the example code so I used 26 for the value for now. 

There was one additional problem.  The code above only can handle 0 to 9V although the range is now 0 to 26V.  So, hooking two 9V batteries in series gave me B.10v = 18.10v.  ('B' is ASCII '0' + 18).  There is probably a better way to perform the math so it is consistent with the rest of the programming.

The max string length is 6, but the below code uses 4 or 5 characters depending if there is a tens digit.

cmd.c now looks like:
Code: [Select]
            WORD tmpW;
            BYTE wholeV;
            BYTE ch;
            tmpW = AdcValues[tagVal & 0x0f];
            if (ref == HTTP_START_OF_VAR )
            {
                //Start the character count at 0
                ch = 0;
                //Convert tmp value to voltage (2 decimal points) value for reference defined in APP_ADC10_REF_VOLTAGE

                //strTmp[ch] = (BYTE)(tmpW / (1023/APP_ADC10_REF_VOLTAGE)) + '0'; ch++;

                wholeV = (BYTE)(tmpW / (1023/APP_ADC10_REF_VOLTAGE));

                //Tens digit, if V>9
                if ( wholeV > 9 ) {
                  strTmp[ch] = (BYTE)((WORD)wholeV / (WORD)10) + '0';
                  wholeV = wholeV - ((strTmp[ch] - 48) * 10); ch++;
                }

                //Ones digit
                strTmp[ch] = (BYTE)((WORD)wholeV) + '0'; ch++;               

                strTmp[ch] = '.'; ch++;
                tmpW = (tmpW % (1023/APP_ADC10_REF_VOLTAGE));   //Get rest
                strTmp[ch] = (BYTE)(( ((WORD)tmpW) * (WORD)10) / (WORD)(1023/APP_ADC10_REF_VOLTAGE)) + '0'; ch++;
                tmpW = (tmpW / 10);
                strTmp[ch] = (BYTE)(( ((WORD)tmpW) * (WORD)100) / (WORD)(1023/APP_ADC10_REF_VOLTAGE)) + '0'; ch++;
                strTmp[ch] = '\0';  //Terminate with 0
            }

I added a APP_ADC10_REF_VOLTAGE define in projdefs.h:

Code: [Select]
/**
 * Global Array containing converted ADC values. This array can be accessed from
 * anywhere to obtain the current value of the ADC inputs. For example, to get
 * the current value of AN2 ADC, use AdcValues[2]
 */
#if defined(APP_USE_ADC8)
extern BYTE AdcValues[ADC_CHANNELS];
#elif defined(APP_USE_ADC10)
extern WORD AdcValues[ADC_CHANNELS];
/**
  * Define reference voltage
  * Modify ver 1: All straps are set to the same reference voltage (5 or 26), see cmd.c
  */
#define APP_ADC10_REF_VOLTAGE 26
#endif

eagleeye

  • Full Member
  • ***
  • Posts: 24
    • View Profile
Re: IOR5E 5V vs 26V jumpers, SBC68EC
« Reply #3 on: October 07, 2011, 12:30:56 AM »
In our applications
 all the IOR5E are located on remote places, so we use a  page that contains the modtronix reference variables. Everytime this web page is served we will only receive a bunch
of AD values as CSV - that is

223,453, 849

knowing the offsets to the data, you then process them at the receiving end.

UPlink cost is very precious and cost a lot of money. so we dont want to send a lot of bytes
over. You could also use UDP to send values by passing all the HTTP character overhead if needed.

then we collect these values and display them on the free PRTG NETWORK Monitor
which provide graphing,logging, alarms and historical values.

http://www.paessler.com/prtg
A vbscript program is used to interface the PRTG program to the modtronix or other web based
board because PRTG cannot perform scaling values on its own.

You could also throw out a html page with JAVA script as the sample modtronix pages do.
So that calculations can be shown and corrected by re-uploading the javascript pages as opposed to recompiling the whole program.

Regds
Allan