• Products
    • Isadora
    • Get It
    • ADD-ONS
    • IzzyCast
    • Get It
  • Forum
  • Help
  • Werkstatt
  • Newsletter
  • Impressum
  • Dsgvo
  • Press
  • Isadora
  • Get It
  • ADD-ONS
  • IzzyCast
  • Get It
  • Press
  • Dsgvo
  • Impressum

Navigation

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Tags

    [SOLVED] Control multiple servos with Isadora -> Arduino (example attached)

    Hardware
    arduino servos
    5
    20
    4672
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Fred
      Fred last edited by Fred

      I want to send serial data from Isadora to 4 separate servos.

      I thought I would use the send Serial actor and create an string with an identifier for each servo followed by the position, so one of my send serial actors would have:

      "A" P1

      P1 will be an integer that will be the servo position.

      My arduino code for handling the serial in data is:

        if (Serial.available() > 0) {
          inString = Serial.read();
          if (inString.substring(0,0) == 'A') {
            String valString  = inString.substring(1);
            pos = valString.toInt();
            servo1.write(pos); 
            inString = "";
          }
          if (inString.substring(0,0) == 'B') {
            String valString  = inString.substring(1);
            pos = valString.toInt();
           servo2.write(pos); 
           inString = "";
          }
        }

      I get a response from the servo, but not what I want, any ideas or examples on how to do this properly? I figure this is not really going to work as I cannot send data to 2 servos at the same time.

      If I have a send serial actor with P1 P2 P3 P4 how can I get these as separate values in Arduino?

      http://www.fredrodrigues.net/
      https://github.com/fred-dev
      OSX 13.6.4 (22G513) MBP 2019 16" 2.3 GHz 8-Core i9, Radeon Pro 5500M 8 GB, 32g RAM
      Windows 10 7700K, GTX 1080ti, 32g RAM, 2tb raided SSD

      Fred 1 Reply Last reply Reply Quote 0
      • Fred
        Fred @Fred last edited by

        @fred

        So now I have something that works, but it is very slow, I cannot update more than 1 time per second and commands seem to lag one behind (they send through when I send another command).

        I took a pretty different route that I have used before with my own code but not via Isadora: I send all the data at once as a string and parse it on the arduino side, here is the arduino code:

        #include <Servo.h>
        Servo myServos[4];  // create servo object to control a servo
        // twelve servo objects can be created on most boards int pos = 0;    // variable to store the servo position
        String serialString;         // incoming serial byte
        int servoPositions[4];
        void setup() {
          myServos[0].attach(8);  // attaches the servo on pin 9 to the servo object
          myServos[1].attach(7);
          myServos[2].attach(6);
          myServos[3].attach(5);
          Serial.begin(57600);
        } void loop() {   if (Serial.available()) {     serialString = Serial.readString();
            String servo1 = serialString.substring(serialString.indexOf('A') + 1, serialString.indexOf('B') );
            servoPositions[0] = servo1.toInt();
            String servo2 = serialString.substring(serialString.indexOf('B') + 1, serialString.indexOf('C') );
            servoPositions[1] = servo2.toInt();
            String servo3 = serialString.substring(serialString.indexOf('C') + 1, serialString.indexOf('D') );
            servoPositions[2] = servo3.toInt();
            String servo4 = serialString.substring(serialString.indexOf('D') + 1, serialString.indexOf('|') );
            servoPositions[3] = servo4.toInt();     serialString = "";
            for (int i = 0; i < 4; i++) {
              myServos[i] .write(servoPositions[i]);
            }
          }
        }

        And my send serial actor now has:

         "A" P1 "B" P2 "C" P3 "D" P4 "|\r"

        It works, but so slowly that it is not useable. 

        Maybe @mark (help...sorry to tag you), or anyone else can provide a better way to do this? I have done communication the other way a lot, Arduino to Isadora, but not this way, I see some references to posts on the old forum, but no examples or posts that are relevant

        http://www.fredrodrigues.net/
        https://github.com/fred-dev
        OSX 13.6.4 (22G513) MBP 2019 16" 2.3 GHz 8-Core i9, Radeon Pro 5500M 8 GB, 32g RAM
        Windows 10 7700K, GTX 1080ti, 32g RAM, 2tb raided SSD

        DusX 1 Reply Last reply Reply Quote 0
        • DusX
          DusX Tech Staff @Fred last edited by

          @fred

          can you post the Isadora file you are suing to send the strings?
          I can't imagine why it would be limited in speed. The string is much shorter than a universe of dmx, and that is easy sent at 40hz.

          Troikatronix Technical Support

          • New Support Ticket Link: https://support.troikatronix.com/support/tickets/new
          • My Add-ons: https://troikatronix.com/add-ons/?u=dusx
          • Profession Services: https://support.troikatronix.com/support/solutions/articles/13000109444-professional-services

          Running: Win 11 64bit, i7, M.2 PCIe SSD's, 32gb DDR4, nVidia GTX 4070 | located in Ontario Canada.

          Fred 1 Reply Last reply Reply Quote 0
          • Fred
            Fred @DusX last edited by

            @dusx I am assuming I have made a fundamental error in my approach to solving this, but here is the patch.Isasdora 4 servos.izz

            http://www.fredrodrigues.net/
            https://github.com/fred-dev
            OSX 13.6.4 (22G513) MBP 2019 16" 2.3 GHz 8-Core i9, Radeon Pro 5500M 8 GB, 32g RAM
            Windows 10 7700K, GTX 1080ti, 32g RAM, 2tb raided SSD

            DusX 1 Reply Last reply Reply Quote -1
            • DusX
              DusX Tech Staff @Fred last edited by

              @fred

              I don't see any reason that it shouldn't be able to run much faster.
              The Serial send is very simple.
              The Arduino code isn't running any large loops or any thing.

              Are the Baud rates matched?

              Troikatronix Technical Support

              • New Support Ticket Link: https://support.troikatronix.com/support/tickets/new
              • My Add-ons: https://troikatronix.com/add-ons/?u=dusx
              • Profession Services: https://support.troikatronix.com/support/solutions/articles/13000109444-professional-services

              Running: Win 11 64bit, i7, M.2 PCIe SSD's, 32gb DDR4, nVidia GTX 4070 | located in Ontario Canada.

              Fred 2 Replies Last reply Reply Quote 0
              • Fred
                Fred @DusX last edited by

                @dusx yes, I tried a lot of baud rates (always matching). Looking at the serial monitor I. Isadora they dont send fast either. I'll try with raw serial tomorrow.

                http://www.fredrodrigues.net/
                https://github.com/fred-dev
                OSX 13.6.4 (22G513) MBP 2019 16" 2.3 GHz 8-Core i9, Radeon Pro 5500M 8 GB, 32g RAM
                Windows 10 7700K, GTX 1080ti, 32g RAM, 2tb raided SSD

                1 Reply Last reply Reply Quote 0
                • Juriaan
                  Juriaan Tech Staff last edited by

                  Hmmm interesting. I just did a project with controlling Servo's using Isadora, personally I use OSC to make the communication between both. It makes no sense that Isadora has a limit on the speed of the Serial output, your code is correct.

                  Isadora 3.1.1, Dell XPS 17 9710, Windows 10
                  Interactive Performance Designer, Freelance Artist, Scenographer, Lighting Designer, TroikaTronix Community moderator
                  Always in for chatting about interaction in space / performance design. Drop me an email at hello@juriaan.me

                  Fred 1 Reply Last reply Reply Quote 0
                  • barneybroomer
                    barneybroomer Beta Gold last edited by

                    Did you try to control servo's from IDE Arduino directly? Do they behave like they used to do? Maybe the problem is there.

                    Mac Mini M1 2020 / OSX 11.7
                    MacBook Pro 2,3 Ghz Intel 8 core I9 / OSX 10.15.7
                    MacBook Pro 2,2 Ghz Intel 8 core I7 / OSX 10.15.7

                    and a Motorola DynaTAC 8000X ;)

                    Fred 1 Reply Last reply Reply Quote 0
                    • Fred
                      Fred @barneybroomer last edited by

                      @barneybroomer All servos work fine without Isadora

                      http://www.fredrodrigues.net/
                      https://github.com/fred-dev
                      OSX 13.6.4 (22G513) MBP 2019 16" 2.3 GHz 8-Core i9, Radeon Pro 5500M 8 GB, 32g RAM
                      Windows 10 7700K, GTX 1080ti, 32g RAM, 2tb raided SSD

                      1 Reply Last reply Reply Quote 0
                      • Fred
                        Fred @DusX last edited by

                        @dusx I think there is a problem with the serial send function in Isadora, not sure. I just made the same structure with openframeworks, the same Arduino and same servos and pins etc and it works perfectly. Also just sending a string a cutting it up the same way on the Arduino.

                        I have marginally better results with send raw serial, but still not at all usable, massive delays and commands seem to queue.

                        This is for a class, so now I need to run an intermediate app and get OSC from Isadora.

                        It would be great if someone else could test this, or suggest another way to send multiple values and verify that the send serial is functioning, before I go for a bug report. To me it seems there is something wrong with the serial sending, like it is sending a really huge buffer that is pre allocated and takes ages to send and receive.

                        http://www.fredrodrigues.net/
                        https://github.com/fred-dev
                        OSX 13.6.4 (22G513) MBP 2019 16" 2.3 GHz 8-Core i9, Radeon Pro 5500M 8 GB, 32g RAM
                        Windows 10 7700K, GTX 1080ti, 32g RAM, 2tb raided SSD

                        bonemap 1 Reply Last reply Reply Quote 0
                        • Fred
                          Fred @Juriaan last edited by

                          @juriaan I would love to use OSC but I am looking at a pile of arduino UNO's so no joy.

                          http://www.fredrodrigues.net/
                          https://github.com/fred-dev
                          OSX 13.6.4 (22G513) MBP 2019 16" 2.3 GHz 8-Core i9, Radeon Pro 5500M 8 GB, 32g RAM
                          Windows 10 7700K, GTX 1080ti, 32g RAM, 2tb raided SSD

                          1 Reply Last reply Reply Quote 0
                          • bonemap
                            bonemap Izzy Guru @Fred last edited by

                            @fred said:

                            a problem with the serial send function in Isadora

                             Hi @Fred,

                            I have just fired up an Arduino Micro with a PMW 12v relay plus a 3v infrared remote, I had no problem communicating to both at the same time running a pulse generator at 30 hz through a sequential trigger to switch the relay and a pulse generator at 5 hz switching the remote. I did not see any issues with the Send Serial Data in the patch setup. 

                            http://bonemap.com | Australia
                            Izzy STD 4.2 | USB 3.6 | + Beta
                            MBP 16” 2019 2.4 GHz Intel i9 64GB AMD Radeon Pro 5500 8 GB 4TB SSD | 14.5 Sonoma
                            Mac Studio 2023 M2 Ultra 128GB | OSX 15.3 Sequoia
                            A range of deployable older Macs

                            Fred 1 Reply Last reply Reply Quote 0
                            • Fred
                              Fred @bonemap last edited by

                              @bonemap can you send me your patch and Arduino code to test here? I did not have trouble when using single parameters with the send serial but only with multiple parameters on a send serial.

                              http://www.fredrodrigues.net/
                              https://github.com/fred-dev
                              OSX 13.6.4 (22G513) MBP 2019 16" 2.3 GHz 8-Core i9, Radeon Pro 5500M 8 GB, 32g RAM
                              Windows 10 7700K, GTX 1080ti, 32g RAM, 2tb raided SSD

                              bonemap 1 Reply Last reply Reply Quote 0
                              • bonemap
                                bonemap Izzy Guru @Fred last edited by bonemap

                                @fred said:

                                send me your patch and Arduino code

                                Here it is, but be aware that the code and the patch are not well annotated.

                                Arduino-Isadora-Relay-Fan-test.zip (apologies I uploaded the wrong files - these are a match)

                                http://bonemap.com | Australia
                                Izzy STD 4.2 | USB 3.6 | + Beta
                                MBP 16” 2019 2.4 GHz Intel i9 64GB AMD Radeon Pro 5500 8 GB 4TB SSD | 14.5 Sonoma
                                Mac Studio 2023 M2 Ultra 128GB | OSX 15.3 Sequoia
                                A range of deployable older Macs

                                Fred 1 Reply Last reply Reply Quote 0
                                • Fred
                                  Fred @bonemap last edited by Fred

                                  @bonemap Cheers, I just took a look, and I also had no trouble sending single characters as you are doing in this example, the issue I am getting is sending more than that, I need to control 4 servos so I have to send 4 different kinds of messages, that should be readable as strings and then split them out at the other end. I make a string like this (using either send serial or send raw serial) A<intvalA>B<intvalB>C<intvalC>D<intvalD>| where <intvalN> are integers (without using the :C delimiter in the send serial so they are sent as ascii), or just using the text formater and creating a string and sending with send Raw Serial.


                                  Either way the messages are received properly but with a lot of delay and not reliably. As I said, the simple versions, just sending a char to switch a Boolean seems to work fine, but more than that gives issues.


                                  Sending the same strings from an application I wrote myself works fine and is very responsive, so either I am misunderstanding how the formatting in the send serial actor works, or there is an issue. It would still be great if someone can test something closer to what I am doing.

                                  http://www.fredrodrigues.net/
                                  https://github.com/fred-dev
                                  OSX 13.6.4 (22G513) MBP 2019 16" 2.3 GHz 8-Core i9, Radeon Pro 5500M 8 GB, 32g RAM
                                  Windows 10 7700K, GTX 1080ti, 32g RAM, 2tb raided SSD

                                  bonemap 1 Reply Last reply Reply Quote 0
                                  • bonemap
                                    bonemap Izzy Guru @Fred last edited by bonemap

                                    @fred said:

                                    great if someone can test something closer to what I am doing

                                     Yep! well my other projects use NodeMCU and OSC, have not used longer strings through the Send Serial Data modules that I can recall. I hope you can work it out.

                                    best wishes

                                    Russell 

                                    http://bonemap.com | Australia
                                    Izzy STD 4.2 | USB 3.6 | + Beta
                                    MBP 16” 2019 2.4 GHz Intel i9 64GB AMD Radeon Pro 5500 8 GB 4TB SSD | 14.5 Sonoma
                                    Mac Studio 2023 M2 Ultra 128GB | OSX 15.3 Sequoia
                                    A range of deployable older Macs

                                    Fred 1 Reply Last reply Reply Quote 0
                                    • Fred
                                      Fred @bonemap last edited by

                                      @bonemap yes I much prefer to use other protocols but this should work, and it is for teaching....it is easier to keep everything in one place for beginner students.

                                      At any rate, here is the Isadora patch and the arduino file in case anyone has the time to take a look.Isadora-Arduino serial version _not working.zip

                                      http://www.fredrodrigues.net/
                                      https://github.com/fred-dev
                                      OSX 13.6.4 (22G513) MBP 2019 16" 2.3 GHz 8-Core i9, Radeon Pro 5500M 8 GB, 32g RAM
                                      Windows 10 7700K, GTX 1080ti, 32g RAM, 2tb raided SSD

                                      1 Reply Last reply Reply Quote 1
                                      • Juriaan
                                        Juriaan Tech Staff last edited by

                                        Will hook up an Arduino and give it a shot when I get back from work.

                                        Isadora 3.1.1, Dell XPS 17 9710, Windows 10
                                        Interactive Performance Designer, Freelance Artist, Scenographer, Lighting Designer, TroikaTronix Community moderator
                                        Always in for chatting about interaction in space / performance design. Drop me an email at hello@juriaan.me

                                        Fred 1 Reply Last reply Reply Quote 0
                                        • Fred
                                          Fred @Juriaan last edited by

                                          @juriaan @bonemap

                                          I found out what the issue is. Arduino read as string is very slow and takes 2.5 seconds to resolve. I have a version now that reads byte by byte and it works great. I have attached the Arduino and Isadora files here.Isadora-Arduino serial version _WORKING!.zip

                                          http://www.fredrodrigues.net/
                                          https://github.com/fred-dev
                                          OSX 13.6.4 (22G513) MBP 2019 16" 2.3 GHz 8-Core i9, Radeon Pro 5500M 8 GB, 32g RAM
                                          Windows 10 7700K, GTX 1080ti, 32g RAM, 2tb raided SSD

                                          DusX 1 Reply Last reply Reply Quote 1
                                          • DusX
                                            DusX Tech Staff @Fred last edited by

                                            @fred

                                            Good to hear.. I was actually going thru your code to debug this last night and felt it was on the processing side but couldn't be sure yet.

                                            Troikatronix Technical Support

                                            • New Support Ticket Link: https://support.troikatronix.com/support/tickets/new
                                            • My Add-ons: https://troikatronix.com/add-ons/?u=dusx
                                            • Profession Services: https://support.troikatronix.com/support/solutions/articles/13000109444-professional-services

                                            Running: Win 11 64bit, i7, M.2 PCIe SSD's, 32gb DDR4, nVidia GTX 4070 | located in Ontario Canada.

                                            1 Reply Last reply Reply Quote 1
                                            • First post
                                              Last post