Bare Conductive Touch Board + proximity sensing

narner's icon

I'm wanting to use the Max communication patch from Bare Conductive (https://github.com/BareConductive/Max-MSP-Touch-Board-communication) to map proximity with the Touch Board, similar to this Arduino code from Bare Conductive (https://github.com/BareConductive/prox-volume).

However, I've not been able to determine what parameters in the Max communication patch would correspond to proximity - anyone have any insight? Or better yet, a modified example patch?

Thank you!

davidestevens's icon

Here's what I do. And I use the Datastream.ino Arduino sketch on the touchboard.
You'll need to do some scaling on the values - I capture the max & min incoming values & then use those to rescale the touchboard data to 0.-1. .

Max Patch
Copy patch and select New From Clipboard in Max.

narner's icon

Ok, I kind of follow - the issue I seem to be having is I'm only seeing any sort of proximity data when my hand is touching my sensor when using the Max examples, but using the Arduino sketch I mentioned above , the proximity readings tend to be much smoother...any theories at all?

narner's icon

Sorry, some more detail:

I added the code below to the DataStream Arduino sketch, which was taken from the "prximity-mp3" example.

`

// mapping and filter definitions
#define LOW_DIFF 0
#define HIGH_DIFF 50
#define filterWeight 0.3f // 0.0f to 1.0f - higher value = more smoothing
float lastProx = 0;

///PRINT PROXIMITY VALUE FOR ELECTRODE 0

// read the difference between the measured baseline and the measured continuous data
int reading = MPR121.getBaselineData(PROX_ELECTRODE)-MPR121.getFilteredData(PROX_ELECTRODE);

// constrain the reading between our low and high mapping values
unsigned int prox = constrain(reading, LOW_DIFF, HIGH_DIFF);

// implement a simple (IIR lowpass) smoothing filter
lastProx = (filterWeight*lastProx) + ((1-filterWeight)*(float)prox);

// map the LOW_DIFF..HIGH_DIFF range to 0..254 (max range for MP3player.setVolume())
uint8_t proximityOutput = (uint8_t)map(lastProx,LOW_DIFF,HIGH_DIFF,0,-60);

Serial.print("PROXIMITY: ");
Serial.print(proximityOutput);
Serial.println();`

And then the Max code below to the Bare Conductive Touch Board Communication patch to get that new proximity information:

