Show Posts
Pages: [1]
1  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: Unable to connect with parallel programmer on: January 18, 2010, 09:10:16 am
Just writing again here to suggest you (Arduino developers) to let the users configure these parameters easier, best would be a popup before burning, and it should also be documented in the help.
2  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: Unable to connect with parallel programmer on: January 13, 2010, 12:46:27 am
Hmm, found the programmers.txt file and tried to change this:
parallel.protocol=dapa
into this:
parallel.protocol=stk200

Now the 1mhz blinking program I had burned with avrdude previously stopped working, so something must have happened. But Arduino still reported errors:

I now get this message each time I try.
What to try now?

This is the programmer I use btw:
http://www.sparkfun.com/commerce/product_info.php?products_id=13

Edit:
Seems I got it working! Now there are no reported errors and the led on pin 13 blinks each second (the default test program I guess).

I had to add a delay of 20:
parallel.name=Parallel Programmer
parallel.protocol=stk200
parallel.force=true
parallel.delay=20

Oh, and just a tip to other newbies, do not run Arduino board with programmer plugged in... (only when programming)
3  Forum 2005-2010 (read only) / Bugs & Suggestions / Unable to connect with parallel programmer on: January 13, 2010, 12:19:57 am
Yes, I list this as a bug since I managed to connect to it when I downloaded WinAVR and tried with avrdude.

I'm using ATMega328 and here is a screenshot with proof:


I am willing to work with you guys to resolve this problem, because it is important to be able to program using a parallel programmer (even if most hate them).

I don't know what more to say... Well, the OS is Vista (x86) and I tried to give Arduino admin privileges too without any luck.
What more should I try?
The path where I put Arduino can that affect this? Should I try installing it to C:/ instead of program files?
Please let's find a solution!
4  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: Possible bug in pulseIn()? on: August 20, 2009, 03:35:34 pm
Quote
it was reprogammed to wait for a first transition
Okay, thanks for the explanation, that I can respect.
But I think it should be noted in the reference page so other people will not waste hours on figuring out what happened like me.
5  Forum 2005-2010 (read only) / Bugs & Suggestions / Possible bug in pulseIn()? on: August 17, 2009, 08:08:23 pm
Hello! I'm new here (but not to programming btw).

It seems like pulseIn(pin,LOW) if it is ALREADY low will wait until it gets high and THEN low again before it measures the time it takes for it to get high after that. Okay, maybe it is hard to explain in a understandable way, but I had to rewrite the function to get the behavior I expected.

I was sitting for hours going insane at this weird behavior (at least weird to me).

If I must then I can show you my code...
It's a IR receiver I'm working on, my readings from the sensor is good and I would suspect the same behavior from these two code snippets I post below. But only the one where I wrote my own timing stuff instead of using pulseIn works as expected. And with "expected" I mean collecting timing data of the "on and off" pulses until the remote signals stopped.


This is where I tried using pulseIn to simplify things:
Code:
#define ir_pin 7

void setup() {
  pinMode(ir_pin,INPUT);
  Serial.begin(9600);
  Serial.println("Ready...");
}

unsigned long onDuration=0;
unsigned long offDuration=0;
unsigned int count=0;
unsigned int data[300];
unsigned long microseconds=0;
boolean timeout=false;

//LOW = IR light, HIGH = no IR light (that's how my IR receiver reads)
void loop() {
  onDuration = pulseIn(ir_pin,LOW);
  if (onDuration > 0) { //did it blink?
    data[count] = onDuration;
    count ++;
    
    microseconds = micros();
    while (digitalRead(ir_pin)==HIGH && timeout==false) { //messure delay between blinks
      if (micros()-microseconds > 10000) { //been off for a second or more
        timeout = true; //rather use break?
      }
    }
    if (timeout == false) {
      offDuration = micros()-microseconds;
      data[count] = offDuration;
      count ++;
    } else { //end of blinks, output data
      Serial.println("########################################");
      for (int i=0; i<count; i++) {
        Serial.println(data[i]);
      }
      count = 0;
      timeout = false;
    }
  }
  if (count > 298) {
    count = 0;
    Serial.println("too much data");
  }
}

This is the working code (when I decided to not use pulseIn for timing):
Code:
#define ir_pin 7

void setup() {
  pinMode(ir_pin,INPUT);
  Serial.begin(9600);
  Serial.println("Ready...");
}

