Show Posts
Pages: [1] 2 3 ... 5
1  Forum 2005-2010 (read only) / Syntax & Programs / Re: Adding Pitch bend to Midi2CV- right approach? on: November 08, 2010, 10:32:06 am
(bump) Not much progress.  I tried out some other things- exchanging extra1&2 for "note & velocity"  It didntnt work.   Copying the transpose functions seems to be the closest to working -but again it is not in real time.   Please any suggestions, anyone?  
2  Forum 2005-2010 (read only) / Syntax & Programs / Re: Adding Pitch bend to Midi2CV- on: November 06, 2010, 07:05:40 pm
(...ran out of room)

I added a new action  (action=5)for when Ch1 Pitchbend data is received (224).  And then like action 4 (sysex transpose function) I use the following data bits to modify the "volages" used to calculate the pitch CVout.  Following the foramt of the rest of the sketch- After the midi pitchbend command is sent the second  is "note" and then "velocity"  "Extra1 and 2" would follow... As I type this  I am  realizing that after 244 is sent,"note" would be lsb, and "velocity" is msb, -not extra1 and extra2 as I had thought, right? So do I just need to figure out the correct way to calculate the pitch shift from "note" and "velocity"?    This is all really just a stab in the dark and I could really use some wise words right now to guide me.
   So am I on the right track or is this approach completely off the mark?  
Any thoughts or suggestions are greatly appreciated.
(BTW Sorry if this is in the wrong forum)
3  Forum 2005-2010 (read only) / Syntax & Programs / Adding Pitch bend to Midi2CV- right approach? on: November 06, 2010, 07:00:38 pm
Hi everyone.  
Im trying to add pitch-bend to a great  Midi to CV converter.  The complete project can be found here:
http://registeringdomainnamesismorefunthandoingrealwork.com/blogs/?tag=arduino

The sketch responds to SysEx transpose commands (2 octaves) so I thought that I could copy and modify that to have the CVPitch respond to bends. So here is pretty much the meat of the sketch with what I have so far (my additions are noted by the "pitchbend" comments):
Code:
void playNote(int note_, int velocity) {
  unsigned int note = note_;
  unsigned int voltage = 0;
  if ((note >= 12) && (note < 24)) {
    ////Serial.println("note >= 12 && note < 24");
    voltage = (voltage1)*((note - 12)/12.0);
  }
  else if ((note >= 24) && (note < 36)) {
    ////Serial.println("note >= 24 && note < 36");
    voltage = (voltage2 - voltage1)*((note - 24)/12.0) + voltage1;
  }
  else if ((note >= 36) && (note < 48)) {
    ////Serial.println("note >= 36 && note < 48");
    voltage = (voltage3 - voltage2)*((note - 36)/12.0) + voltage2;
  }
  else if ((note >= 48) && (note < 60)) {
    ////Serial.println("note >= 48 && note < 60");
    voltage = (voltage4 - voltage3)*((note - 48)/12.0) + voltage3;
  }
  else if ((note >= 60) && (note < 72)) {
    ////Serial.println("note >= 60 && note < 72");
    voltage = (voltage5 - voltage4)*((note - 60)/12.0) + voltage4;
  }
  noteOn = true;
  if ((velocity >= 1) && (velocity < 64)) { //normal note
    write_dac(WRITE_UPDATE_N, ACC, 0);
    write_dac(WRITE_UPDATE_N, CV, voltage);
    write_dac(WRITE_UPDATE_N, GATE, 65535);
    //Serial.print("cv = ");
    //Serial.print(voltage);
    //Serial.println(", accent = OFF");
  }
  else if (velocity >= 64) { //accent
    write_dac(WRITE_UPDATE_N, ACC, 65535);
    write_dac(WRITE_UPDATE_N, CV, voltage);
    write_dac(WRITE_UPDATE_N, GATE, 65535);
    //Serial.print("cv = ");
    //Serial.print(voltage);
    //Serial.println(", accent = ON");
  }
}

void stopNote(int note, int velocity) {
  //Serial.println("Note off, GATE = 0");
  write_dac(WRITE_UPDATE_N, GATE, 0);
  noteOn = false;
}

void cc(int note_, int velocity_) {
  write_dac(SETUP_INTERNAL_REGISTER, 0, 1);
  unsigned int note = note_;
  unsigned int velocity = velocity_; //you wouldn't have to convert the ints if you used
                                     //something other than -1 to indicate they were empty,
                                     //just keep them as bytes through out and use 128 as
                                     //empty for MSB and LSB data byte
    if (note == 4) {
    if (velocity >= 64) {
      write_dac(SETUP_INTERNAL_REGISTER, 0, 1);
      //Serial.println("INTERNAL REGISTER ON");
    }
    else {
      write_dac(SETUP_INTERNAL_REGISTER, 0, 0);
      //Serial.println("INTERNAL REGISTER OFF");
    }
  }
  else if (note == 1) {
    unsigned int voltage = 65535*velocity/127.0;
    write_dac(WRITE_UPDATE_N, 3, voltage);
    //Serial.print("OUTPUT 3 = ");
    //Serial.println(voltage);
  }
  else if (note == 14) {
    unsigned int voltage = 65535*velocity/127.0;
    write_dac(WRITE_UPDATE_N, 4, voltage);
    //Serial.print("OUTPUT 4 = ");
    //Serial.println(voltage);
  }
  else if (note == 20) {
    unsigned int voltage = 65535*velocity/127.0;
    write_dac(WRITE_UPDATE_N, 5, voltage);
    //Serial.print("OUTPUT 5 = ");
    //Serial.println(voltage);
  }
  else if (note == 21) {
    unsigned int voltage = 65535*velocity/127.0;
    write_dac(WRITE_UPDATE_N, 6, voltage);
    //Serial.print("OUTPUT 6 = ");
    //Serial.println(voltage);
  }
  else if (note == 22) {
    unsigned int voltage = 65535*velocity/127.0;
    write_dac(WRITE_UPDATE_N, 7, voltage);
    //Serial.print("OUTPUT 7 = ");
    //Serial.println(voltage);
  }
}

void loop() {
  if (Serial.available() > 0) {
    //recieved something so note time for working out if the RX Led should flash
    lastBonk = timer0_millis;
    // read the incoming byte:
    incomingByte = Serial.read();
    if ((incomingByte == 144) &! sysex) {
      //incoming note on
      action = 1;
    }
    else if ((incomingByte == 128) &! sysex) {
      //incoming note off
      action = 2;
    }
    else if ((incomingByte == 176) &! sysex) {
      action = 3;
    }
    else if ((incomingByte == 240) &! sysex) {
      action = 4;
      sysex = true;
      //Serial.println("incoming sysex");
    }
    else if ((incomingByte == 247) && sysex) {
      sysex = false;
      //Serial.println("sysex finished");
    }
    else if ((incomingByte == 224) &! sysex) {  //pitchbend
      action = 5;
    }
    
    else if ((action == 1) && (note == -1)) {
      note = incomingByte;
    }
    else if ((action == 1) && (note != -1)) {
      velocity = incomingByte;
      //Serial.print("note on 144 ");
      //Serial.print(note, DEC);
      //Serial.print(" ");
      //Serial.println(velocity, DEC);
      if (velocity == 0) {
        stopNote(note,velocity);
      }
      else {
        playNote(note,velocity);
      }
      action = 0;
      note = -1;
      velocity = -1;
    }
    else if ((action == 2) && (note == -1)) {
      note = incomingByte;
    }
    else if ((action == 2) && (note != -1)) {
      velocity = incomingByte;
      //Serial.print("note off 128 ");
      //Serial.print(note, DEC);
      //Serial.print(" ");
      //Serial.println(velocity, DEC);
      stopNote(note,velocity);
      action = 0;
      note = -1;
      velocity = -1;
    }
    else if ((action == 3) && (note == -1)) {
      note = incomingByte;
    }
    else if ((action == 3) && (note != -1)) {
      velocity = incomingByte;
      //Serial.print("cc ");
      //Serial.print(note, DEC);
      //Serial.print(" ");
      //Serial.println(velocity, DEC);
      cc(note,velocity);
      action = 0;
      note = -1;
      velocity = -1;
    }
    else if ((action == 4) && (note == -1)) {
      note = incomingByte;
    }
    else if ((action == 4) && (note != -1) && (velocity == -1)) {
      velocity = incomingByte;
    }
    else if ((action == 4) && (note != -1) && (velocity != -1) && (extra1 == -1)) {
      extra1 = incomingByte;
    }
    else if ((action == 4) && (note != -1) && (velocity != -1) && (extra1 != -1) && (extra2 == -1)) {
      extra2 = incomingByte;
      //Serial.print("sysex: ");
      //Serial.print(note);
      //Serial.print(" ");
      //Serial.print(velocity);
      //Serial.print(" ");
      //Serial.print(extra1);
      //Serial.print(" ");
      //Serial.println(extra2);
      switch (note) {
      case 1:
        voltage1 = velocity*512 + extra1*4 + extra2;
        //Serial.print("voltage1 = ");
        //Serial.println(voltage1);
        break;
      case 2:
        voltage2 = velocity*512 + extra1*4 + extra2;
        //Serial.print("voltage2 = ");
        //Serial.println(voltage2);
        break;
      case 3:
        voltage3 = velocity*512 + extra1*4 + extra2;
        //Serial.print("voltage3 = ");
        //Serial.println(voltage3);
        break;
      case 4:
        voltage4 = velocity*512 + extra1*4 + extra2;
        //Serial.print("voltage4 = ");
        //Serial.println(voltage4);
        break;
      case 5:
        voltage5 = 65535 + velocity*512 + extra1*4 + extra2;
        //Serial.print("voltage5 = ");
        //Serial.println(voltage5);
        break;
      }
      action = 0;
      note = -1;
      velocity = -1;
      extra1 = -1;
      extra2 = -1;
    }
  }  /////////////////////pitchbend//////////////////////
   else if ((action == 5) && (note == -1)) {
      note = incomingByte;
    }
    else if ((action == 5) && (note != -1) && (velocity == -1)) {
      velocity = incomingByte;
    }
    else if ((action == 5) && (note != -1) && (velocity != -1) && (extra1 == -1)) {
      extra1 = incomingByte;
    }
    else if ((action == 5) && (note != -1) && (velocity != -1) && (extra1 != -1) && (extra2 == -1)) {
      extra2 = incomingByte;
      //Serial.print("sysex: ");
      //Serial.print(note);
      //Serial.print(" ");
      //Serial.print(velocity);
      //Serial.print(" ");
      //Serial.print(extra1);
      //Serial.print(" ");
      //Serial.println(extra2);
      switch (note) {
      case 1:
        voltage1 = velocity*512 + extra1*4 + extra2;
        //Serial.print("voltage1 = ");
        //Serial.println(voltage1);
        break;
      case 2:
        voltage2 = velocity*512 + extra1*4 + extra2;
        //Serial.print("voltage2 = ");
        //Serial.println(voltage2);
        break;
      case 3:
        voltage3 = velocity*512 + extra1*4 + extra2;
        //Serial.print("voltage3 = ");
        //Serial.println(voltage3);
        break;
      case 4:
        voltage4 = velocity*512 + extra1*4 + extra2;
        //Serial.print("voltage4 = ");
        //Serial.println(voltage4);
        break;
      case 5:
        voltage5 = 65535 + velocity*512 + extra1*4 + extra2;
        //Serial.print("voltage5 = ");
        //Serial.println(voltage5);
        break;
      }
      action = 0;
      note = -1;
      velocity = -1;
      extra1 = -1;
      extra2 = -1;
    }
  }
  
So this  kinda works, - CV out  responds to bends but its like the transpose function, pitch changes are not in real time but apply to the next note triggered - Also the tone of the note played is pretty glitchy. Getting it this far  represents a huge milestone for me and  my understanding of midi  but it obviously not  what I want.    

4  Forum 2005-2010 (read only) / Syntax & Programs / Re: Translator needed: C++ I2c protocol to arduino on: March 09, 2010, 12:09:58 am
Thanks, but Ive already seen them. The first is a wired nunchuk with an xbee the other two are by the guy who started the thread I posted and have the same code.
5  Forum 2005-2010 (read only) / Syntax & Programs / Translator needed: C++ I2c protocol to arduino on: March 08, 2010, 11:05:48 pm
Hi,
Ive been having a lot of trouble getting a  wireless wii nunchuk connected to my diecimila.  The wireless 'chuck use a different initiation routine than the wired ones and it varies between the multiple 3rd party brands.     Member  ILAN  has gotten my brand of wireless nunchuk ( Nyko Kana) to work reliably, but he is using an AVR ATTINY 461.
He was kind enough to post his initiation routine but I am having no luck trying to alter the existing wireless sketch to follow his. Here is the original wireless sketch written for a blazepro nunchuk:
Code:
Code:
// read out a Wii Nunchuck controller
// adapted to work with wireless Nunchuck controllers of third party vendors by Michael Dreher <michael@5dot1.de>

// adapt to your hardware config
#define POWER_VIA_PORT_C2_C3 1    // use port pins port C2 and C3 as power supply of the Nunchuck (direct plug using wiichuck adapter)
#define DEBUG_RCV_TEL 1

#define USE_NEW_WAY_INIT 1        // use "The New Way" of initialization <http://wiibrew.org/wiki/Wiimote#The_New_Way>
#define WII_IDENT_LEN ((byte)6)
#define WII_TELEGRAM_LEN ((byte)6)
#define WII_NUNCHUCK_TWI_ADR ((byte)0x52)

#include <Wire.h>
#include <string.h>
#include <utility\twi.h>
#undef int
#include <stdio.h>

uint8_t outbuf[WII_TELEGRAM_LEN];            // array to store arduino output
int cnt = 0;
int ledPin = 13;

void setup ()
{
  Serial.begin (115200);

#ifdef POWER_VIA_PORT_C2_C3    // power supply of the Nunchuck via port C2 and C3
  PORTC &=~ _BV(PORTC2);
  PORTC |=  _BV(PORTC3);
  DDRC |= _BV(PORTC2) | _BV(PORTC3);  // make outputs
  delay(100);  // wait for things to stabilize
#endif

  Wire.begin(); // initialize i2c
  // we need to switch the TWI speed, because the nunchuck uses Fast-TWI
  // normally set in hardware\libraries\Wire\utility\twi.c twi_init()
  // this is the way of doing it without modifying the original files
#define TWI_FREQ_NUNCHUCK 400000L
  TWBR = ((CPU_FREQ / TWI_FREQ_NUNCHUCK) - 16) / 2;

  nunchuck_init(0); // send the initialization handshake

  // display the identification bytes, must be "00 00 A4 20 00 00" for the Nunchuck
  byte i;
  if(readControllerIdent(outbuf) == 0)
  {
    Serial.print("Ident=");
    for (i = 0; i < WII_TELEGRAM_LEN; i++)
    {
      Serial.print(outbuf[i], HEX);
      Serial.print(' ');
    }
    Serial.println();
  }

  Serial.println("Finished setup");
}

// params:
//   timeout: abort when timeout (in ms) expires, 0 for unlimited timeout
//   return:  0 == ok, 1 == timeout
byte nunchuck_init (unsigned short timeout)
{
  byte rc = 1;

#ifndef USE_NEW_WAY_INIT
  // look at <http://wiibrew.org/wiki/Wiimote#The_Old_Way> at "The Old Way"
  Wire.beginTransmission (WII_NUNCHUCK_TWI_ADR);      // transmit to device 0x52
  Wire.send (0x40);            // sends memory address
  Wire.send (0x00);            // sends sent a zero.  
  Wire.endTransmission ();      // stop transmitting
#else
  // disable encryption
  // look at <http://wiibrew.org/wiki/Wiimote#The_New_Way> at "The New Way"

  unsigned long time = millis();
  do
  {
    Wire.beginTransmission (WII_NUNCHUCK_TWI_ADR);      // transmit to device 0x52
    Wire.send (0xF0);            // sends memory address
    Wire.send (0x55);            // sends data.  
    if(Wire.endTransmission() == 0) // stop transmitting
    {
      Wire.beginTransmission (WII_NUNCHUCK_TWI_ADR);      // transmit to device 0x52
      Wire.send (0xFB);            // sends memory address
      Wire.send (0x00);            // sends sent a zero.  
      if(Wire.endTransmission () == 0)      // stop transmitting
      {
        rc = 0;
      }
    }
  }
  while (rc != 0 && (!timeout || ((millis() - time) < timeout)));
#endif

  return rc;
}


// params:
//   ident [out]: pointer to buffer where 6 bytes of identification is stored. Buffer must be at least 6 bytes long.
//                A list of possible identifications can be found here: <http://wiibrew.org/wiki/Wiimote#The_New_Way>
//   return:  0 == ok, 1 == error
byte readControllerIdent(byte* pIdent)
{
  byte rc = 1;

  // read identification
  Wire.beginTransmission (WII_NUNCHUCK_TWI_ADR);      // transmit to device 0x52
  Wire.send (0xFA);            // sends memory address of ident in controller
  if(Wire.endTransmission () == 0)      // stop transmitting
  {
    byte i;
    Wire.requestFrom (WII_NUNCHUCK_TWI_ADR, WII_TELEGRAM_LEN);      // request data from nunchuck
    for (i = 0; (i < WII_TELEGRAM_LEN) && Wire.available (); i++)
    {
      pIdent[i] = Wire.receive();      // receive byte as an integer
    }
    if(i == WII_TELEGRAM_LEN)
    {
      rc = 0;
    }
  }
  return rc;
}

void clearTwiInputBuffer(void)
{
  // clear the receive buffer from any partial data
  while( Wire.available ())
    Wire.receive ();
}


void send_zero ()
{
  // I don't know why, but it only works correct when doing this exactly 3 times
  // otherwise only each 3rd call reads data from the controller (cnt will be 0 the other times)
  for(byte i = 0; i < 3; i++)
  {
    Wire.beginTransmission (WII_NUNCHUCK_TWI_ADR);      // transmit to device 0x52
    Wire.send (0x00);            // sends one byte
    Wire.endTransmission ();      // stop transmitting
    //delay(1);
  }
}

void loop ()
{
  delay (1000);
  send_zero (); // send the request for next bytes
  Wire.requestFrom (WII_NUNCHUCK_TWI_ADR, WII_TELEGRAM_LEN);      // request data from nunchuck

  for (cnt = 0; (cnt < WII_TELEGRAM_LEN) && Wire.available (); cnt++)
  {
    outbuf[cnt] = nunchuk_decode_byte (Wire.receive ());      // receive byte as an integer
    digitalWrite (ledPin, HIGH);      // sets the LED on
  }

  // debugging
#ifdef DEBUG_RCV_TEL
  Serial.print("avail=");
  Serial.print(Wire.available(), DEC);
  Serial.print("  cnt=");
  Serial.println(cnt, DEC);
#endif

  clearTwiInputBuffer();

  // If we recieved the 6 bytes, then go print them
  if (cnt >= WII_TELEGRAM_LEN)
  {
    print ();
  }

}

// Print the input data we have recieved
// accel data is 10 bits long
// so we read 8 bits, then we have to add
// on the last 2 bits.  That is why I
// multiply them by 2 * 2
void print ()
{
  int joy_x_axis = outbuf[0];
  int joy_y_axis = outbuf[1];
  int accel_x_axis = outbuf[2] * 2 * 2;
  int accel_y_axis = outbuf[3] * 2 * 2;
  int accel_z_axis = outbuf[4] * 2 * 2;

  int z_button = 0;
  int c_button = 0;

  // byte outbuf[5] contains bits for z and c buttons
  // it also contains the least significant bits for the accelerometer data
  // so we have to check each bit of byte outbuf[5]
  if ((outbuf[5] >> 0) & 1)
  {
    z_button = 1;
  }
  if ((outbuf[5] >> 1) & 1)
  {
    c_button = 1;
  }

  if ((outbuf[5] >> 2) & 1)
  {
    accel_x_axis += 2;
  }
  if ((outbuf[5] >> 3) & 1)
  {
    accel_x_axis += 1;
  }

  if ((outbuf[5] >> 4) & 1)
  {
    accel_y_axis += 2;
  }
  if ((outbuf[5] >> 5) & 1)
  {
    accel_y_axis += 1;
  }

  if ((outbuf[5] >> 6) & 1)
  {
    accel_z_axis += 2;
  }
  if ((outbuf[5] >> 7) & 1)
  {
    accel_z_axis += 1;
  }

  Serial.print (joy_x_axis, DEC);
  Serial.print ("\t");

  Serial.print (joy_y_axis, DEC);
  Serial.print ("\t");

  Serial.print (accel_x_axis, DEC);
  Serial.print ("\t");

  Serial.print (accel_y_axis, DEC);
  Serial.print ("\t");

  Serial.print (accel_z_axis, DEC);
  Serial.print ("\t");

  Serial.print (z_button, DEC);
  Serial.print ("\t");

  Serial.print (c_button, DEC);
  Serial.print ("\t");

  Serial.print ("\r\n");
}

// Decode data format that original Nunchuck uses with old init sequence. This never worked with
// other controllers (e.g. wireless Nunchuck from other vendors)
char nunchuk_decode_byte (char x)
{
#ifndef USE_NEW_WAY_INIT
  x = (x ^ 0x17) + 0x17;
#endif
  return x;
}


and I like to alter it by replicating ILAN's recommended routine:


Quote
BEGIN INIT LOOP
0xA4
0xF0
0x55

30 msec DELAY

0xA4
0xFB
0x00

23 msec DELAY

0xA4
0xFA //identity request

45 usec DELAY

0xA5  //identitity READ

23 msec DELAY

0xA4
0xF0
0xAA //Enable Encryption

30 msec DELAY

0xA4
0x40
0x00
0x00
0x00
0x00
0x00
0x00 //Send First 6 bytes of Encryption Key

30 msec DELAY

0xA4
0x46
0x00
0x00
0x00
0x00
0x00
0x00 //Send Second 6 bytes of Encryption Key

30 msec DELAY

0xA4
0x4C
0x00
0x00
0x00
0x00 //Send Last 4 bytes of Encryption Key

30 msec DELAY

END INIT LOOP (REPEAT LOOP FROM BEGINNING IF ANY I2C ERRORS OCCUR)


READ DATA LOOP BEGIN:

0xA4
0x00 //Request Nunchuck Data

500 usec DELAY

0xA5   //Read Nunchuck Data

4 msec DELAY

READ DATA LOOP END

The original thread: http://tp://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1259091426/0
I am sure this is super simple  for anyone with more programming experience than me and should take just a moment.  I have been  trying learn /understand I2C protocol  but as of now, I am too dense for any of it to stick...
While I usually subscribe  to  the "teach a man to fish" philosophy,  I am begging someone to just help me make the changes.  I have been blindly hacking at this thing with no sign of progress,  please put me out of my misery.
Thanks in advance
6  Forum 2005-2010 (read only) / Interfacing / Re: Using Arduino to program my pic on: February 20, 2010, 05:33:36 pm
You could just make this simple JDM programmer:http://www.circuit-projects.com/microcontroller/pic-and-eeprom-programmer.html


oh... I guess you need usb, though.  
7  Forum 2005-2010 (read only) / Interfacing / Re: What could cause RX to not read data? on: February 20, 2010, 10:49:51 pm
OK, if i did it correctly,  I get no data being recieved. heres the sketch:
Code:
//variables setup
byte incomingByte;

int statusLed = 13;   // select the pin for the LED


//setup: declaring iputs and outputs and begin serial
void setup() {
  pinMode(statusLed,OUTPUT);   // declare the LED's pin as output
  Serial.begin(31250);        //start serial with midi baudrate 31250 or 38400 for debugging
  digitalWrite(statusLed,LOW);
}


void loop () {
 if (Serial.available() > 0) {

    incomingByte = Serial.read();
    // wait for as status-byte, channel 1, note on or off
    if (incomingByte==144){ // 144 is note on ch1
      digitalWrite(statusLed, HIGH);
      delay(20);
      digitalWrite(statusLed, LOW);
      delay(1);
    }

Serial.println (incomingByte);
delay (20);
 }



}
there is no gibberish on any baud.....
Ill give it another go tomorrow.
8  Forum 2005-2010 (read only) / Interfacing / Re: What could cause RX to not read data? on: February 20, 2010, 10:30:01 pm
thanks, sounds like a plan.

By the way....I just made a cv to midi converter http://tomscarff.110mb.com/cv2midi/cv2midi.htmworks great...except for the midi thru.  The arduino doesnt accept data from neither of my two keyboards,  sending it out works fine though.

If anyone reading is familiar with midi,  I have another question.  The Midi out data is one step behind.  I believe with a keyboard it is fine but when controlled by an analog sequencer it is always one step behind the step that should be played.  meaning...the note that is being voiced is controled by the pot of the previous step.
Not too big of a problem,  Im just happy to get something working. Obviously Im a total novice, could someone point me in the direction of what to alter, code-wise?  Im guessing clock??
anyway thanks again. ill report back after trying serial.print.
9  Forum 2005-2010 (read only) / Interfacing / What could cause RX to not read data? on: February 20, 2010, 02:32:29 pm
Hi, Ive been trying to get a simple verified midi-in sketch running for days. It does not recieve or read incoming midi data.  My hardware is good and connected properly.  the arduino  loads and  executes other sketches with no problem.    I am begining to think it my be a  problem with the ATMEGA itself  or software.  Here's the sketch:
Code:
//variables setup
byte incomingByte;

int statusLed = 13;   // select the pin for the LED


//setup: declaring iputs and outputs and begin serial
void setup() {
  pinMode(statusLed,OUTPUT);   // declare the LED's pin as output
  Serial.begin(31250);        //start serial with midi baudrate 31250 or 38400 for debugging
  digitalWrite(statusLed,LOW);
}


void loop () {
 if (Serial.available() > 0) {

    incomingByte = Serial.read();
    // wait for as status-byte, channel 1, note on or off
    if (incomingByte==144){ // 144 is note on ch1
      digitalWrite(statusLed, HIGH);
      delay(20);
      digitalWrite(statusLed, LOW);
      delay(1);
    }

 }
}
 


 For Hardware, I have a arduino diecimila and an optoisolated midi in like this:http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1187962258/all Im using midi out from a microkorg keyboard, on channel 1.
 

 The most frustrating thing is it worked once, briefly, and after many failed attempts. (Out of frustration, and lack of other ideas) I took the lead from the opto out (pin 5) and touched it directly to the ATMEGA pin 2 ( rx).  I also accidently touched pin 1 and found that I can trigger the board to reset with each keystroke.
   Directly touch the pin didnt work but when I pit the lead back into the RX socket, it worked.  I was amazed, but when I unhooked the lead and put it back again, no dice.  My first thought was that it was  a loose or bad connection, but after an exhaustive search I have found nothing. I get a very strong beep when i perform a continuity test between  the opto pin 5  and the ATMega pin 2.  Naturally, I tried touching the lead diectly to pin 2 many times.  This does nothing and  leads me to suspect that there is a problem with the ATMega and /or some software problem (I dont think that it is the sketch, though)   Anyone have any ideas?   I am using Arduino 018.   But my arduino is from '07.  VCould it be a bug or problem with the bootloader....Im just guessing.
 When I had it working before it almost seemed like I had "jumpstarted" the arduino into reading the data.  ?? does this make sense?  What could cause the rx to not respond?

I dont have any "real" test equipment, but my Meter reads a steady 5.14v  on the RX pin.  Should this always be high?  Im a noob with digital and programming pics, but shouldnt this be low to recieve input?   (The midi input lead read about the same but flickers slightly with key action.)

I tried a simple skech to take a digital read of pin 0 and report back with serial.println.   Unconnected it reads "I" and with a lead to ground   I get "0",   so it seems like it can read something.    

I have no idea what to try next except to drop some cash on a new arduino and/or bootloaded chip and wait a week til they get here.  

please,  any ideas or suggestions are greatly appreciated.
thanks
10  Forum 2005-2010 (read only) / Troubleshooting / Re: Windows XP won't recognise driver and install on: October 27, 2010, 10:02:56 am
Im having a similar problem with an afterschool robotics class that I am (trying to )teach.   the computers will not recognize any of our 8 duemilanove boards. Every time I plug in a board I get the new hardware wizard  and after a "sucessful"  driver install,  a "new hardware detected" message  immediately pops up.?
     I tried selecting the drivers foler, ftdi usb drivers folder....
Arduine 0021 runs and appears to upload but along with "done uploading" im getting an AVRDUDE timing error /out of sync.   We are using school comuters with some pretty intense security settings, but even in "admin" it didnt work.  The schools computer tech and I tried for hours yesterday.   Any ideas?
11  Forum 2005-2010 (read only) / Troubleshooting / Re: Mad Catz wireless nunchuck on: November 20, 2010, 03:55:34 pm
seach for the "read wireless nunchuk" thread.  Somewhere around page 8 or so there is a sketch that works with a Madcatz chuck though there was an unsolve issue with a very  a slow 1 sec refresh rate. Works though.  
12  Forum 2005-2010 (read only) / Troubleshooting / Boarduino working  - but not with SPI? on: November 20, 2010, 03:39:54 pm
Hi everyone.   I am having a difficult time and posting here is a last resort.
Im building a "finished" version of a midi to cv circuit on a  proto breadboard(bb). The circuit is pretty simple: an atmega and and associated components (Im using the boarduino schematic here :http://www.ladyada.net/images/boarduino/boarduinosch.png) and a dac chip communicating via SPI.  

So the arduino part of the circuit seems to be working -  blinks leds for incoming midi messeage, (I also ran a few other test sketches too with no problem) - however the DAC does not respond.  
   To test the wiring and try to isolate the problem, i removed the atmega chip from the bb socket ,  put it in an arduino board and then "patched" the arduino pins back to the appropriate pins on the bb socket with jumpers. ex: rx to bb socket pin 2;d3 to bb socket pin 5; 5v+ to bb pin 7;ground to bb socket pin 8; etc)
  In this configuration the DAC works, reliably, everytime.   However  when I return the chip to the bb(connecting the same pins directly to the same socket to which it was just wired), the DAC remains dead-no dice.  I've wired it up and check the connections countless times and I am fairly certain that its all correct.
  When patched out and working, the arduino board is getting power from the bb supply- so Ill assume that i can rule out that too.   The only difference between when the atmega chip is in the socket of the bb and when it is in a arduino board is (as far as I can tell, besides all the extra messy jumper wires) is different  resonator circuits.  The arduino has a crystal/ cap combo while I used a  16.000 resonator on the BB -I wouldnt think that this could be the culprit , but could this effecting SPI?
    
   As I mentioned above im using the boarduino schematic. Is there something Im missing that would be on an "official" arduino board or
is there something that could be interfering SPI communication when the atmega is in the socket of the protoboard and not when patched out to an arduino?

13  Forum 2005-2010 (read only) / Troubleshooting / Re: Problem with wiichuck on: March 13, 2010, 02:52:58 pm
what kind of nunchuk are you using?   If its a Nintendo-brand, hard wired 'chuck, the library and other sketches should work.   If you have a wireless nunchuk made by various 3rd party companies, you may be in for an excrutiating ordeal.  see "read wireless nunchuck into arduino" thread for info and sketches that work with some wireless nunchuks:
:http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1259091426   They use a different encryption routine and that varies with the different brands.  So far, the  most commonly available brand seem the hardest to connect.  
Not sure how the 3rd party "wired " chuck work with the wired chuck sketches.
14  Forum 2005-2010 (read only) / Troubleshooting / Re: Troubleshoot Midi In. Arduino not receiving w/ RX on: February 22, 2010, 09:38:33 am
Well you were right.  It was hardware, still not sure why though.   For me, Kuk's scematic with a 4n28 opto  just doesnt work.  Even though i could test the opto by could getting a led to flicker, the arduino just would not recognize the incoming data. none of the 10 I have  worked.   Last night I tried another opto,  a cny17-4, it has a similar pin-out.   It worked right away!...
Im just thrilled that this works so I not gonna loose too much sleep wondering why, but...
...obviously, many others have had success with the 4n28,  why doesnt it work for me?
 
thanks for your help, Grumpy Mike.
15  Forum 2005-2010 (read only) / Troubleshooting / Re: Troubleshoot Midi In. Arduino not receiving w/ RX on: February 19, 2010, 10:43:37 am
OK, It works! but I have no idea why.  I unhooked the lead from the Rx socket and touched it to pin 2 of the atmega chip and then back in the RX socket.....now it works.  I know that I did this a dozen times yesterday.   Oh, I also briefly stuck a 1k resistor between tx and rx.  Did I somehow manage to jumpstart it or something?

Well...I spoke too soon.   I unhooked the input and put it right back in and now no longer works.  I dont think that it is a continuity issue.  I get a strong beep when when the probes are directly on pin 5 of the optoisolator and pin 2 of the atmega and have rebuilt the circuit and changed jumpers dozens of times.

I redid my experiment by touching the wire directly to atmega pin 2 with no results , however I have found the  LED  blinks with pressed keys when I connect the wire to Pin 1 of the atmega?  i guess  this just resetting the arduino with every  keystroke.
Again i am like 98% sure that all of the hardware and connections are good and the software has been verified by others (and it briefly worked for me.)    It seems the x factor here is the arduino itself and its reluctance to take in data.      sigh.... Why is this so being so difficult?   Could there be a problem with my  arduino?  

good grief
Pages: [1] 2 3 ... 5