• cfry

    Thanks, that is what I'll do, I just want to understand how it works. Ill try again in a few days.

    I also received some instructions on how to install a backport of Pd on Patchbox OS. It did not succeed, I assume I did something wrong.

    posted in I/O hardware diyread more
  • cfry

    How does deken work? Will the search results differ depending on what version of Pure data you have installed? Or is the only difference what type of OS you use?

    posted in I/O hardware diyread more
  • cfry

    thanks, comport worked. But not the others. To get the other externals I have to compile them, right? Just copying them to the externals folder did not work.

    Another question, what do I loose out on if I stick with Pd 0.50.2-3, instead of the latest?

    posted in I/O hardware diyread more
  • cfry

    Hi!

    I successfully installed Patchbox OS:

    [Beta] Patchbox OS image 2020-11-23

    with Pd 0.50.2 installed

    Works like a charm so far! External USB sound card works, headless autostart with chosen pd patch, audio works fine. Almost seems too good to be true.

    Now I would like to install convolve_tilde and timbreID that can be found at GitHub I can not find William Brents webpage anymore.

    Eventually I would like to install comport as well.

    I installed the latest deken-plugin I could find (v0.7.8) through Find externals but I can not find anyone of those three externals.

    What do I need to do to get them? Do I need to install the latest Pd version?

    I do not have the skills to compile from source, yet. For now I just want to understand my options.

    Thanks a lot!

    posted in I/O hardware diyread more
  • cfry

    @JMC64 what Os do you use on the Rp3?

    posted in I/O hardware diyread more
  • cfry

    Hi,
    I am installing Pd on a Raspberry Pi running Buster, the default 32-bit install installed Pd Vanilla through the system Add/Remove Software, which turned out to be Pd 0.49.

    I checked out this guide but it is for purr data.

    How should I do to get the latest vanilla version? Hopefully I can install all needed externals through deken.

    And, is there a better Os install than default Buster? I aim to run the Pi headless.

    Thanks!

    posted in I/O hardware diyread more
  • cfry

    @alexandros said:

    Answer 1: The current code looks better than the one you posted above it (which is apparently something I've used, hopefully in my tutorial and not the book...),

    It is from the tutorial and I believe it was fine in a stepwise educational context. (Why I posted it was because the variables inside the else if() are treated differently. Wild guess that it could be a problem.)

    Thank you so much for that you took time to help me on this. However, this problem does not exist in the old tutorial code(!).

    Look here

    no_crash.png

    I send two updates per millisecond and still no crash. The Pd console reports errors. Pd still works as normal. This is the codes (Arduino and Pd) from your tutorial.

    When using the new codes (both Ardunio sketch and Pd patch) Pd crash/freeze and there is no report in the pd console.

    posted in I/O hardware diyread more
  • cfry

    @alexandros said:

    Have you detected whether the crash happens with else if (in == 'd') or else if (in == 'p')?

    It happens only in else if (in == 'p'). When I bypass that I can update snapshot~ by 1 ms (I assume that 'c' will still be sent by 1 ms intervals).

    In the Pd patch it's probably better to swap the $1 and $2 values in the messages. Have the channel set in a cold inlet and the value in a hot one and then write this message print $2c$1v

    Ok I did that.

    I see in the screenshot of the patch that the PWM message is not connected to [comport]. Is this for some particular reason?

    It is to make sure Pd does not crash/freeze until I want to try the code.

    Maybe the 10ms interval for sending a PWM value to [comport] is a bit too fast. Did you try something slower, like 50ms?

    That made it work. If I use six pwm pins the limit is 150 ms before crash.

    Question 1: Could there something bad that happens around else if (in == 'p')? In another code snippet you used this format:

      while(Serial.available()){
        byte inByte = Serial.read();
        if((inByte >= '0') && (inByte <= '9'))
        temporary = 10 * temporary + inByte - '0';
        else{
          if(inByte == 'p'){
            pwmLEDvalue = temporary;
            temporary = 0;
          }
          else if(inByte == 'd'){
            dspLEDstate = temporary;
            temporary = 0;
          }
        }
        analogWrite(pwmLED, pwmLEDvalue);
        digitalWrite(dspLED, dspLEDstate);
      }
    

    compared to this in the current sketch:

    if (Serial.available()) {
         
        static int temp;
        byte in = Serial.read();
      
        if (isDigit(in)) temp = temp * 10 + in - '0';
        
        else if (in == 'c') {
          channel = temp;
          temp = 0;
        }
           
        else if (in == 'd') {
          digitalWrite(outPins[channel], temp);
          temp = 0;
        }
    
        else if (in == 'p') {
          analogWrite(pwmPins[channel], temp);
          temp = 0;
        }
    
      }
    

    Question 2: Is this crash of Pd and the computer (macOS Mojave) expected behavior in a situation like this? If it is not, maybe it should be reported as a bug. It happens consistently.

    Thoughts: Could there be a problem in [comport]? This crash behavior is identical with the problems I had when using Pdunio/Firmata.

    posted in I/O hardware diyread more
  • cfry

    @alexandros said:

    @cfry the thing is that the last bit of code you posted seems just fine, excluding the calling to pinMode where you're enabling the integrated pull-up resistors. Can you try that code removing these lines in setup(), and instead of heat sensitive sensors or whatever you're currently using, use simple potentiometers and verify whether that works or not? In case it doesn't work, please post a diagram of your circuit in some way (even hand-drawn is ok), as well as the full Arduino sketch and a screenshot of the Pd patch.

    20210331_164954-2.jpg
    arduino_pd_testing.png
    20210331_161600-2.jpg

    int outPins[3] = {2, 4, 7};
    int pwmPins[6] = {3, 5, 6, 9, 10, 11}; 
    
    int channel = 0;
    
    int inPins[2] = {8, 12};
    int analogPins[8] = {0, 1, 2, 3, 4, 5, 6, 7};
    
    // int debug_skip = 0;
    
    void setup() {
       
       for (int i = 0; i < 3; i++) {
        pinMode(outPins[i], OUTPUT);
      }
        for (int i = 0; i < 6; i++) {
        pinMode(pwmPins[i], OUTPUT);
      } 
        for(int i = 0; i < 2; i++) {
        pinMode(inPins[i], INPUT_PULLUP);
      }
    
      Serial.begin(115200);
      
    }
    
    void loop() {
        
    //DO OUTPUTS
      
      if (Serial.available()) {
         
        static int temp;
        byte in = Serial.read();
      
        if (isDigit(in)) temp = temp * 10 + in - '0';
    
        //quote out this section to avoid crash
        
        else if (in == 'c') {
          channel = temp;
          temp = 0;
        }
           
        else if (in == 'd') {
          digitalWrite(outPins[channel], temp);
          temp = 0;
        }
    
        else if (in == 'p') {
          analogWrite(pwmPins[channel], temp);
          temp = 0;
        }
    
        //end quote out here
      
      }
    
    // DO INPUTS
    
    Serial.print("analog");
      
      for(int i = 0; i < 8; i++){
        
        unsigned int analogVal = analogRead (analogPins[i]);
        
        Serial.print(" "); 
        Serial.print(analogVal);
      }
      
      Serial.println(); 
      
      Serial.print("digital");
        
      for(int i = 0; i < 2; i++) {
        
        unsigned int digitalVal = digitalRead(inPins[i]);
        
        Serial.print(" ");
        Serial.print(digitalVal);
      }  
      
      Serial.println(); 
      
    }
    

    If I do the following PureData will always freeze and requires force quit. Occasionally the whole OS becomes sluggish/freeze and need a reboot.

    1. Have this code snippet in the Arduino sketch
        //quote out this section to avoid crash
        
        else if (in == 'c') {
          channel = temp;
          temp = 0;
        }
           
        else if (in == 'd') {
          digitalWrite(outPins[channel], temp);
          temp = 0;
        }
    
        else if (in == 'p') {
          analogWrite(pwmPins[channel], temp);
          temp = 0;
        }
    
        //end quote out here
    
    1. Connect [print $1c$2p] -> [comport]

    (I have also noted different behavior using [comport] from the tutorial by copy and paste compared to creating a comport object (cmd+1 and then typing). At times the latter did not work at all, but after reboot of the system both seems to work.)

    Thanks for helping

    Here is the patch from screenshot above:
    tmp_arduino_pd_testing.pd

    posted in I/O hardware diyread more
  • cfry

    Thank you for replying and sorry if I am unclear. I will try to slow down a bit.

    @alexandros said:

    @cfry definitely not necessary to use two Arduinos. I can't really understand where your problem lies.

    -The problem is that it does not work when I try to use an arbitrary combination of pins in different modes (Digital in, Digital out, Analog in, Analog out).

    Another problem is that I have a hard time reading the code parts that are handling the conversion data in order to do the serial communication, although I understand the principle of it.

    You didn't reply to my earlier question about the pinMode calls where you use INPUT_PULLUP on analog inputs. Is this really necessary?

    -I assumed that the problem lied in void ()loop as a conflict between the output and input handling sections. And that pinMode calls in void setup() was not relevant in this case. That is why I did not answer that question directly.

    Also, why not use the analog pins in an array like with the digital pins? It will save a lot of writing and it's less error prone.

    -I was foreseeing that I may want to configure those pins individually, but I can set it up with a loop for now.

    One thing you might want to consider is having the Arduino notify Pd when it's done sending all its data and that it's ready to receive. That could be done at the end of the loop() function like this:

    Serial.print("done ");
    Serial.println("bang");
    

    And in Pd have a [r done] object which will output a bang. Use this bang to send data from Pd to the Arduino by unpacking a list with all the accumulated data, possibly with a [list-abs/list-drip].
    I use this notification technique in my 3dPdModular system, but there's a LOT of data there and it was only necessary. Perhaps you could try it out.

    -I will try that.

    Since I consider this to be basically your code I assumed that you could easily just insert the code for both input and output in void loop() in a way that works and that would show me how to solve it. Then I would be able to do further explorations and it would be end of story.

    I will digest this a bit and may start a new thread, since this one has slided from "Having lots of switches into Pd" to "having a working code template for communicating between Arduino and Pd using and an arbitrary mixture of pin modes".

    Please let me know if this still does not make sense. Thank you so much!

    posted in I/O hardware diyread more

Internal error.

Oops! Looks like something went wrong!