Show Posts
Pages: 1 2 3 [4] 5 6 ... 25
46  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: Ethernet library documentation on: February 10, 2009, 02:09:28 am
We'll have to wait for some of the guru's to weigh in on the specifics.  I know the Wiznet supports 4 independent connections, but I'm not sure if/how the Arduino handles that.  I have not yet tried multiple connections.

It sounds like you are working on a somewhat similar project to me, but I'm using C#.  I'm still experimenting to decide if I want the Arduino's in client or server mode.

Quote
the adafruit shield has a transistor and caps and requires a 5v source (maybe for reset?)
I believe that is the 3.3V voltage regulator and supporting caps.  Since the Arduino runs at 5V and the Wiznet 3.3V you need a second supply.  This is true if you want to run the Wiznet without the shield also (don't try to run it direct off the 5V).

You may want to check out this thread:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1234006420
there is an issue with the latest release that may be causing some of your headaches.

Hopefully Mellis or someone else can give us some insight on your other questions.
47  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: Ethernet library documentation on: February 10, 2009, 12:52:25 am
I think it is because the Ethernet library is still pretty new and still getting all of the kinks worked out.  The longer it's around the more the documentation will improve.  Is there something specific you are having a problem with or need help on?

As far as hooking up a Wiznet module (810mj, 811mj, 812mj) it can be as simple as 4 wires.  SCK to D13, MISO to D12, MOSI to D11, SCS to D10 and of course a 3.3V supply and ground to the module and a ground connection to the arduino.  The pinouts for the Wiz modules are different depending on version, so check your datasheet.  You can get fancier if you want all the status LEDs, but I don't really find them that useful.
48  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: Spam fighting request on: September 09, 2008, 12:43:11 pm
It really does seem to be getting worse, why not address it now?  I've skipped wading through the messages several times in the last week due to the spam content.
49  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: Spam fighting request on: August 17, 2008, 12:31:43 am
Yes, it is getting old.
50  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: Arduino NG USB board does not run on ext. powe on: February 03, 2007, 03:33:54 am
Quote
atmel 168

Do you mean the ATMega8, or did you swap in a 168?
51  Forum 2005-2010 (read only) / Syntax & Programs / Re: Ethernet server() problem. on: January 05, 2011, 04:29:12 pm
I don't think the problem is with the Ethernet library, more likely you are stuck in your while reset == false loop when you disconnect.  Which means you will never check the connection again.
52  Forum 2005-2010 (read only) / Syntax & Programs / Re: Need a code check to see if this should work. on: February 25, 2010, 12:57:26 am
Looks like it should work.  Maybe you are saving the else for future use, but it is not required.  The only other thing is that the last state really only needs to be updated when it changes, but I think it will work fine as you have it. i.e.

Code:
if (entrystate != lastentrystate) {
  // save the current entrystate as the lastentrystate,
  // for next time through the loop
  lastentrystate = entrystate;

  // when the state has changed see if change went
  // HIGH to LOW
  if (entrysensor == HIGH) {
    // Board entered machine, increment board quantity
    boardqty++;
  }
}

I've done some similar projects that involved a board stacker.  Our main issue was that the ovens are unrelenting and keep pushing boards out even if the downstream is not ready.

Let us know how it goes!
53  Forum 2005-2010 (read only) / Syntax & Programs / Re: Need a code check to see if this should work. on: February 24, 2010, 01:36:23 am
Well, you have a decent start but there are a few problems.  AnalogRead returns a value between 0 and 1023.  http://arduino.cc/en/Reference/AnalogRead  Depending on your sensor, you may actually be better off using a digital pin with HIGH and LOW values.  Another issue is that you never wait for the sensor to go off so your count will almost instantly be hit as the code loops.

Do you have any more information about your conveyor and other line equipment?  Most conveyors have a SMEMA interface that provides the control and sensing you require.  If you are controlling the conveyor I don't see a real need for the alarm as you shouldn't ever allow more than the maximum number of boards into the conveyor.  It's hard to say what your best option is without know more about exactly what your upstream and downstream equipment is and how it operates.
54  Forum 2005-2010 (read only) / Syntax & Programs / Re: Wstring question on: October 02, 2009, 01:28:28 pm
It's a great library and makes string manipulation much easier, but there is a bug in the posted library.  Please see this thread for the patch:

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1241618944

I have contacted the library author and hoping he patches it soon.

Frank is correct that there is no magic happening, but for me the purpose is to make things easier and cleaner.  I think it achieves that.
55  Forum 2005-2010 (read only) / Syntax & Programs / Re: Analog input, Digital output... Please help me... on: September 09, 2009, 10:21:14 am
Keep in mind delay is blocking.  If you need another part of your program to do something for the 1 second that VAR = 1 then you will need to try a different approach.  If you take a peek at the "Blink Without Delay" example it should give you some ideas.
56  Forum 2005-2010 (read only) / Syntax & Programs / Re: "pin = 1 << p" on: August 31, 2009, 10:57:22 pm
http://www.arduino.cc/playground/Code/BitMath
57  Forum 2005-2010 (read only) / Syntax & Programs / Re: Cleaning up Serial Print to LCDs on: August 25, 2009, 04:29:20 pm
Did you patch the memory leak in the string library?

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1241618944/11
58  Forum 2005-2010 (read only) / Syntax & Programs / Re: Without delay on: August 17, 2009, 09:20:09 pm
Here is some quickly put together and untested code that should get you going.

Code:
#include <MegaServo.h>
   MegaServo myservo;
// Begin Robot Code
//int micVal;
//int cdsVal;
int irLval;  // Left IR
int irCval;  // Center IR
int irRval;  // Right IR
int i;   // Generic Counter
int x;  // Generic Counter
int PLval;  // Pulse Width for Left Servo
int PRval;  // Pulse Width for Right Servo
int cntr;  // Generic Counter Used for Determining amt. of Object Detections
int counter; // Generic Counter
int clrpth;  // amt. of Milliseconds Of Unobstructed Path
int objdet;  // Time an Object was Detected
int task;  // Routine to Follow for Clearest Path
int pwm;  // Pulse Width for Pan Servo
boolean add;  // Whether to Increment or Decrement PW Value for Pan Servo
int distance;  // Distance to Object Detected via Ultrasonic Ranger
int oldDistance;  // Previous Distance Value Read from Ultrasonic Ranger

float scale = 1.9866666666666666666666666666667;  // *Not Currently Used*

int LeftPin = 6;  // Left Servo
int RightPin = 9;  // Right Servo
int PingServoPin = 5;  // Pan Servo
int irLPin = 0;            // Analog 0; Left IR
int irCPin = 1;            // Analog 1; Center IR
int irRPin = 2;            // Analog 2; Right IR
int ultraSoundSignal = 7; // Ultrasound signal pin
int val = 0;              // Used for Ultrasonic Ranger
int ultrasoundValue = 0;  // Raw Distance Val
int oldUltrasoundValue;  // *Not used*
int pulseCount;        // Generic Counter
int timecount = 0; // Echo counter
int ledPin = 13; // LED connected to digital pin 13
int pos = 0;
int SPKR = 4;

long browTimer;
int browState;

#define BAUD 9600
#define CmConstant 1/29.034

void setup() {
  myservo.attach(11);
  pos = 40;
  myservo.write(pos);
  delay(150);
  myservo.detach();
  Serial.begin(9600);
  pinMode(SPKR, OUTPUT);
  pinMode(ledPin, OUTPUT);
  pinMode(LeftPin, OUTPUT);
  pinMode(RightPin, OUTPUT);
  pinMode(PingServoPin, OUTPUT);
  pinMode(irLPin, INPUT);
  pinMode(irCPin, INPUT);
  pinMode(irRPin, INPUT);
    // Beep!
  {
    for (int i = 0; i<500; i++) {  // generate a 1KHz tone for 1/2 second
      digitalWrite(SPKR, HIGH);
      delayMicroseconds(400);
      digitalWrite(SPKR, LOW);
      delayMicroseconds(400);
    }
  for(i = 0; i < 20; i++) {
    digitalWrite(PingServoPin, HIGH);
    delayMicroseconds(655 * 2);
    digitalWrite(PingServoPin, LOW);
    delay(20);
  }
  ultrasoundValue = 600;
  i = 0;
}
}
void loop()
{
  Look();
  Go();
  checkBrow();
}
void Look() {
  irLval = analogRead(irLPin);
  irCval = analogRead(irCPin);
  irRval = analogRead(irRPin);
  if(irLval > 200) {
    BrowUP();
     PLval = 850;
    PRval = 820;
    x = 5;
    cntr = cntr + 1;
    clrpth = 0;
    objdet = millis();
  }
  else if(irCval > 200) {
    BrowUP();
    PLval = 850;
    PRval = 820;
    x = 10;
    cntr = cntr + 1;
    clrpth = 0;
    objdet = millis();
  }
  else if(irRval > 200) {
    BrowUP();
    PLval = 650;
    PRval = 620;
    x = 5;
    cntr = cntr + 1;
    clrpth = 0;
    objdet = millis();
  }
  else {
    x = 1;
    PLval = 850;
    PRval = 620;
    counter = counter + 1;
    clrpth = (millis() - objdet);
    if(add == true) {
      pwm = pwm + 50;
    }
    else if(add == false) {
      pwm = pwm - 50;
    }
    if(pwm < 400) {
      pwm = 400;
      add = true;
    }
    if(pwm > 950) {
      pwm = 950;
      add = false;
    }
    digitalWrite(PingServoPin, HIGH);
    delayMicroseconds(pwm * 2);
    digitalWrite(PingServoPin, LOW);
    delay(20);
    readPing();
    if(ultrasoundValue < 150) { // this value is the closeness of PING will get.
      cntr = cntr + 1;
      switch(pwm) {
      case 400:
        x = 7;
        PLval = 650;
        PRval = 650;
        Go();
        break;
      case 500:
        x = 10;
        PLval = 650;
        PRval = 650;
        Go();
        break;
      case 600:
        x = 14;
        PLval = 850;
        PRval = 850;
        Go();
        break;
      case 700:
        x = 10;
        PLval = 850;
        PRval = 850;
        Go();
        break;
      case 950:
        x = 7;
        PLval = 850;
        PRval = 850;
        Go();
        break;
      }
    }
  }
  if(cntr > 25 && clrpth < 2000) {
    clrpth = 0;
    cntr = 0;
    Scan();
  }
}
void Go() {
  for(i = 0; i < x; i++) {
    digitalWrite(LeftPin, HIGH);
    delayMicroseconds(PLval * 2);
    digitalWrite(LeftPin, LOW);
    digitalWrite(RightPin, HIGH);
    delayMicroseconds(PRval * 2);
    digitalWrite(RightPin, LOW);
    delay(20);
  }
}
void readPing() {  // Get Distance from Ultrasonic Ranger
  timecount = 0;
  val = 0;
  pinMode(ultraSoundSignal, OUTPUT); // Switch signalpin to output
  digitalWrite(ultraSoundSignal, LOW); // Send low pulse
  delayMicroseconds(2); // Wait for 2 microseconds
  digitalWrite(ultraSoundSignal, HIGH); // Send high pulse
  delayMicroseconds(5); // Wait for 5 microseconds
  digitalWrite(ultraSoundSignal, LOW); // Holdoff
  pinMode(ultraSoundSignal, INPUT); // Switch signalpin to input
  val = digitalRead(ultraSoundSignal); // Append signal value to val
  while(val == LOW) { // Loop until pin reads a high value
    val = digitalRead(ultraSoundSignal);
  }
  while(val == HIGH) { // Loop until pin reads a high value
    val = digitalRead(ultraSoundSignal);
    timecount = timecount +1;            // Count echo pulse time
  }
  ultrasoundValue = timecount; // Append echo pulse time to ultrasoundValue
  // Lite up LED if any value is passed by the echo pulse
   if(timecount > 0){
    digitalWrite(ledPin, HIGH);
  }
}
void Scan() {   // Scan for the Clearest Path
  oldDistance = 30;
  task = 0;
  for(i = 1; i < 5; i++) {
    switch(i) {
    case 1:
      //Serial.println("Pos. 1");
      pwm = 1125;    ///  incr. by 100 from 1085
      break;
    case 2:
      //Serial.println("Pos. 2");
      pwm = 850; //// increased by 100 from 850
      break;
    case 3:
      //Serial.println("Pos. 3");
      pwm = 400;
      break;
    case 4:
      //Serial.println("Pos. 4");
      pwm = 235;
      break;
    }
    for(pulseCount = 0; pulseCount < 20; pulseCount++) {  // Adjust Pan Servo and Read USR
      digitalWrite(PingServoPin, HIGH);
      delayMicroseconds(pwm * 2);
      digitalWrite(PingServoPin, LOW);
      readPing();
      delay(20);
    }
    distance = ((float)ultrasoundValue * CmConstant);   // Calculate Distance in Cm
    if(distance > oldDistance) {  // If the Newest distance is longer, replace previous reading with it
      oldDistance = distance;
      task = i;   // Set task equal to Pan Servo Position
    }
  }
  distance = 50;  // Prevents Scan from Looping
  switch(task) {   // Determine which task should be carried out
  case 0:  // Center was clearest
    x = 28;
    PLval = (850);
    PRval = (850);
    Go();
    break;
  case 1:  // 90 degrees Left was Clearest
    x = 14;
    PLval = (650);
    PRval = (650);
    Go();
    break;
  case 2:  // 45 degrees left
    x = 7;
    PLval = (650);
    PRval = (650);
    Go();
    break;
  case 3:  // 45 degrees right
    x = 7;
    PLval = (850);
    PRval = (850);
    Go();
    break;
  case 4:  // 90 degrees right
    x = 14;
    PLval = (850);
    PRval = (850);
    Go();
    break;
  }
}

void checkBrow()
{
  switch (browState)
  {
    case 1: //Brow Up
      if ((millis() - browTimer) > 500)
      {
        BrowDown();
      }
      break;
    case 2: //Brow Down Waiting to Detach Servo
      if ((millis() - browTimer) > 120)
      {
        myservo.detach();
        browState = 0;
      }
      break;
    default:
      break;
  }
}

void BrowUP()
{
  browTimer = millis();
  myservo.attach(11);
  pos = 0;
  myservo.write(pos);
  browState = 1;
}

void BrowDOWN()
{
  browTimer = millis();
  myservo.attach(11);
  pos = 40;
  myservo.write(pos);
  browState = 2;
}

// End Robot Code
59  Forum 2005-2010 (read only) / Syntax & Programs / Re: Question about software and PING on: August 16, 2009, 12:48:33 am
Did you check out the blink without delay example?
60  Forum 2005-2010 (read only) / Syntax & Programs / Re: Question about software and PING on: August 15, 2009, 08:28:58 pm
Just keep in mind that is a full 1/2 second that the Arduino is doing nothing.  Take a look at the blink without delay example on the site to give you some ideas.
Pages: 1 2 3 [4] 5 6 ... 25