3 Replies Latest reply on Aug 17, 2015 6:22 PM by CMata_Intel

    Default pin state

    Rubik

      Hi,

       

      I'm writing a program to control my watering system. I write the software using Node and besides the regular mraa interaction I have a web interface. The issue I face is if while a solenoid valve is opened (a pin state is ON) the program crashes the state of the pin will not be changed to off. Is there any solution to this issue? Maybe to set a default state for a pin and when a process is no longer active this value to be set?

       

      Regards,

      Rubik

        • 1. Re: Default pin state
          CMata_Intel

          Hi Rubik,

           

          Are you having an error message when the program crashes? Which pin are you using? If you are using the pin 7 of the Arduino Expansion Board, there is a known issue related with this pin and the WiFi performance so I would suggest to use another pin.

          Have you tried with different pins?

          Which expansion board are you using with the Edison Module?

          Which image are you using? Check this by running configure_edison --version

           

          Do you want to use two services? Or just one and inside of it create the exceptions for the pin?

          You can try from the Linux side to set the pin with the value you want, you can also try by setting a pull-up resistor, take a look at the Hardware Guide for the Arduino Expansion Board.

           

          Regards,

          Charlie.

          • 2. Re: Default pin state
            Rubik

            Hi Charlie,

            I use a GPIO Block and I use pin GPIO-44 (mraa 31), GPIO-45(mraa45), GPIO-46(mraa32) and GPIO-47(mraa 46)

            The version I use is weekly-146 and weekly-159.

            Basically what I do is:

             

            var valve1 = new mraa.Gpio(31); // GPIO-44

            valve1.dir(mraa.DIR_OUT);

             

            setInterval(function() {

                   if (valveShouldBeOpened(currentTime)) {

                    valve1.write(1);

                   }

                   if (valveShouldBeClosed(currentTime)) {

                    valve1.write(0);

                   }

              }, 5 * 1000);

             

            Now, if the node process dies after open and before close the pin state will remain open.

             

            Regards,

            Rubik

            • 3. Re: Default pin state
              CMata_Intel

              Hi Rubik,

               

              Are you running this with the XDK or are you using the Terminal Console?

              Have you tried to debug the valveShouldBeOpened(currentTime) function? Is this working as it should?

              I suggest you to start checking section by section of your code, start with the functionality of changing the state of the pin in order to see where the problem is

               

               

              Regards,

              Charlie