ADC0808 outputting random values

I have interfaced an atmel 89c51 with ADC0808. Given the clock through uC. Vrf+ 5v.Vref- 0v.
I have also interfaced it with max232. Done the programming so that the ADC has three inputs and uC initiates the ADC0808 and sends the outputs to serial port. Input values are converted into Decimal and then ASCII (to display on hyperterminal). While I give 0 volts to all inputs.
The output is
000,000,000
When I give 5 volt to 1st input. The output appears as
255,000,000
But when i give input value between 0-5 volt.e.g 2.5 volt. the ouptut is still
000,000,000
I could not understand what could be the problem.
I have uploaded the proteus.simlulation file,c and hex code
Attachments:
sys3inputs.zip ‏37 KB

Hi 444444,
Thanks for posting to National Instruments forums. I wanted to check, after scanning your initial post, are you using any National Instruments software or hardware, perhaps something like the USB 8451? These forums are frequented by NI users and, subsequently, are a great place to speak with experts in the use of those products. Looking through your set up, I was unfamiliar with a lot of the hardware you mentioned, and as such I am not sure if this forum will be the best place to get the answers and expertise you are seeking. Perhaps the manufacturers of the 89c51 and ADC0808 have a support line where the expertise in your hardware is more readily available. I am sure that they would be a better resource as far a familiarity with programming and how data should be returned by that ADC. 
Regards,
h_baker
National Instruments
Applications Engineer
Digital Multimeter Resources

