585,971 active members*
4,208 visitors online*
Register for free
Login

Thread: IO SIGN

Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2011
    Posts
    0

    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

  2. #2
    Join Date
    May 2006
    Posts
    4045
    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
    TK
    http://dynomotion.com

  3. #3
    Join Date
    Feb 2011
    Posts
    0
    Thanks very much, Tom

Similar Threads

  1. Replies: 2
    Last Post: 03-12-2013, 04:23 PM
  2. One sign on the go!
    By cncadmin in forum EnRoute
    Replies: 0
    Last Post: 12-06-2011, 09:10 AM
  3. shop sign
    By woodman08 in forum Gorilla CNC Machines
    Replies: 3
    Last Post: 12-26-2010, 11:57 PM
  4. sign
    By Edwardo in forum DynaTorch
    Replies: 11
    Last Post: 09-03-2008, 02:56 AM

Posting Permissions

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