unsigned long onDuration=0;
unsigned long offDuration=0;
unsigned int count=0;
unsigned int data[300];
unsigned long microseconds=0;
boolean timeout=false;
boolean wasLow=false;

//LOW = IR light, HIGH = no IR light (that's how my IR receiver reads)
void loop() {
  microseconds = micros();
  while (digitalRead(ir_pin)==LOW) { //messure delay between blinks
    wasLow=true;
  }
  if (wasLow==true) { //did it blink?
    onDuration = micros()-microseconds;
    wasLow=false;
  } else {
    onDuration = 0;
  }
  if (onDuration > 0) {
    data[count] = onDuration;
    count ++;
    
    microseconds = micros();
    while (digitalRead(ir_pin)==HIGH && timeout==false) { //messure delay between blinks
      if (micros()-microseconds > 100000) { //been off for a second or more
        timeout = true; //rather use break?
      }
    }
    if (timeout == false) {
      offDuration = micros()-microseconds;
      data[count] = offDuration;
      count ++;
    } else { //end of blinks, output data
      Serial.println("########################################");
      for (int i=0; i<count; i++) {
        Serial.println(data[i]);
      }
      count = 0;
      timeout = false;
    }
  }
  if (count > 298) {
    count = 0;
    Serial.println("too much data");
  }
}

As you see the only changes is a few lines over "if (onDuration > 0)". I may be crazy but shouldn't the snippets behave the same way? At least that would make sense to me.
6  Forum 2005-2010 (read only) / Interfacing / Code to control TB6612FNG motor driver on: January 18, 2010, 06:43:33 pm
TB6612FNG motor driver:
http://www.sparkfun.com/commerce/product_info.php?products_id=9457

Some code demonstrating how to use this motor driver:

Code:
//Configure these to fit your design...
#define out_STBY 5
#define out_B_PWM 3
#define out_A_PWM 11
#define out_A_IN2 9
#define out_A_IN1 10
#define out_B_IN1 8
#define out_B_IN2 7
#define motor_A 0
#define motor_B 1
#define motor_AB 2

void setup()
{
  pinMode(out_STBY,OUTPUT);
  pinMode(out_A_PWM,OUTPUT);
  pinMode(out_A_IN1,OUTPUT);
  pinMode(out_A_IN2,OUTPUT);
  pinMode(out_B_PWM,OUTPUT);
  pinMode(out_B_IN1,OUTPUT);
  pinMode(out_B_IN2,OUTPUT);
  
  motor_standby(false);
  motor_speed2(motor_A,-100);
  motor_speed2(motor_B,-100);
  delay(2000);
  for (int i=-100; i<100; i++) {
    motor_speed2(motor_A,i);
    motor_speed2(motor_B,i);
    delay(50);
  }
  delay(2000);
  motor_standby(true);
}

void loop()
{

}

void motor_speed2(boolean motor, char speed) { //speed from -100 to 100
  byte PWMvalue=0;
  PWMvalue = map(abs(speed),0,100,50,255); //anything below 50 is very weak
  if (speed > 0)
    motor_speed(motor,0,PWMvalue);
  else if (speed < 0)
    motor_speed(motor,1,PWMvalue);
  else {
    motor_coast(motor);
  }
}
void motor_speed(boolean motor, boolean direction, byte speed) { //speed from 0 to 255
  if (motor == motor_A) {
    if (direction == 0) {
      digitalWrite(out_A_IN1,HIGH);
      digitalWrite(out_A_IN2,LOW);
    } else {
      digitalWrite(out_A_IN1,LOW);
      digitalWrite(out_A_IN2,HIGH);
    }
    analogWrite(out_A_PWM,speed);
  } else {
    if (direction == 0) {
      digitalWrite(out_B_IN1,HIGH);
      digitalWrite(out_B_IN2,LOW);
    } else {
      digitalWrite(out_B_IN1,LOW);
      digitalWrite(out_B_IN2,HIGH);
    }
    analogWrite(out_B_PWM,speed);
  }
}
void motor_standby(boolean state) { //low power mode
  if (state == true)
    digitalWrite(out_STBY,LOW);
  else
    digitalWrite(out_STBY,HIGH);
}
void motor_brake(boolean motor) {
  if (motor == motor_A) {
    digitalWrite(out_A_IN1,HIGH);
    digitalWrite(out_A_IN2,HIGH);
  } else {
    digitalWrite(out_B_IN1,HIGH);
    digitalWrite(out_B_IN2,HIGH);
  }
}
void motor_coast(boolean motor) {
  if (motor == motor_A) {
    digitalWrite(out_A_IN1,LOW);
    digitalWrite(out_A_IN2,LOW);
    digitalWrite(out_A_PWM,HIGH);
  } else {
    digitalWrite(out_B_IN1,LOW);
    digitalWrite(out_B_IN2,LOW);
    digitalWrite(out_B_PWM,HIGH);
  }
}
You might wanna change this line depending on your motors:
PWMvalue = map(abs(speed),0,100,50,255);
For "Micro Metal Gearmotor 30:1" 50 is the minimum PWM I wanted to give it, stronger engines can have a value closer to zero though.

Wanna remote control it?
Like I do in this video: http://www.facebook.com/v/295202320029
Then get BlueSMiRF or similar and put this in setup():
Code:
Serial.begin(115200);

Then put this in the loop():
Code:
 byte data, length, motor, command; //0-255
  char speed; //-128-128
  data = Serial.available();
  if (data > 0) {
    length = Serial.read();
    while (data < length-1) { //wait until we got everything
      data = Serial.available(); delay(20); //todo: add timeout
    }
    command = Serial.read();
    switch (command) {
      case 0: //speed
        motor = Serial.read();
        speed = Serial.read();
        if (motor == motor_AB) {
          motor_speed2(motor_A,speed);
          motor_speed2(motor_B,speed);
        } else {
          motor_speed2(motor,speed);
        }
        break;
      case 1: //brake
        motor = Serial.read();
        if (motor == motor_AB) {
          motor_brake(motor_A);
          motor_brake(motor_B);
        } else {
          motor_brake(motor);
        }
        break;
      case 2: //coast
        motor = Serial.read();
        if (motor == motor_AB) {
          motor_coast(motor_A);
          motor_coast(motor_B);
        } else {
          motor_coast(motor);
        }
        break;
      case 3: //standby
        motor_standby(Serial.read());
        break;
    }
  }

But how to steer it?
Well, use your brain... I'll give a hint though, this is to set motor 1 to max backward speed:
byte1 = 4 //this is the total size of message
byte2 = 0 //this is the command id
byte3 = 1 //motor id, 0 or 1
byte4 = -100 //backward = -value (0 to 100)
7  Forum 2005-2010 (read only) / Interfacing / Re: Individual pixel controll through serial lcd? on: August 25, 2009, 02:17:45 pm
Quote
Sorry to wake an old post, but I want to make scandinavian letters to my serial LCD. I have the Hex code for the letters, but how do I go about defining them to the screen?

I think this makes it clear? Just use ASCII 0 to 8 to print the custom ones.
Code:
void setChar(byte pos,byte b1,byte b2,byte b3,byte b4,byte b5,byte b6,byte b7,byte b8) {
  //character designer here: http://www.geocities.com/dinceraydin/lcd/charcalc.htm
  //pos from 0-7 (max 8 custom characters)
  Serial.print(0xFE,BYTE); //HD44780 command (254)
  Serial.print(64+pos*8,BYTE); //CG RAM start
  Serial.print(b1,BYTE);
  Serial.print(b2,BYTE);
  Serial.print(b3,BYTE);
  Serial.print(b4,BYTE);
  Serial.print(b5,BYTE);
  Serial.print(b6,BYTE);
  Serial.print(b7,BYTE);
  Serial.print(b8,BYTE);
  Serial.print(254,BYTE); //switch to command mode to leave
  Serial.print(1,BYTE);  //then do something (clear screen)
}

void setup() {
  Serial.begin(9600);
  setChar(0,159,159,159,159,159,159,159,159); //black box
  for (int i=0; i<8; i++) { //print custom chars
    Serial.print(i,BYTE);
  }
}

void loop() {
}
8  Forum 2005-2010 (read only) / News / Re: Arduino 0018 now available. on: February 07, 2010, 04:17:09 am
Quote
And for those who experience delays opening the "Tools" menu or when the ide starts in Windows: http://erwin.ried.cl/files/articles/arduino_bluetooth_001/rxtxSerial-2.2_fixed_2009-08-04.rar
Thanks!

I am really disappointed with the devs for not including this fix. Without it Arduino seems like some buggy software made by kids... Yes I am harsh now, but it really gives them a bad image with such slowdowns and other bugs.

They should also fix parallel port bootloader burning by adding a "options window" to let you configure it. I wrote about that here:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1263359997

/harsh off

But other than that I am very happy with this release. Arduino sure makes things easier and I love it for that.
Pages: [1]