Pages: 1 2 [3] 4   Go Down
Author Topic: multiplexing and max/msp … a survey  (Read 4163 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 27
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

unplugged d0 and d1 programmed it and then replugged them both in… cool. however still no print out in arduino.app when i twist the pot. typically i see a stream of data in the sketch window when i test stuff like this… but i haevtn really looked at this guys code to see if thats how its setup.

by the way youre a champ for helping me with all of this jazz!

i forgot to mention on the last image i took out the pot to make it less confusing looking.
Logged

Daniel
Guest
 Bigger Bigger  Smaller Smaller  Reset Reset

whew

i think we can just thank god that you didn't blow up...smiley
It only too me two minutes to help, as I'm designing a web site and when my email went 'ding' it was a good distraction.  I guess that's what the team means by the "support" that they provide for official Arduino products.... i.e. support by someone other than the team.  ;D  Ok, ok , they're paying for the hosting.

Quote
beginSerial(9600);

that's wrong, check the reference and comment out the other serial command and it should work.
 
You're on your own now, Vancouver sushi is calling.

D
« Last Edit: September 22, 2007, 10:04:42 pm by Daniel » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 27
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

right on man… have poke roll for me ;] i think im gonna quit for the night too. hopefully we can get this crap rolling soon.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 27
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hmm what makes you think that the 9600 baud was incorrect. i really have no idea what it should be if thats wrong. i basically just copy pasted the text from the tutorial.

however that said, when i uncommented the this line:
Code:
Serial.println(bin[count]);
in the serial inspecting window i did get it counting 0 1 10 100 101 110 111 etc.

Lastly i moved the jumpers from the 4051 to only occupy d2 d3 and d4 so that way no more unplugging and plugging back in every time i reprogram the arduino. it also seem according to this code that 2 3 and 4 are the ones hes calling as per this line

Code:
 pinMode(2, OUTPUT);    // s0
  pinMode(3, OUTPUT);    // s1
  pinMode(4, OUTPUT);    // s2
Logged

Daniel
Guest
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
hmm what makes you think that the 9600 baud was incorrect.

Like I said, check the reference... there is no "beginSerial" command.
 
file://localhost/Applications/arduino-0009/reference/Serial_Begin.html

D
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 27
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

whoops. sorry. hopefully this isn't way more hand holding than you counted on… i'm just hoping i haven't bit off more than i can chew. switched that code out. but in looking at the code i don't think there is anything to tell the arduino.app to read the pins when a pots values change. now this is the part i'm confused about do i use an analog read http://www.arduino.cc/en/Reference/AnalogRead which would only check the values coming out of the 4051 into the a0 port. or do i read all the values from the digital pins … http://www.arduino.cc/en/Reference/DigitalRead. seems like analog since the digital pins are all 1/0 rather than variable.

thanks again for all your help i really do appreciate it. and i think if we get this thing rolling it could serve as a rad tutorial for other folks step by step wise.
Logged

Daniel
Guest
 Bigger Bigger  Smaller Smaller  Reset Reset

hmm

sounds like more work than I have time for, but maybe someone else will jump in here and help you with that part?

D
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 27
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

right on. thanks for your help thus far. to anyone else on the radar heres the code i have running now:
Code:
/*
 * codeexample for useing a 4051 * analog multiplexer / demultiplexer
 * by david c. and tomek n.* for k3 / malmö högskola
 *
 */  

int led = 13; //just a led
int r0 = 0; //value select pin at the 4051 (s0)
int r1 = 0; //value select pin at the 4051 (s1)
int r2 = 0; //value select pin at the 4051 (s2)
int row = 0; // storeing the bin code
int count = 0; // just a count

int analogPin = 0;
int val = 0;   // variable to store the read value
int threshold = 512;   // threshold

int bin [] = {000, 1, 10, 11, 100, 101, 110, 111};//bin = binär, some times it is so easy

void setup(){
  Serial.begin(9600);
  pinMode(2, OUTPUT);    // s0
  pinMode(3, OUTPUT);    // s1
  pinMode(4, OUTPUT);    // s2


}

void loop () {

  for (count=0; count<=7; count++) {
    row = bin[count];      
    r0 = row & 0x01;
    r1 = (row>>1) & 0x01;
    r2 = (row>>2) & 0x01;
    digitalWrite(2, r0);
    digitalWrite(3, r1);
    digitalWrite(4, r2);
    //Serial.println(bin[count]);
    delay (100);
    
    val = analogRead(analogPin);   // read the input pin
  if (val >= threshold) {
    Serial.print(val, DEC);
  } else {
    Serial.print("off ");
  }
    
  }  

}

currently it checks the pot to see if its been moved about half way and then it prints the value. otherwise it prints "off" what i need to figure out how to do is get ti to cycle through all the different ports and read out the values individually. im also beginning to think that maybe having the arduino spit out midi itself is a better way to go than have max read the pots and then translate it to midi. this might even be a faster application?

any thoughts on this are welcome in the mean time ill trudge forward.
Logged

UK
Offline Offline
Jr. Member
**
Karma: 0
Posts: 65
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, got mine from maplin ( HEF 4051 BP ).
At first I tried to follow your pictures and the tutorial but I was confused.
Your pictures relate to the right hand diagram from the tutorial ( logic symbol ). That's what confused me.
I followed the left hand diagram ( pin configuration ) and only the tutorial and now it works like a charm.
Obviously I had to had a analogueRead to read the thing. I think all your trouble scared me  smiley-razz

Daniel:
I don't understand why the tutorial as a beginSerial instead of the Serial.begin. Is it because of a old version, or the code is for wiring?
And I didn't use any capacitor.

Tomorrow I will try to adapt the capacitive thing to the multiplex.

Do you think that one of us should do a simple tutorial with pictures on how to wire a multiplex and rewrite the code so it actually do something when the arduino is wired properly. I am happy to do it, but I won't do it directly as I have lot of work. I still don't know what pin 6 and 7 (E and Vee) are for, ground access ?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 27
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

wow thats awesome that you have had so much success… my problems stem strictly from the fact that i am learning all this stuff as i go. if you post your solution for mulitplexing that i can follow i will happily document it and post it. i have alot of work to do too… but frankly this is more fun smiley-wink


edit: i should mention i did get it working to a degree… i just have no idea how to get the data out of arduino into something useful like max or even midi.


ACTUALLY: could you show me what your analog read looks like? Im mostly curious how you are separating the different inputs since they are all coming in on the same analog input.
« Last Edit: September 25, 2007, 04:32:00 pm by boligrafoe » Logged

UK
Offline Offline
Jr. Member
**
Karma: 0
Posts: 65
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Oh I wasn't trying to show of. I am also learning as I am doing it. I think I am so happy to have this working that I had to say it.
It's really a pain when you are a newbee like me and you don't have any pictures to look at in a tutorial. I think I will take the time to do a small one with picts.

Making it talk to Max is also my next step after the capacitive thing. I hope I will be as lucky. Your midi idea might be a good one actually.
Are you going to try with this tutorial ?
http://itp.nyu.edu/physcomp/Labs/MIDIOutput
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 27
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

perhaps. this one is exactly what im doing pretty much. although i want to add a few digital switches in order to change the midi channel

http://little-scale.blogspot.com/2007/06/arduino-midi-out-example.html

honestly i would rather do all that with software. having to power the board external and have a midi interface seems like a waste of space when the arduino is capable of that itself…

oh but please do share your code. i would love to see what you have rolling.
« Last Edit: September 25, 2007, 04:35:47 pm by boligrafoe » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 27
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Daniel… you may be fed up with my lameness by now but if you so happen to be looking to this thread at all do you (or anyone else) have any idea why this code would produce nothing in max?


Code:
/*  
 *  Arduino2Max w/ 4051
 *  Send pin values from Arduino to MAX/MSP
 *  
 *  Arduino2Max.pde
 *  ------------  
 *  Latest update: September 2007
 *  ------------
 *  Copyleft: use as you like
 *  by djmatic
 *  Based on a sketch and patch by Thomas Ouellet Fredericks  tof.danslchamp.org
 *  
 */


int x = 0; // a place to hold pin values

int bin [] = {000, 1, 10, 11, 100, 101, 110, 111}; //bin = binär, some times it is so easy

int r0 = 0; //value select pin at the 4051 (s0)
int r1 = 0; //value select pin at the 4051 (s1)
int r2 = 0; //value select pin at the 4051 (s2)

int row = 0; // storeing the bin code
int count = 0; // just a count

int analogPin = 0;
int threshold = 25;   // threshold

void setup()
{
  Serial.begin(115200);          // 115200 is the default Arduino Bluetooth speed
  digitalWrite(13,HIGH);       ///startup blink
  delay(600);
  digitalWrite(13,LOW);
  pinMode(13,INPUT);
  
  pinMode(2, OUTPUT);    // s0
  pinMode(3, OUTPUT);    // s1
  pinMode(4, OUTPUT);    // s2
}


void loop()
{

if (Serial.available() > 0){         // Check serial buffer for characters
        
    if (Serial.read() == 'r') {       // If an 'r' is received then read the pins
      
    // your code goes here. This is where you would prep the data
    // by reading it with the 4051 etc.  
    
      for (count=0; count<=7; count++) {
    row = bin[count];      
    r0 = row & 0x01;
    r1 = (row>>1) & 0x01;
    r2 = (row>>2) & 0x01;
    digitalWrite(2, r0);
    digitalWrite(3, r1);
    digitalWrite(4, r2);
    //Serial.println(bin[count]);
    delay (5);
  }  
    x = analogRead(analogPin);
    sendValue (x);                    // this is the statement to send data to Max
  
    Serial.println();                 // Send a carriage returnt to mark end of pin data.
    delay (5);                        // add a delay to prevent crashing/overloading of the serial port
  
  }

 }
}

void sendValue (int x){              // function to send the pin value followed by a "space".
 Serial.print(x);
 Serial.print(32, BYTE);
}



 
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey Boli,
I got your comment on my blog regarding the multiplexing. I have not been following this thread, so I don't know exactly what has been happening. However, I have implemented a simple sketch / patch / breadboard combo of multiplexing two 4051s into the Arduino and reading the data in Max/MSP. I am assuming that this is something similar as to what you were asking.

Anyway, you can see what i have done so far in a very simple example with 2 4051s. But i have to run off to work now, so i'm afraid that is it for a while from me at least. But i will be back - hopefully whip up slightly better code etc.

You can see the very basic example here: http://little-scale.blogspot.com/2007/09/multiplexy.html
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 27
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

wow your example looks really good. i may try to wire that up tomorrow. thanks for you help in advance!
« Last Edit: September 25, 2007, 11:08:48 pm by boligrafoe » Logged

Pages: 1 2 [3] 4   Go Up
Jump to: