IO SIGN


Results 1 to 3 of 3

Thread: IO SIGN

  1. #1
    Registered
    Join Date
    Feb 2011
    Location
    SPAIN
    Posts
    14
    Downloads
    0
    Uploads
    0

    Default IO SIGN

    Hi anyone, today I´ve got two questions I would like to know how read with the instruction (readbit) a bit 0 lever that's to say how to detect that the bit has changed from 1 to 0.
    tha second question is reated to software, and C programming, there are many programs that Tom has made as examples, some of them include Loops that are executed for ever. my question how can include two o more than two of these loops in the same program, what's the correct way If so can you post an example.
    thanks in advanced
    Carlos

    Similar Threads:


  2. #2
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4045
    Downloads
    0
    Uploads
    0

    Default

    Hi Carlos,

    To do something when an input transitions from 1->0 you might write some code to remember the last state and look for the case where the new state is now 0 but the last state was 1. Here is an example:

    int NewState,LastState;

    LastState=ReadBit(46);

    for ( ; ; ) // loop forever
    {
    NewState=ReadBit(46);
    If (NewState==0 && LastState==1)
    {
    // do something because bit changed from 1 to 0
    }
    LastState=NewState; // remember the last State
    }




    For the case where there multiple things that you wish to be continuously monitored you can use a single loop and put all the things you need to do in the same loop. See below:



    for ( ; ; ) // loop forever
    {
    // Do one thing here
    // Do something else here
    }


    HTH

    Last edited by TomKerekes; 07-09-2012 at 06:22 PM.
    Regards
    TK http://dynomotion.com


  3. #3
    Registered
    Join Date
    Feb 2011
    Location
    SPAIN
    Posts
    14
    Downloads
    0
    Uploads
    0

    Default

    Thanks very much, Tom



Tags for this Thread

Posting Permissions

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


About CNCzone.com

    We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

Follow us on


Our Brands

IO SIGN

IO SIGN