4 Replies Latest reply on Apr 21, 2015 3:33 PM by Kuroneko

    It is possible to use Pin 11 for PWM on Arduino Breakout board?

    Kuroneko

      Hello dear intel community,

       

      I'm new here and it also should be mentioned, that my english is really horrible - but I will try to explain my problem in a understandable way.

      I use the Arduino Breakout board and this Motor shield, to control two motors. The shield requires Pin 3 and 11. The first one on Pin 3 drive without any complications, but when I try to make an UPM-Object of the other one, I always get a error message. So after a while I figured out, that the jumpers on the swizzler must be changed to use Pin 10 and 11. I try that several times but it still not work.

       

      As I mentioned above, I use UPM. Here is the (short) code:

       

      upm::StepMotor *motor = NULL;
      
      int main(int argc, char **argv) {
      motor = new upm::StepMotor(43, 11); // GPIO 43 is correct, right?
      motor->setSpeed (500);
      motor>stepForward (5000);
      delete motor;
      return 0; }
      

       

      So ... my question is: What should I do, that the second motor works too?


      Thanks for your support.


      Best regards,

      Kuroneko

        • 1. Re: It is possible to use Pin 11 for PWM on Arduino Breakout board?
          Intel_Peter

          Hello Kuroneko,

           

          As you can see in mraa: Intel Edison, MRAA (UPM is a repository for sensors that use libmraa) is limited to PWM available on default swizzler positions (3,5,6,9). However you could try to use PWM directly through the Linux console with the following lines:

           

          echo 259 > /sys/class/gpio/export

          echo 227 > /sys/class/gpio/export

          echo 262 > /sys/class/gpio/export

          echo 214 > /sys/class/gpio/export

          echo low > /sys/class/gpio/gpio214/direction

          echo low > /sys/class/gpio/gpio262/direction

          echo high > /sys/class/gpio/gpio259/direction

          echo in > /sys/class/gpio/gpio227/direction

          echo mode1 > /sys/kernel/debug/gpio_debug/gpio183/current_pinmux

          echo high > /sys/class/gpio/gpio214/direction

           

          Or through through the Arduino IDE using  the following command:

           

          setPwmSwizzler(6, 9, 10, 11);

           

          Peter.

          • 2. Re: It is possible to use Pin 11 for PWM on Arduino Breakout board?
            Kuroneko

            Hello Peter,

             

            My english isn't that good - so I understand just a little of the whole documentation.

            Thank you for the answer. It works fine for me, but the motor turn only in one direction. What can I do, if I want to turn the motor to the other? Sorry for the beginner-questions.

             

            Kuroneko

            • 3. Re: It is possible to use Pin 11 for PWM on Arduino Breakout board?
              Intel_Peter

              Well, according to Arduino - ArduinoMotorShieldR3, the motor shield has a direction pin, I don't have one of this shields so I'm not able to test it, however I believe if this pin is High it'll turn to one side and if it is on Low it'll turn the other way.

               

              Peter.

              • 4. Re: It is possible to use Pin 11 for PWM on Arduino Breakout board?
                Kuroneko

                Hello Peter,

                 

                I thought that too and tried it out yesterday - without success. Several hours ago I tried it again, and for some reason it works now (I might forget to restart the board ..) ...

                 

                However, with the following lines the motor turns in the correct way:

                 

                echo 259 > /sys/class/gpio/export
                echo 227 > /sys/class/gpio/export
                echo 262 > /sys/class/gpio/export
                echo 214 > /sys/class/gpio/export
                echo low > /sys/class/gpio/gpio214/direction
                echo low > /sys/class/gpio/gpio262/direction
                echo high > /sys/class/gpio/gpio259/direction
                echo in > /sys/class/gpio/gpio227/direction
                echo mode1 > /sys/kernel/debug/gpio_debug/gpio183/current_pinmux
                
                
                echo 40 > /sys/class/gpio/export
                echo 261 > /sys/class/gpio/export
                echo 229 > /sys/class/gpio/export
                echo low > /sys/class/gpio/gpio214/direction
                echo high > /sys/class/gpio/gpio229/direction
                echo in > /sys/class/gpio/gpio261/direction
                echo mode1 > /sys/kernel/debug/gpio_debug/gpio40/current_pinmux
                echo high > /sys/class/gpio/gpio214/direction
                

                 

                Thanks for your help,

                 

                Kuroneko