How to read analog signals?


Closed Thread
Results 1 to 24 of 24

Hybrid View

  1. #1
    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.

  2. #2
    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 09: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 " !!!
    *****************************************

  3. #3
    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^^=].

  4. #4
    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

  5. #5
    Join Date
    Dec 2008
    Posts
    24


    Did you find this post helpful? Yes | No

    Default

    hey thank you very much ill test it out tommorw. Well one question is this setup detecting a analog voltage then fires rapidfire

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


    Did you find this post helpful? Yes | No

    Default Is it analog?

    You might be seeing a varying pulse width that looks like analog with your meter.

    Hey after playing around and some testing with my new multimeter I found out this, The top pin is always low or ground the middle pin is 1.41 volt When the trigger is not held down, But when you start pressing the trigger it slowly starts decreasing, the more you hold it down the less the voltage gets. When i held the trigger down all the way It was at 0.31-0.30 volts thats afcourse when its down all the the way but even if you press it a little bit the voltage will decrease a little bit and the bottem pin of the 3 is at 1.61 volt all the time and doesent decrease nor increase. This is afcourse on this version of the controller while the other fires off high but not low like this
    From: http://www.picbasic.co.uk/forum/show...4&postcount=27

    Put a scope on it if you have one to make sure.
    Just a thought.
    Louie

  7. #7
    Join Date
    Dec 2008
    Posts
    24


    Did you find this post helpful? Yes | No

    Default

    na pretty sure did research and saw other projects in devlopment in assemply

    here is a pdf to read from it will help a lot I just want to finish this sucka up and play with it in the game =].

    here is the pdf on all the info on the other project i also have it.

    here I downlaoded it on rs since it exceeds ins 200kb's.

    Code:
    http://rapidshare.com/files/204649264/Opensource_Rapidfire_X360_Project2_2.pdf.html

Similar Threads

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