Scanning of multiple inputs

Discussion in 'C' started by calvinlyp, Feb 11, 2010.

  1. calvinlyp

    calvinlyp New Member

    Joined:
    Jun 4, 2009
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    Hi all, i am relatively new to C programming, so pardon my ignorance.

    i am trying to program a micro controller which uses c language.

    i require to read from multiple inputs, and simultaneously display or print out for the user to see, may i know how should i go about doing it?

    eg.
    i have a,b and c inputs.
    each coming from a different source but arrive at the same time, but how do i display these 3 values concurrently, which this 3 values should display as a group.

    any advice will be greatly appreciated.
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    Which compiler are you using?
    Which microcontroller (specify exactly, e.g. Microchip PIC16F887)?
    What hardware is it connected to? Post a circuit diagram.
    What are the nature of the inputs; are they analog or digital, and what form does the input take: is it a continuously varying signal, a stream of 1's and 0's, etc?
    What are the outputs; are they LEDs, some kind of display (what exactly)? What exactly do you want the outputs to do in relation to the inputs: if LEDs and binary inputs, do the LEDs just display the inputs 1=on, 0=off? You mentioned printing - are you connected to a printer in the sense that an HP Laserjet is a printer, or do you mean something different by "print"?

    If you're completely new to microcontrollers then the best advice is to follow a tutorial to get you started. Try this for starters:
    http://www.winpicprog.co.uk/pic_tutorial.htm
    Or you could invest in one of the MikroElektronika boards; I just got myself an EasyPIC6.
     
  3. calvinlyp

    calvinlyp New Member

    Joined:
    Jun 4, 2009
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    as my reply was too long i attached it as a .txt file.

    thanks for any reply.

    i am relatively new to Psoc development pardon my ignorance.
    i am currently working on integrating accelerometer with the development kit.

    i found an article on
    http://www.cypress.com/?docID=19786

    after consulting an expert, he noted to me that the application note i had referred is for connecting an Accelerometer to PSoC1 devices which have SAR and ADCINC incremental ADCs. PSoC3 does not have a SAR8 user module. Instead i can use the ideas proposed in the application note but substitute the ADC with the Deltasigma ADC from PSoC.

    i am purchasing a similar accelerometer(http://sgbotic.com/index.php?t...ts&product_id=440) to integrate on the PSoC development board.

    1)since now the accelerometer i am using is 3axis should i follow the concept of the article, by using a mux? or sholud i use 3 individual ADC to read from each x,y and z?
    as the x,y,z value from the accelerometer will be available for the ADC to read at the same time.

    this lead to next question
    2) if i was to use a mUX,there is two mux available in the creator software, i was thinking of using the AMUXSeq, as i need to differential x,y and z value.
    is this a better choice out of the two?

    3) since PSoC development board had its own LCD, from the article, i can remove the concept of I2C to display on the external device right?
    however can the LCD display simultaneously 3 values by writing at the appropriate position of the LCD(ie i send to print string of x,y and z value at different position of the LCD)?
    as the LCD is only one port, can it take in 3 functions to write at the same time?

    or should i set the values of x,y,z in some buffer and display at one time?

    thanks
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Moved attachment into post.
     
  5. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    Well you know more about Psoc than me. I've only been using PICs so far.

    1. depends on the project requirements. An ADC takes an amount of time to perform the conversion so the question is how frequently do you need to take readings? Can you get the required bandwidth out of just one ADC? If not then you will need three ADCs.

    Another consideration is: Can you spare three pins for three ADCs? If you can't then that settles the question for you.

    On the other hand what is easier? Does it make programming easier or harder to use three ADCs or to multiplex three inputs into one ADC?

    2. No idea. But this question may be rendered moot by the answers to 1.

    3. Yes. Unless the psoc has 3 CPUs on board you won't be doing anything simultaneously; you will read from one ADC, then the next, then the 3rd. When you display stuff on screen just display all three values in different places.

    If psoc has a multitasking OS and you're just writing a thread to read one ADC and display it on screen, and having 3 of those threads, then you'll have to serialise LCD access (i.e synchronise your threads so they don't try to write to it at the same time) otherwise you will confuse it. Also if you MUX the ADCs you'll have to serialise that as well, so it may just be easier to do the whole lot in one thread. You wouldn't be looking at a vast amount of code anyway.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice