How to read analog signals?


Closed Thread
Results 1 to 24 of 24

Hybrid View

  1. #1
    Join Date
    Dec 2008
    Posts
    24


    Did you find this post helpful? Yes | No

    Default

    well joe thanks for replying what I want to do is... I want to be able to test a analog voltage peroid. And if that analog volatge is in fat true then I want it to pulse low out of the same pin testing that voltage.

    edit i dont want to see how much the voltage is i want to see when it read analog
    Last edited by thm ov3rkill; - 24th February 2009 at 00:31.

  2. #2
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Possible translation

    edit i dont want to see how much the voltage is i want to see when it read analog
    I'm taking a stab at this. I believe when you say "true" you are wanting to say "through", meaning "complete" or "done", is this correct?
    And if that is the case, then it can be done but your circuit will have to be made to monitor your analog signal and have an LED at the same pin.
    It would be simpler to use one pin for the analog signal input then turn ON an LED on another pin (setup as an output) when the A/D is completed or "through".
    Louie

  3. #3
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by thm ov3rkill View Post
    I want to be able to test a analog voltage peroid.
    Ok you want to test an analog voltage, what are you testing for? Do you mean any value greater than zero ?
    And if that analog volatge is in fat true then I want it to pulse low out of the same pin testing that voltage.

    edit i dont want to see how much the voltage is i want to see when it read analog
    So if I understand correctly . . .
    Code:
     
    If voltage is > 0 then
    PortA.0 = 0 'set port latch to low status before enabling tris
    TRISA.0 = 0 ' Turn input into output enabling port to pull low.
    else
    TrisA.0 = 1 ' Keep port in high impedance input status
    endif
    Where PortA.0 in this example is your analog input / output port
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  4. #4
    Join Date
    Dec 2008
    Posts
    24


    Did you find this post helpful? Yes | No

    Default

    Hey joe Well this is the thing I want to setup a little project . You may remmeber me from the xbox 360 thread. But i didint get a chance on that. So i wanted to seeif i can acually get to read the trigger press and pulse out.


    Also I wanted this to be done on a pic 12f683

    Well The reason i want it on the same pin because I dont think i can kill 2 birds with one stone meaning as There is only on spot to read and fire of the controller which is called the wiper. I have seen this done before. So lets say i pull the trigger the pic reads the analog then it pulses low.

  5. #5
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by thm ov3rkill View Post
    Hey joe Well this is the thing I want to setup a little project . You may remmeber me from the xbox 360 thread. But i didint get a chance on that. So i wanted to seeif i can acually get to read the trigger press and pulse out.


    Also I wanted this to be done on a pic 12f683

    Well The reason i want it on the same pin because I dont think i can kill 2 birds with one stone meaning as There is only on spot to read and fire of the controller which is called the wiper. I have seen this done before. So lets say i pull the trigger the pic reads the analog then it pulses low.
    I did not forget . . . Here is what I am having trouble understanding "i pull the trigger the pic reads the analog then it pulses low" Exactly what do you mean by "the PIC reads the analog", What exactly must it see, to then make the pic pulse low? What state is the pin in when the condition is NOT met ? What state is it in when you want the pic to fire ?
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  6. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink

    Hi Joe,

    What I understand here is ...

    IF input pin level is LOW, the Pic must Hold The pin LOW ...

    Question ( useful ! )

    When must the Pic release the pin ???


    In clear Words ...

    I pull the trigger of my gun ... and I want it to make a machine gun ... instead of single shot.

    OR

    I Want to transform an astable button into a bistable one ( ? )

    Or something like that....


    Looks using Comparator offers more Here ... Even if a Timer might be fired ...
    12F629 ???

    Alain
    Last edited by Acetronics2; - 25th February 2009 at 10:38.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  7. #7
    Join Date
    Dec 2008
    Posts
    24


    Did you find this post helpful? Yes | No

    Default

    hey Thanks ace.

    Well again in words. The xbox 360 controller triggers have a analog signal when you press then down thats what it fires off...

    so lets say I want to pull my trigger. if the pic reads( or sees what ever you want to call it) the analog signal that just came trough when i pressed the trigger it makes that same pin into a output and starts to pulses low and when i let go of it it stops and just goes back up top^^=].

  8. #8
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default How about this way?

    Here's something untested you can try. Two methods of rapid fire but you also need to add a 330 Ohm resistor between the button and the input so the PIC can sense a press then drive the same pin as an output even if you keep holding the button low.
    I used the names pulse_fire and rapid_fire just to make them seperate.
    If it does work for you, adjust the PAUSE times to suit your needs.
    Code:
    ' This one fires off 5 shots per press or continueously if button held
    pulse_fire:                 
        i=0                     ' Reset increment counter
        TRISIO = %00000001      ' Port 0 input, rest outputs
        while GPIO.0=1: Wend    ' Wait here until button pressed
        TRISIO = %00000000      ' Port 0 now an output
            for i=1 to 5        ' Set number of rapid fires per button press
                low GPIO.0      ' Hold output LOW
                pause 50        ' Held LOW for 50ms
                high GPIO.0     ' Turn OFF output
                pause 50        ' Keep OFF for 50 ms
            next i              ' 
    goto pulse_fire             ' Go back, continue if button still pressed or 
                                ' wait until pressed again.
                                
    ' This one just continueously fires as long as button is pushed
    rapid_fire:
        TRISIO = %00000001      ' Port 0 input, rest outputs
        while GPIO.0=1: Wend    ' Wait here until button pressed
        TRISIO = %00000000      ' Port 0 now an output
                low GPIO.0      ' Hold output LOW
                pause 50        ' Held LOW for 50ms
                high GPIO.0     ' Turn OFF output                                     
                pause 50        ' Keep OFF for 50 ms
    goto rapid_fire             ' Go back, continue as long as button pressed
    Here's the schematic to the resistor add on:
    Attached Images Attached Images
    Louie

Similar Threads

  1. Cleaning up code
    By Tobias in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd December 2009, 08:14
  2. pic18f analog comparator problem
    By david.silaghi in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 6th May 2009, 10:38
  3. SEROUT WORD variable problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th April 2009, 12:20
  4. Changing declared variables names on the fly
    By jessey in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 16th December 2006, 07:34
  5. analog read
    By swordman in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 12th August 2004, 20:37

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts