assurance-tunnel
assurance-tunnel
assurance-tunnel
assurance-tunnel

[ANSWERED] Serial Watcher Binary and Arduino



  • Hello from Italy. I build a patch on isadora (3.07)  using Serial Watcher Binary Actor. It’s just a simple sensor triggering a digital input on Arduino sending just a 0 - 1 for sensor on/off. In arduino I used the serial.postln(1, DEC) to match the Serial Watcher pattern “1” value: integer = digits I wrote in the edit input parser. Everything works fine but sometimes the Serial Watcher freeze and I need to send a trig to the reset actor’s input. The Arduino I can see it is working since I coupled a LED that blinks when sensor is or off. At the moment I solved sending a reset trig to the object every 10 or 20 seconds, but I’m not sure if this may cause some problem to the Actor since the patch is part of an interactive installation for an art exhibition. I don’t know if maybe increase the timeout parameter, basically the sensor will be triggered by the visitor once in a while. Any suggestion will be very appreciated. Please notice that most of the time the Actor works fine, maybe it freeze after an hour or so maybe never in a day... I tried to swap USB port and change the cable. but I need to make it work 100%. Thanks. Ciao Riccardo Mazza 


  • Tech Staff

    @Juriaan @fubbi any ideas? 

    I'm not well-versed with Arduinos.


  • Tech Staff

    @rikimazza said:

    serial.postln(

     Have you tried using Serial.print()
    I don't think it should make a difference, but perhaps some glitch exists in the data sent?
    Can you see any changes in the sent data in the Isadora Monitor Window?



  • @rikimazza one other note, are you sending the value in every update loop in your arduino code? If so it is better to check if the value has changed and only send the value if it is different, you may just be choking the serial port sending data that is not needed.



  • On occasion and depending on the payload, you may have to use .println() to send the return character in order to get it out of the buffer, or you need to flush the serial buffer altogether when you want to transmit the payload. Many years ago I had a similar issue, and I vaguely recall this being part of my solution.



  • @rikimazza This is not directly helpful for your question, sorry, but I prefer to skip the whole serial route and here is what I'd do

    The best thing to do is really to get a teensy. You can set it up to be a usb midi interface or HID or whatever you want, bypassing all the serial grief.

    Or to get a solid signal from the arduino you can send it as midi to a midi interface. If you get a midi plug and a resistor for like a euro its actually quite easy to send midi (receiving is a bit more complicated).

    That's just my personal preference based on what I feel like dealing with in a performance situation. I rather deal with the note on watcher than the serial in watcher when it comes to sending tiny bits of  data around the stage to one or multiple machines.

    If you dont want to buy a teensy, than all you have to do is this:



  • can you post your Arduino code - just too check there isn't something unusual in it.



  • Thanks very much to all for suggestions. I guess the problem is due to serial communication of the Arduino and serial actor. I solved sending a reset message with a pulse trigger every 3 seconds to the rest input of Serial Actor and it works well. In Arduino I used the internal 10Khom resistor on pin 7 using  INPUT_PULLUP with the following code. When sensor is on the LED also lit so that I can be sure the sensor reacts . 

    void setup() {
      

    Serial.begin(9600);

      pinMode(13, OUTPUT);
      pinMode(7, INPUT_PULLUP);

    }

    void loop() {

      int b1 = digitalRead(7);

      if (b1 == LOW) {
        
        digitalWrite(13, HIGH); //accende LED interno per testing
        
        Serial.println(1,DEC); //Seriale da inviare a ISADORA
        Serial.println(1);
      
      } else {
        
        digitalWrite(13, LOW);
        Serial.println(1,DEC);
        Serial.println(0);
        
        }

    };

    // on isadora edit serial bynary actor -- "1"  value:integer = 4 digits



  • @fubbi wow fantastic!!! thanks for sharing!!



  • @fred thanks Fred, yes Arduino is working I use the led to check. Anyway I solved sending periodically a rest message to the Actor and it looks like working well.



  • @dusx thanks Dusking. Yes the problem anyway can be solved sending a reset message maybe it can be Arduino with my Mac... but sending a reste periodically to the actor it works and it looks like it is stable too.  



  • @rikimazza


    I know you have a workaround, but from this code the suggestion in freds post is correct - the code sends the values as often as the board can - way faster than you need. Adding a small delay in the Arduino code should remove the need to reset the actor, and reduce the work you are asking the computer to do. If you add delay(10); just before the final bracket it would stop for 10 milliseconds each time, and you would only be sending the message slightly less than 100 times a second.