{
    "boxes" : [         {
            "box" :             {
                "maxclass" : "number",
                "outlettype" : [ "int", "bang" ],
                "patching_rect" : [ 45.5, 2019.0, 50.0, 20.0 ],
                "id" : "obj-166",
                "fontname" : "Arial",
                "parameter_enable" : 0,
                "numinlets" : 1,
                "numoutlets" : 2,
                "fontsize" : 12.0
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "unpack 1 2 3 4 5 6 7 8 9 10 11 12 13",
                "outlettype" : [ "int", "int", "int", "int", "int", "int", "int", "int", "int", "int", "int", "int", "int" ],
                "patching_rect" : [ 45.5, 1978.99646, 205.0, 20.0 ],
                "id" : "obj-162",
                "fontname" : "Arial",
                "color" : [ 0.694118, 0.694118, 0.694118, 1.0 ],
                "numinlets" : 1,
                "numoutlets" : 13,
                "fontsize" : 12.0
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "route",
                "outlettype" : [ "", "" ],
                "patching_rect" : [ 45.5, 1947.99646, 38.0, 20.0 ],
                "id" : "obj-163",
                "fontname" : "Arial",
                "color" : [ 0.694118, 0.694118, 0.694118, 1.0 ],
                "numinlets" : 2,
                "numoutlets" : 2,
                "fontsize" : 12.0
            }

        }
,         {
            "box" :             {
                "maxclass" : "newobj",
                "text" : "p PROXIMITY Serial/OSC switcher",
                "outlettype" : [ "", "" ],
                "patching_rect" : [ 68.0, 1904.0, 197.0, 20.0 ],
                "id" : "obj-161",
                "fontname" : "Arial",
                "numinlets" : 0,
                "numoutlets" : 2,
                "fontsize" : 12.0,
                "patcher" :                 {
                    "fileversion" : 1,
                    "appversion" :                     {
                        "major" : 6,
                        "minor" : 1,
                        "revision" : 10,
                        "architecture" : "x86"
                    }
,
                    "rect" : [ 194.0, 112.0, 640.0, 480.0 ],
                    "bglocked" : 0,
                    "openinpresentation" : 0,
                    "default_fontsize" : 12.0,
                    "default_fontface" : 0,
                    "default_fontname" : "Arial",
                    "gridonopen" : 1,
                    "gridsize" : [ 15.0, 15.0 ],
                    "gridsnaponopen" : 1,
                    "statusbarvisible" : 2,
                    "toolbarvisible" : 1,
                    "boxanimatetime" : 200,
                    "imprint" : 0,
                    "enablehscroll" : 1,
                    "enablevscroll" : 1,
                    "devicewidth" : 0.0,
                    "description" : "",
                    "digest" : "",
                    "tags" : "",
                    "boxes" : [                         {
                            "box" :                             {
                                "maxclass" : "message",
                                "text" : "PROXIMITY: 0 0 0 0 0 0 0 0 0 0 0 0",
                                "outlettype" : [ "" ],
                                "patching_rect" : [ 50.0, 177.0, 199.0, 18.0 ],
                                "id" : "obj-171",
                                "fontname" : "Arial",
                                "numinlets" : 2,
                                "numoutlets" : 1,
                                "fontsize" : 12.0
                            }

                        }
,                         {
                            "box" :                             {
                                "maxclass" : "newobj",
                                "text" : "r o",
                                "outlettype" : [ "" ],
                                "patching_rect" : [ 207.0, 100.0, 25.0, 20.0 ],
                                "id" : "obj-166",
                                "fontname" : "Arial",
                                "numinlets" : 0,
                                "numoutlets" : 1,
                                "fontsize" : 12.0
                            }

                        }
,                         {
                            "box" :                             {
                                "maxclass" : "newobj",
                                "text" : "r s",
                                "outlettype" : [ "" ],
                                "patching_rect" : [ 50.0, 100.0, 24.0, 20.0 ],
                                "id" : "obj-155",
                                "fontname" : "Arial",
                                "numinlets" : 0,
                                "numoutlets" : 1,
                                "fontsize" : 12.0
                            }

                        }
,                         {
                            "box" :                             {
                                "maxclass" : "message",
                                "text" : "PROXIMITY:",
                                "outlettype" : [ "" ],
                                "patching_rect" : [ -29.0, 134.099976, 79.0, 18.0 ],
                                "id" : "obj-149",
                                "fontname" : "Arial",
                                "numinlets" : 2,
                                "numoutlets" : 1,
                                "fontsize" : 12.0
                            }

                        }
,                         {
                            "box" :                             {
                                "maxclass" : "message",
                                "text" : "/proximity",
                                "outlettype" : [ "" ],
                                "patching_rect" : [ 146.0, 142.099976, 62.0, 18.0 ],
                                "id" : "obj-150",
                                "fontname" : "Arial",
                                "numinlets" : 2,
                                "numoutlets" : 1,
                                "fontsize" : 12.0
                            }

                        }
,                         {
                            "box" :                             {
                                "maxclass" : "outlet",
                                "patching_rect" : [ 85.0, 259.0, 30.0, 30.0 ],
                                "id" : "obj-173",
                                "numinlets" : 1,
                                "numoutlets" : 0,
                                "comment" : ""
                            }

                        }
,                         {
                            "box" :                             {
                                "maxclass" : "outlet",
                                "patching_rect" : [ 50.0, 259.0, 30.0, 30.0 ],
                                "id" : "obj-174",
                                "numinlets" : 1,
                                "numoutlets" : 0,
                                "comment" : ""
                            }

                        }
],
                    "lines" : [                         {
                            "patchline" :                             {
                                "source" : [ "obj-171", 0 ],
                                "destination" : [ "obj-174", 0 ],
                                "hidden" : 0,
                                "disabled" : 0
                            }

                        }
,                         {
                            "patchline" :                             {
                                "source" : [ "obj-166", 0 ],
                                "destination" : [ "obj-150", 0 ],
                                "hidden" : 0,
                                "disabled" : 0
                            }

                        }
,                         {
                            "patchline" :                             {
                                "source" : [ "obj-155", 0 ],
                                "destination" : [ "obj-149", 0 ],
                                "hidden" : 0,
                                "disabled" : 0
                            }

                        }
,                         {
                            "patchline" :                             {
                                "source" : [ "obj-150", 0 ],
                                "destination" : [ "obj-173", 0 ],
                                "hidden" : 0,
                                "disabled" : 0
                            }

                        }
,                         {
                            "patchline" :                             {
                                "source" : [ "obj-149", 0 ],
                                "destination" : [ "obj-173", 0 ],
                                "hidden" : 0,
                                "disabled" : 0
                            }

                        }
,                         {
                            "patchline" :                             {
                                "source" : [ "obj-149", 0 ],
                                "destination" : [ "obj-171", 0 ],
                                "hidden" : 0,
                                "disabled" : 0
                            }

                        }
]
                }
,
                "saved_object_attributes" :                 {
                    "default_fontface" : 0,
                    "default_fontname" : "Arial",
                    "default_fontsize" : 12.0,
                    "description" : "",
                    "digest" : "",
                    "fontface" : 0,
                    "fontname" : "Arial",
                    "fontsize" : 12.0,
                    "globalpatchername" : "",
                    "tags" : ""
                }

            }

        }
],
    "lines" : [         {
            "patchline" :             {
                "source" : [ "obj-162", 0 ],
                "destination" : [ "obj-166", 0 ],
                "hidden" : 0,
                "disabled" : 0
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-163", 0 ],
                "destination" : [ "obj-162", 0 ],
                "hidden" : 0,
                "disabled" : 0
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-161", 0 ],
                "destination" : [ "obj-163", 0 ],
                "hidden" : 0,
                "disabled" : 0
            }

        }
,         {
            "patchline" :             {
                "source" : [ "obj-161", 1 ],
                "destination" : [ "obj-163", 1 ],
                "hidden" : 0,
                "disabled" : 0
            }

        }
],
    "appversion" :     {
        "major" : 6,
        "minor" : 1,
        "revision" : 10,
        "architecture" : "x86"
    }

}

However, the data coming into the Max patch seems to be really slow...I'm only getting any sort of proximity reading if my hand is directly touching my electric paint sensor.