Similar Messages

  • Weighted random value (1-10) e.g.3 will be  50 % of records

    Hello,
    i need to generate random values into my table. For the simplification, lets say that i need to generate values in range from 1 to 10. For this there is a lot of ways.
    e.g. UPDATE test_number SET random_value = round (dbms_random.value (1,10))
    But what I need is something like weighted random values. I need random values to be inserted into column, but I need e.g. 3 to be inserted more times than other values e.g. if i have 100 rows i want to have 3 in 50 random rows
    Do you have any idea how to achieve it?
    Thanks a lot for any help or reply !

    Hi,
    You can do something like this:
    WITH     got_p_num     AS
         SELECT     LEVEL                         AS id
         ,     FLOOR (dbms_random.value (1, 19))     AS p_num
         FROM     dual
         CONNECT BY     LEVEL     <= 10
    SELECT       id
    ,       p_num
    ,       CASE
              WHEN  p_num     < 3     THEN p_num
              WHEN  p_num     < 12     THEN 3
                                     ELSE p_num - 8
           END     AS r_num
    FROM       got_p_num
    ORDER BY  r_num
    ;If you want the number 3 to appear on half of the rows; that means that, out of 18 random numbers, you expect 3 to occur 9 times, and the other numbers to appear once each. The query above generates random integers in the range 1 through 18 inclusive, and calls this number p_num. The CASE statement maps p_num to what you really want, a n integer between 1 and 10, with 3 occurring 9/18 (= 1/2) of the time.
    Instead of using a CASE expression, you might want to create a table, that has one row for every number that can be in the output, and the probability of picking that number. You could then join to that table to convert the raw random number to the id that you want.
    Edited by: Frank Kulash on Oct 6, 2011 3:36 PM

  • How can i get the random values from database?

    Hi,
    i want to get random values from database.
    I try my best find no solution
    plz give solution in either sql query or java method.
    thanks in advance.

    try this:
    Give a numeric row-id to each row of database.
    say (1-100) for 100 rows
    In the program use random function to get random number between 0 and 1. this value u multiply with 100(or total number of rows) and take integer value of it . u then perform sql query to select the a row which matches randomly genarated value with row-id assigned to each row of database
    madhu

  • Selecting random values from an array based on a condition

    Hi All,
    I have a small glitch here. hope you guys can help me out.
    I have an evenly spaced integer array as X[ ] = {1,2,3, ....150}. and I need to create a new array which selects 5 random values from X [ ] , but with a condition that these random values should have a difference of atleast 25 between them.
    for example res [ ] = {2,60,37,110,130}
    res [ ] = {10,40,109,132,75}
    I have been thinking of looping thru the X [ ], and selecting randomly but things look tricky once I sit down to write an algorithm to do it.
    Can anyone think of an approach to do this, any help will be greatly appreciated ...

    For your interest, here is my attempt.
    import java.util.Random;
    public class TestDemo {
        public static void main(String[] args) throws Exception {
            for (int n = 0; n < 10; n++) {
                System.out.println(toString(getValues(5, 25, 150)));
        private final static Random RAND = new Random();
        public static int[] getValues(int num, int spread, int max) {
            if (num * spread >= max) {
                throw new IllegalArgumentException("Cannot produce " + num + " spread " + spread + " less than or equals to " + max);
            int[] nums = new int[num];
            int max2 = max - (num - 1) * spread - 1;
            // generate random offsets totally less than max2
            for (int j = 0; j < num; j++) {
                int next = RAND.nextInt(max2);
                // favour smaller numbers.
                if (max2 > spread/2)
                    next = RAND.nextInt(next+1);
                nums[j] = next;
                max2 -= next;
            // shuffle the offsets.
            for (int j = num; j > 1; j--) {
                swap(nums, j - 1, RAND.nextInt(j));
            // add the spread of 25 each.
            for (int j = 1; j < num; j++) {
                nums[j] += nums[j-1] + spread;
            return nums;
        private static void swap(int[] arr, int i, int j) {
            int tmp = arr;
    arr[i] = arr[j];
    arr[j] = tmp;
    public static String toString(int[] nums) {
    StringBuffer sb = new StringBuffer(nums.length * 4);
    sb.append("[ ");
    for (int j = 0; j < nums.length; j++) {
    if (j > 0) {
    sb.append(", ");
    sb.append(nums[j]);
    sb.append(" ]");
    return sb.toString();

  • In XML Output the values of Number column tags are not displayed properly

    Hi,
    Our Client have been using AR Invoice Print Program for a long time and it is heavily customized. Also they are using an old version of the RDF. So we have taken the latest version of the RDF (RAXINV.rdf) for Oracle Apps 11.5.10.2 by raising a SR and implement Client's old RAXINV.rdf into it.
    All was ok, but when we are running the program, the XML Output did not generate properly. For the Q_INVOICE query (G_ORDER_BY, G_INVOICE and G_INV_TERM group), the value of some of the scaler number columns are not appeared properly. The tags are coming correctly, but the value is appearing as '*', instead of the correct value. We have checked in the RDF Level (By putting srw.message and check in the log file) that those columns are having proper value. So there is no issue with the RDF.
    But because of the above mentioned problem, the some of the PDF output field values also is not generated correctly.
    I think that because of the lexical parameters which was implementing the Q_INVOICE query (&COMMON_QUERY) this issue is coming. Because the issue is only in the Q_INVOICE query group (G_ORDER_BY, G_INVOICE and in G_INV_TERM group) not in any other query group.
    There is no problem with the scaler character columns. The issue is only with the number columns.
    Also we have checked that if we hardcode the value of the number columns in the above mentioned lexical parameter, this problem doesn't appear.
    If we put TO_CHAR function to those number columns in the lexical parameter (COMMON_QUERY), then this issue get solved. But we can't do it because of performance issue and also Client won't approve it.
    Please help.
    With Thanks and Regards

    I don't know how to read the code you pasted or I would have checked this myself.
    Do your fields in the internal table reference dictionary objects or elementary types? If not using dictionary types, the column names will be blank by default. If you can't change your fields to be dictionary types, you can try this to change the column names:
    I made a method inside my local class to add the names:
            call method set_colname
              EXPORTING iv_tab = alv_tab
                        iv_colid = 'xxxx'  "fieldname from the table
                        iv_stxt = text-t54
                        iv_mtxt = text-t55
                        iv_ltxt = text-t55.
    METHOD set_colname .
      data:
              alv_cols type REF TO cl_salv_columns_table,
              alv_col type REF TO cl_salv_column.
      TRY .
    *... Change fieldnames
            call METHOD iv_tab->get_columns RECEIVING value = alv_cols.
            call method alv_cols->get_column EXPORTING columnname = iv_colid RECEIVING value = alv_col.
            IF iv_stxt <> ''.
              CALL METHOD alv_col->set_short_text EXPORTING value = iv_stxt.
            ENDIF.
            IF iv_mtxt <> ''.
              CALL METHOD alv_col->set_medium_text EXPORTING value = iv_mtxt.
            ENDIF.
            IF iv_ltxt <> ''.
              CALL METHOD alv_col->set_long_text EXPORTING value = iv_ltxt.
            ENDIF.
       CATCH cx_salv_not_found.
      ENDTRY.
    ENDMETHOD. "set_colname

  • Output variable value (DBMS_OUTPUT.PUT_LINE)

    Hello,
    I just started using ORACLE and am learning about PL/SQL. My question is how do you output a variable? I am running the following in an SQL Worksheet, but I can't output the value:
    DECLARE
    v_Temp VARCHAR2(200);
    BEGIN
    v_Temp :='help me';
    DBMS_OUTPUT.PUT_LINE(v_Temp);
    DBMS_OUTPUT.PUT_LINE('Text In Single');
    END;
    Thanks, sck10

    SQL> DECLARE
      2  v_Temp VARCHAR2(200);
      3 
      4  BEGIN
      5  v_Temp :='help me';
      6  DBMS_OUTPUT.PUT_LINE(v_Temp);
      7  DBMS_OUTPUT.PUT_LINE('Text In Single');
      8  END;
      9  /
    PL/SQL procedure successfully completed.
    SQL> set serveroutput on
    SQL> /
    help me
    Text In Single
    PL/SQL procedure successfully completed.
    SQL> Nicolas.

  • Random Value Generation

    FYI, time to give back. I have received a number of excellent
    responses from this forum, so here is one that might help someone
    else.
    I had found and modified the code below to generate a random
    value (letters and numbers) to use as a member ID. With it you can
    set the length of the generated value, as well as the content
    (numbers, capital letters, lower case letters, even special
    symbols). I chose a subset of capital letters along with 0-9 so the
    result contained more numbers.

    I don't get it?! Why not just use something like
    #createUUID()#, which is also apparently meant to be unique
    everytime.
    If you don't like the format of createUUID you can always run
    a couple of functions over it to alter it a bit, like taking out
    some of the dashes, or making it longer etc.
    Maybe I'm missin the point...it's late here!! Me =
    sleepy.

  • Inserting Random Values

    Hi there!
    just a little question:
    I want to insert into a table random values between -2 and 2, which shoul differ for every row. When I'm writing
      FOR n IN nodes LOOP
        FOR EACH n2 IN nodes2 LOOP
          IF (n2.layer_ = n.layer_ +1) THEN
            INSERT INTO nn2_links (lfdnr, sourceid, destid, weight, delta_weight, Zone_)
                 VALUES (lfdnr#, n.nodeid, n2.nodeid, dbms_random.value(-2,2), 0, Zone#);
            lfdnr# := lfdnr# +1;
          END if;
        END LOOP;
      END LOOP; I'll get the same value for all records fullfilling the IF-criteria in the middle. What can I do? Must I write another loop?
    greetings
    ~Mel

    OP states that she / he would like to have distinct values for every row but instead gets the same value for all rows.
    To OP:
    Sorry mel, not much help. Can't see the error in your script.
    When I put a anonymous block together, it runs smoothly:
    SQL> set serveroutput on
    SQL> declare
      2  outn number;
      3  cnt number;
      4  begin
      5  cnt := 1;
      6  while cnt <=10 loop
      7     select dbms_random.value(-2,2) into outn from dual;
      8     dbms_output.put_line('Wert: '|| to_char(outn));
      9     cnt := cnt + 1;
    10  end loop;
    11  end;
    12  /
    Wert: 1,94760933757912513703045869459081746304
    Wert: ,1850733416444459069798272966494986884
    Wert: -1,28557676353717597230879638125649445416
    Wert: -,20789721958144010481059709280045566588
    Wert: -1,46550435548323732535026606603236048092
    Wert: -1,48594688953909777344516402506798302304
    Wert: -,2162809554864053530960985675499170964
    Wert: 1,71049071188915501435899411045229762652
    Wert: ,53354523369664937673204584890644358732
    Wert: -,96917849158672171927090500710866039384
    PL/SQL-Prozedur wurde erfolgreich abgeschlossen.
    SQL>

  • Unique Random Values

    OK, firstly, I am a Java n00b. I am not creating a program, just editing some source, but I need some help. What I need, are 5 different variables, each with a random value (integer) between 1 and 5 (inclusive), but, I don't want to variables to have the same value. The outcomes I'm looking for could be as follows:
    t = 4
    i = 3
    g1 = 5
    g2 = 1
    y = 2
    and then the next time the code is run I might get:
    t = 1
    i = 5
    g1 = 4
    g2 = 2
    y = 3
    Each variable has a random value (integer) between 1 and 5 (inclusive), but no 2 variables have the same value.
    Here is what I tried:
         Random rand = new Random();
         int t = (rand.nextInt(5) + 1);
         int i = (rand.nextInt(5) + 1);
         int g1 = (rand.nextInt(5) + 1);
         int g2 = (rand.nextInt(5) + 1);
         int y = (rand.nextInt(5) + 1);
    // While i is the same as t, make i a new random integer between 1 and 5. Yes? Or no...?
         do {
         i = (rand.nextInt(5) +1);
         } while (i == t);
         do {
         g1 = (rand.nextInt(5) +1);
         } while (g1 == t);
         do {
         g1 = (rand.nextInt(5) +1);
         } while (g1 == i);
         do {
         g2 = (rand.nextInt(5) +1);
         } while (g2 == t);
         do {
         g2 = (rand.nextInt(5) +1);
         } while (g2 == i);
         do {
         g2 = (rand.nextInt(5) +1);
         } while (g2 == g1);
         do {
         y = (rand.nextInt(5) +1);
         } while (y == t);
         do {
         y = (rand.nextInt(5) +1);
         } while (y == i);
         do {
         y = (rand.nextInt(5) +1);
         } while (y == g1);
         do {
         y = (rand.nextInt(5) +1);
         } while (y == g2);But when I use the variables in the next part of the program, sometimes it works, but sometimes 2 of them are the same. Sometimes even 4...
    Can someone help me please?

    Thinking about it now though, I would like to learnproperly. What is a good Java guide that starts from
    scratch?
    I think the Core Java books, by Cay Horstmann, are a
    great way to start learning Java. I refered to his
    books constantly durning college:
    http://www.amazon.com/exec/obidos/tg/detail/-/013148202
    /qid=1096410169/sr=1-1/ref=sr_1_1/104-3324308-3016709?v
    glance&s=books
    Sun's basic Java tutorial
    Sun's New To Java Center. Includes an overview of what Java is, instructions for setting up Java, an intro to programming (that includes links to the above tutorial or to parts of it), quizzes, a list of resources, and info on certification and courses.
    http://javaalmanac.com. A couple dozen code examples that supplement The Java Developers Almanac.
    jGuru. A general Java resource site. Includes FAQs, forums, courses, more.
    JavaRanch. To quote the tagline on their homepage: "a friendly place for Java greenhorns." FAQs, forums (moderated, I believe), sample code, all kinds of goodies for newbies. From what I've heard, they live up to the "friendly" claim.
    Bruce Eckel's Thinking in Java (Available online.)
    Joshua Bloch's Effective Java
    Bert Bates and Kathy Sierra's Head First Java.

  • Get a random value out of a query result

    I have a query:
    select id
    from class_schedule
    where id not in (
    select distinct(event_id) from trainer_schedule)I want to pick up a random value from this query result and assign it to a varible e.g. randomID.
    please help

    here is the example
    SQL> SELECT empno,ename
      2  FROM (
      3    SELECT empno,ename
      4    FROM EMP
      5    ORDER BY dbms_random.VALUE)
      6  WHERE ROWNUM = 1;
          7876 ADAMS
    SQL> /
          7566 JONES
    SQL> /
          7900 JAMES
    SQL> /
          7844 TURNER
    SQL>

  • Select statement for JDBC receiver synch scenario for capturing random value from ECC portal

    Dear Experts,
    I am working on ECC <----> SAP-PO 7.31 <----> JDBC synchronous scenario. I am clear about the config part except the Select statement. I will be
    capturing 2 random values from the portal i.e. VendId and VendName in ECC to get the vendor details like Vendor Country, Vendor Status, Vendor Contact , Vendor Address etc from JDBC vendor table/view VENDETAIL.
    What would be the select statement to capture the random values for ECC portal? My select statement would look some thing like this..
    Select f1,f2,f3,f4 from table VENDETAIL where key1 = "VendId" and "VendName"
    Please suggest if the above select statement works for the above scenario...
    Regards
    Rebecca

    Hi Rebecca,
    Your statement should work fine.
    Please see the statement we use below.
    SELECT eT_cashier, eT_proc_yn, eT_proc_date FROM eTest WHERE eb_proc_yn = 'N'
    Just remember to update the change indicator so that you dont duplicate your records.
    UPDATE eTest SET eb_proc_yn = 'Y' WHERE eb_proc_yn = 'N'.
    Regards,
    Jannus Botha

  • Build array from random values via ethernet

    Am trying to save data that comes from ehternet ((random values (modbus protocol)) in an array.
    I am using an index array.....but all the values are the same!! How can I sort them??
    It functions correctly with a for loop with random numbers build.......but it doesn't work with the data from ethernet.
    Can someone please help me??
    Attachments:
    Data.vi ‏16 KB

    chendel wrote:
    Am trying to save data that comes from ehternet ((random values (modbus protocol)) in an array.
    I am using an index array.....but all the values are the same!!
    You just read the same shared variable 100 times within a few nanoseconds. Apparently, the variable gets modified less often on the other end.
    chendel wrote:
    How can I sort them??
    If all array values are the same, they are already sorted.
    You need to rethink your code. maybe you can make the shared variable an array and write the entire random array on the other end, the read it out once.
    LabVIEW Champion . Do more with less code and in less time .

  • How to get both, the ResultSet and Output (return value) from Oracle Stored Procedure

    Hi! I am doing a conversion from MSSQL to Oracle with C++ and MFC ODBC. Any comment is appreciated!! I have Oracle 8i and Oracle ODBC 8.1.6 installed.
    My question is how to retrieve the return value AND ALSO the resultSet at the same time by using Oracle function without modifying my souce codes (except puttting mypackage. string infron of my procedure name, see below).
    -- My source code in C++ with MSSQL ....
    sqlStr.Format("{? = call ListOfCustomers(%i)}", nNameID);
    RcOpen = CustomerList.Open(CRecordset::forwardOnly, sqlStr, CRecordset::readOnly );
    Where CustoemrList is a Crecordset object...
    IN DoFieldExchange(CFieldExchange* pFX) I have ...
    //{{AFX_FIELD_MAP(CQOSDB_Group)
    pFX->SetFieldType(CFieldExchange::outputColumn);
    RFX_Long(pFX, T("Name"), mCustoemrName);
    //}}AFX_FIELD_MAP
    // output parameter
    pFX->SetFieldType( CFieldExchange::outputParam );
    RFX_Int( pFX, T("IndexCount"), mCustomerNumber);
    -- m_CustomerNumber is where i store the return value!!!
    -- In Oracle Version, i have similar codes with ...
    sqlStr.Format("{? = call mypackage.ListOfCustomers(%i)}", nNameID);
    RcOpen = CustomerList.Open(CRecordset::forwardOnly, sqlStr, CRecordset::readOnly );
    -- I have oracle package/Body codes as following...
    create or replace package mypackage
    as
    type group_rct is ref cursor;
    Function listgroups(
    nameID NUMBER ,
    RC1 IN OUT Mypackage.group_rct ) return int;
    end;
    Create or replace package body mypackage
    as
    Function listgroups(
    NameID NUMBER ,
    RC1 IN OUT Mypackage.group_rct )return int
    IS
    BEGIN
    OPEN RC1 FOR SELECT Name
    from Customer
    WHERE ID = NameIDEND ListGroups;
    END
    return 7;
    END listgroups;
    END MyPackage;
    Ive simplified my codes a bit....
    null

    yes, it is exactly what i want to do and I am using Oracle ODBC driver.
    I tried using procedure with 1 OUT var fo numeric value and the other IN OUT ref cursor var instead of function, but error occurs when I called it from the application. It give me a memory ecxception error!!
    sqlStr.Format("{? = call ListOfCustomers(%i)}", nNameID);
    RcOpen = CustomerList.Open(CRecordset::forwardOnly, sqlStr, CRecordset::readOnly );
    it seems to me that the ? marker var is making all the trouble... can you please give me any more comment on this?? thanks!
    null

  • XML Report Excel Output exponential value issue

    Hello All,
    While working on XML Report we need to show output in excel format. One of the out put value is “00110E001”. but when displaying in excel is shows "1.00E+0" and default behavior of MS Excel is if the any number data contains “E” then excel will convert those records in exponential format. But our client required those data which are present in database i.e. “00110E001”.
    Kindly share your valuable inputs.
    Thanks in advance
    Thanks,
    Pushpal

    Hi Uday,
    You are making number as a string, by adding a character :) , so it will be displayed as string with space and not as number.

  • How can I start a loop before the DAQ Assistand outputs a value?

    Hi everybody,
    I created a VI (See attachment) to Measure the speed of a turning wheel. (A optical detector outputs pulses which are proportional to the speed) The DAQ Assistant measures the frequency and the values are written to a log file. To log every 100 ms the value into the table, there is a while loop with should be executet 10 times a second.
    The first question:
    I want to start measurement as soon as I press "RUN". In fact, my VI first begins to run and log data when the wheel turns and the frequency is not "0". But I want to log data too, if the speed is "0". How can I programm that in Labview?
    The second problem:
    Labview writes not continuely the values: Sometimes 7 values a second, sometimes 11 values.... (I can see that because i log the time too). But if the programm runs for some seconds its getting better and better.
    How can I force Labview to run the loop exactly tacted? Is my Computer too slow? Or is my method to log continuely data simply wrong? I am relative new in Labview and would be thankful in getting help.
    Markus
    Attachments:
    Measure Frequency and Log data.vi ‏63 KB

    I would say right off hand from what you describe that the issue is not related to computer speed, but choice of operating system. Windows is not a deterministic operating system - this means you can't count on how long it will take to do anything.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

Maybe you are looking for

  • Web Service error com.sun.xml.ws.fault.SOAPFaultBuilder.disableCaptureStack

    Hi, I have implemented a Java class which calls some XML RPC 3.0 proxy methods. If I test the method input inside a "main ()" method and get the output, it works nice. The XML RPC 3.0 procy method is also invoked and there is no problem. However, whe

  • Ipod wont hold as much after itunes update.

    My Ipod touch 5th gen (32gb) had about 16gb of space remaining. Then once I updated itunes and have tried to sync all of the sudden it tells me that im 4gbs over yet its the same amount of data as i had before the update. If you know anything please

  • E-mails from my work Road Runner Account are being rejected by Verizon

    When I send a message from my work to my Home Verizon e-mail Account the message come back  Undelivered Mail Returned to Sender.  This started about 3 weeks ago here is the error:  host relay.verizon.net[206.46.232.11] said: 421 4.4.2  Timeout while

  • ICloud calendar customizing instructions?

    In online adds I see a screenshot of the icloud calendar showing the calendar as full screen with no sidebar on the left displaying what calendar you are currently using. Also, in the add screenshot I see a variety of color codes for different types

  • HT201471 when will get I Pad A1460 in India

    I would like to have 4th generation I Pad A1460, as impress with the features. Pl. let me know when it will be available in India.