Show Posts
Pages: [1] 2 3 4
1  Using Arduino / Networking, Protocols, and Devices / Re: Seeed Relay board V1.0 and xbee on: March 22, 2013, 07:23:51 am
Got it.  Thanks for the help!   smiley-razz
2  Using Arduino / Networking, Protocols, and Devices / Seeed Relay board V1.0 and xbee on: March 20, 2013, 02:29:37 pm
Hi people,

I'm bought these

http://seeedstudio.com/wiki/Relay_Shield_V1.0

hoping that I could get two Uno's with two of the seeed relay shields and two xbee pro S1's to communicate.

According to the Seeed wiki you are able to send commands to the relays wirelessly but I can't get it to work.  Normally I would just mess with it until I could get it to work but I don't have time.  I am supposed to use this project for work by this Monday, 3/25/13! 

Anyway, if I understand it right the xbee on the shield has no communication with the Uno.  So the Uno can directly control the relays, and the xbee can directly control the relays but the xbee cannot control the relays THROUGH the arduino.  Unfortunately this is exactly what I need it to do.

If you have experience with this shield please let me know if my assumptions are correct.

I've already ordered the SEEED relay board V2.0 http://www.seeedstudio.com/depot/relay-shield-v20-p-1376.html which hopefully when combined with an xbee shield http://www.amazon.com/SainSmart-Shield-Module-Arduino-Duemilanove/dp/B006TQ30TW/ref=sr_1_1?s=electronics&ie=UTF8&qid=1363807669&sr=1-1&keywords=Xbee+Shield+Moduleon top will do what I need.

3  Using Arduino / Project Guidance / Re: Data syncing on: November 06, 2012, 11:50:46 am


Receiving Unit:

Code:
//  Original code borrowed from "Blink without delay"
//  and "Multijoy" by Principia Labs

// Import the Arduino Servo library
#include <Servo.h>

// User input for servo and position
int userInput[3];    // raw input from serial buffer, 3 bytes
int startbyte;       // start byte, begin reading input
int servo;           // which servo to pulse?
int pos;             // servo angle 0-180
int i;               // iterator

// LED on Pin 51 assigned to button
int LEDButton = 9;
int LEDSync = 11;
int pinState = LOW;

void setup()
{
  // LED on Pin 53 for digital on/off demo
  pinMode(LEDButton, OUTPUT);
  pinMode(LEDSync, OUTPUT);
  // Open the serial connection, 9600 baud
  Serial.begin(9600);
}

void loop() { // loop program
  // Wait for serial input (min 3 bytes in buffer)
  if (Serial.available() > 2) {
    // Read the first byte
    startbyte = Serial.read();
    // If it's really the startbyte (255) ...
    if (startbyte == 255) {
      // ... then get the next two bytes
      for (i=0;i<2;i++) {
        userInput[i] = Serial.read();
      }
      // First byte = servo to move?
      servo = userInput[0];
      // Second byte = which position?
      pos = userInput[1];
      // Packet error checking and recovery
      if (pos == 255) { servo = 255; }

      // Assign new position to appropriate servo
      switch (servo) {
       
        // LED on Pin 9 for digital on/off demo
        case 98:
          if (pos == 180) {
            if (pinState == LOW)
                pinState = HIGH;
                }
            else pinState = LOW;   
             
          if (pos == 0) {
            pinState = LOW;
           }
          digitalWrite(LEDButton, pinState);
          break;
         
        case 97:
          if (pos == 180) {
            if (pinState == LOW)
                pinState = HIGH;
                }
            else pinState = LOW;   
             
          if (pos == 0) {
            pinState = LOW;
           }
          digitalWrite(LEDSync, pinState);
          break;
      }
    }
  }
}

This code allows the second unit to receive the relayed signal from the first unit.
4  Using Arduino / Project Guidance / Re: Data syncing on: November 06, 2012, 11:49:47 am

Transceiver Unit:

Code:
//  Original code borrowed from "Blink without delay"
//  and "Multijoy" by Principia Labs



int LEDButton = 9;              // Button LED on Pin 9 named LEDButton
const int LEDBlink =  11;       // the number of the sync LED pin

// Variables will change:
int ledState = LOW;             // ledState used to set the LED
long previousMillis = 0;        // will store last time LED was updated

// the following variables are "long" because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long interval = 10000;          // Off time for Sync LED (milliseconds)
long interval2 = 500;           // On time for Sync LED (milliseconds)

// Import the Arduino Servo library
#include <Servo.h>

// User input for servo and position
int userInput[3];    // raw input from serial buffer, 3 bytes
int startbyte;       // start byte, begin reading input
int servo;           // which servo to pulse?
int pos;             // servo angle 0-180
int i;               // iterator


int pinState = LOW;  //Initial pinstate set

void setup()
{
   // LED on Pin 11 for digital on/off demo
  pinMode(LEDBlink, OUTPUT);

  // LED on Pin 9 for digital on/off demo
  pinMode(LEDButton, OUTPUT);

  // Open the serial connection, 9600 baud
  Serial.begin(9600);
}

void loop() {
  // Wait for serial input (min 3 bytes in buffer)
  if (Serial.available() > 2) {
    // Read the first byte
    startbyte = Serial.read();
    // If it's really the startbyte (255) ...
    if (startbyte == 255) {
      // ... then get the next two bytes
      for (i=0;i<2;i++) {
        userInput[i] = Serial.read();
      }
      // First byte = LED to control?
      servo = userInput[0];
      // Second byte = On or off?
      pos = userInput[1];
      // Packet error checking and recovery
      if (pos == 255) { servo = 255; }

      // Assign new position to appropriate servo (LED)
      switch (servo) {
       
        // LED on Pin 9 for digital on/off demo
        case 99:
          if (pos == 180) {     
            if (pinState == LOW)
                pinState = HIGH;
                Serial.print(char(255));        // error protection
                Serial.print(char(98));         // send command for "case 98"
                Serial.print(char(180));        // send state command
                }
            else {
              pinState = LOW;   
              Serial.print(char(255));        // error protection
              Serial.print(char(98));         // send command for "case 98"
              Serial.print(char(0));          // send state command
              }
          if (pos == 0) {
            pinState = LOW;
            Serial.print(char(255));        // error protection
            Serial.print(char(98));         // send command for "case 98"
            Serial.print(char(0));          // send state command
          }
          digitalWrite(LEDButton, pinState);
          break;
      }
    }
  } 
  unsigned long currentMillis = millis();    // "millis" is an internal timer that
                                             //  starts running on power up
 
  if(currentMillis - previousMillis > interval) {   
    // save the last time you blinked the LED
    previousMillis = currentMillis;   

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW){
      ledState = HIGH;
      Serial.print(char(255));        // error protection
      Serial.print(char(97));         // send command for "case 97"
      Serial.print(char(180));        // send state command
    }   
    else {
      ledState = LOW;
      Serial.print(char(255));        // error protection
      Serial.print(char(97));         // send command for "case 97"
      Serial.print(char(0));          // send state command
    }
    // set the LED with the ledState of the variable:
    digitalWrite(LEDBlink, ledState);
   
  }
    else if(currentMillis - previousMillis > interval2) {
    // save the last time you blinked the LED
    if (ledState == HIGH){
      ledState = LOW;
      Serial.print(char(255));        // error protection
      Serial.print(char(97));         // send command for "case 97"
      Serial.print(char(0));          // send state command
    digitalWrite(LEDBlink, ledState);
    previousMillis = currentMillis;  }   
  }
}



This code receives the signal from the handheld and relays it to Transceiver 2.  It also sends a signal to the handheld as confirmation.

5  Using Arduino / Project Guidance / Re: Data syncing on: November 06, 2012, 11:48:55 am
Ok, I got it.  I used some code from Principia Labs "MultiJoy" sketch to keep the wireless data organized.  He uses the term "error protection".   Anyway, if anyone cares here is the code I used:

Handheld:

Code:
//  Original code borrowed from "Blink without delay"
//  and "Multijoy" by Principia Labs



const int buttonPin = 2;     // the number of the pushbutton pin
const int LEDPin =  12;      // the number of the LED pin
int LEDButton = 9;           // LED on Pin 9 assigned to button
int LEDSync = 11;            // LED on Pin 11 assigned to button
int buttonState = 0;         // variable for reading the pushbutton status
int pinState = LOW;          // set initial state of pin
int t = 0;                   // switching variable


// Import the Arduino Servo library
#include <Servo.h>

// User input for servo and position
int userInput[3];    // raw input from serial buffer, 3 bytes
int startbyte;       // start byte, begin reading input
int servo;           // which servo to pulse?
int pos;             // servo angle 0-180
int i;               // iterator

void setup(){
 
  // Initialize outputs
  pinMode(LEDButton, OUTPUT);        //  set pin named "LEDButton" as output
  pinMode(LEDSync, OUTPUT);          
  pinMode(LEDPin, OUTPUT);      
  pinMode(buttonPin, INPUT);         //  set pin named "buttonPin" as input

buttonState = digitalRead(buttonPin);
  
    if (buttonState == HIGH) {
      if (t == 0) {
        Serial.print(char(255));        // error protection
        Serial.print(char(99));         // send command for "case 99"
        Serial.print(char(180));        // send state command
        digitalWrite(LEDPin, HIGH);
        t = 1;
      }
    }
    else {
      if (t == 1) {
        Serial.print(char(255));        // error protection
        Serial.print(char(99));         // send command for "case 99"
        Serial.print(char(0));          // send state command
        digitalWrite(LEDPin, LOW);
        t = 0;
    }
  }
}
  
  Serial.begin(9600); //set baud rate on Arduino to 9600
}

void loop(){

  // Wait for serial input (min 3 bytes in buffer)
  if (Serial.available() > 2) {
    // Read the first byte
    startbyte = Serial.read();
    // If it's really the startbyte (255) ...
    if (startbyte == 255) {
      // ... then get the next two bytes
      for (i=0;i<2;i++) {
        userInput[i] = Serial.read();
      }
      // First byte = servo to move?
      servo = userInput[0];
      // Second byte = which position?
      pos = userInput[1];
      // Packet error checking and recovery
      if (pos == 255) { servo = 255; }

      // Assign new position to appropriate servo
      switch (servo) {
      
        //  Upon receiving signal from the other units
        //  determine the case number and the condition
        //  and set the corresponding pinstate.
        
        case 98:
          if (pos == 180) {
            if (pinState == LOW)
                pinState = HIGH;
                }
            else pinState = LOW;  
            
          if (pos == 0) {
            pinState = LOW;
           }
          digitalWrite(LEDButton, pinState);
          break;
          
        case 97:
          if (pos == 180) {
            if (pinState == LOW)
                pinState = HIGH;
                }
            else pinState = LOW;  
            
          if (pos == 0) {
            pinState = LOW;
           }
          digitalWrite(LEDSync, pinState);
          break;
      }
    }
  }
  buttonState = digitalRead(buttonPin);
  
    if (buttonState == HIGH) {
      if (t == 0) {                         //  switching variable allows only one loop per state change                                            
        Serial.print(char(255));            //  error control
        Serial.print(char(99));             //  send command for "case 99"
        Serial.print(char(180));            //  send state command
        digitalWrite(LEDPin, HIGH);         //  turn the LED on
        t = 1;                              //  if buttonState HIGH and t = 0, do the above and change "t" to 1
      }
    }
    else {
      if (t == 1) {
        Serial.print(char(255));            // error protection
        Serial.print(char(99));             // send command for "case 99"
        Serial.print(char(0));              // send state command
        digitalWrite(LEDPin, LOW);          // turn the LED off
        t = 0;
    }
  }
}

The handheld transmits a signal to Logger 1 and also receives a signal from Logger 1 as confirmation that you are still in range.


6  Using Arduino / Project Guidance / Re: Data syncing on: October 26, 2012, 09:18:32 am
Quote
Do you know if you are having hardware or software issues?

How is the switch wired to the handheld unit?

How are the XBees configured?

Software.  The first problem is there is a delay when I close the switch on the handheld unit.  When I close the switch the corresponding LED's on the other 2 arduinos light up as much as a second later.  The next problem is with the periodic signal.  The third arduino will flash the periodic LED pretty rapidly (maybe 30Hz or so) but this flashing starts and stops somewhat in time with the 1 second interval prescribed in the "blink without delay" code. 

The switch is a normally open single pole momentary switch.  I have pin 2 connected to a 10k resistor which is connected to ground.  The switch has 5v+ to one side, the other side also goes to pin 2.

I bought the xbee pro 900 XSC for the extended range.   When I read the modem using the X-CTU software, it indicates that it is the XBP09-XSC and the function set is the xbee-pro xsc 9600.  I see no other function set available that would allow me to designate whether it is a router or coordinator.

I'll make sure my xbee shield is providing the correct voltage to the xbee.  I'll look into addressing the messages but i'm not sure how to do that yet.
Thanks for the GPS idea, but I'm already invested in this direction.  If I cant get it to work I may try it.
7  Using Arduino / Project Guidance / Re: Data syncing on: October 25, 2012, 01:34:12 pm
Ok, all the hardware is here and the code is installed but i'm having issues.  The LED's are very erratic and i'm not sure why.

I will summarize what I'm trying to accomplish and how I tried to do that.

Basically I want to press a button on the first arduino and have arduinos 2 & 3 wirelessly receive that and have each one power an LED when the button is depressed.
I also want arduinos 2 & 3 to each power a separate LED that should flash at some periodic rate.  .1 second on, 1 second off, or whatever time settings I choose.  

So here's how I tried to do it:

The first arduino/xbee simply sends out an "H" or "L" and powers an LED depending on the position of the switch on pin 2.

The second arduino/xbee receives the "H" or "L" and powers another LED accordingly.  It also uses a modified version of the "Blink without delay" example to run the periodic flashing.  I have attached a Serial.print ("N") or "F" to the state of the periodic LED.  

The third arduino/xbee receives either the "N" or "F" or "H" or "L" and powers LED's accordingly.


I know this is simple but I can't seem to get it to work.  


Any help would be greatly appreciated.
8  Using Arduino / Project Guidance / Re: Data syncing on: October 23, 2012, 04:10:21 pm
Hey guys, I am just waiting for the xbee sheilds, should be here thursday.  I have the code ready for all three arduinos, I was hoping someone could take a quick look.  I'm not too sure about serial communication parts.  

Can you take a look at this code and see if I'm on the right track for making these three units communicate with each other?  Thanks.

Here is what I have for the handheld unit:

Code:
/*
Pin 2 is connected to switch terminal and one end of resistor
other end of resistor is connected to ground
other switch terminal is connected to 5v
Pin 12 is for transmit indicator LED
*/

const int buttonPin = 2;     // the number of the pushbutton pin
const int ledPin =  12;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status
int tim = 0;

void setup() { //Arduino initial setup

  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);     
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);   
 
  Serial.begin(9600); //set baud rate on Arduino to 9600

}

void loop() { //loop program

  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:L
  if (buttonState == HIGH) {     
    // turn LED on:   
    digitalWrite(ledPin, HIGH); 
    Serial.print("H"); //Send the character H
    tim = 1;
  }
  else if (tim == 1) {
    // turn LED off:
    digitalWrite(ledPin, LOW);
    Serial.print("L"); //Send the character H
    tim = 0;
   }
}

Here is what I have for the first receiving unit:

Code:
// set pin numbers:
const int LEDBlink =  13;      // the number of the LED pin

// Variables will change:
int ledState = LOW;             // ledState used to set the LED
long previousMillis = 0;        // will store last time LED was updated

// the follow variables is a long because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long interval = 2000;           // interval at which to blink (milliseconds)
long interval2 = 100;           // interval at which to blink (milliseconds)

int LEDButton = 11; // Assign Pin 11 for Button LED
void setup() { //Arduino initial setup  

  Serial.begin(9600); //Set baud rate for Arduino to 9600
 
 pinMode(LEDBlink, OUTPUT);     // set the digital pin as output:
 pinMode(LEDButton, OUTPUT); // Make Digital  Pin 11 as Output Pin

}

void loop() { // loop program
  if (Serial.available()) { //If there is data in the Serial Line
    int dataByte = Serial.read(); //save data into integer variable dataByte
    Serial.print(dataByte, BYTE); //Print to screen the variable received
          if(dataByte == 'H'){ //if the variable is the character H
             digitalWrite(LEDButton, HIGH); //then Button LED pin is ON
            }
            else if(dataByte == 'L') { // if the variable is the character L
              digitalWrite(LEDButton, LOW); // then Button LED pin is off        
    }
  }
  unsigned long currentMillis = millis();
 
  if(currentMillis - previousMillis > interval) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;  

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW){
      ledState = HIGH;
      Serial.print("N");  //sends N to other arduino    
    }  
    else {
      ledState = LOW;
      Serial.print("F");  //sends F to other arduino
    }
    // set the LED with the ledState of the variable:
    digitalWrite(LEDBlink, ledState);
    
  }
    else if(currentMillis - previousMillis > interval2) {
    // save the last time you blinked the LED
    if (ledState == HIGH){
      ledState = LOW;
      Serial.print("F");  //sends F to other arduino
    digitalWrite(LEDBlink, ledState);
    previousMillis = currentMillis;  }      
    }
}

Here is what I have for the second receiving unit:

Code:
int LEDBlink = 11; // Assign Pin 11 for Sync LED
int LEDButton = 9; // Assign Pin 9 for Button LED

void setup() { //Arduino initial setup  

  Serial.begin(9600); //Set baud rate for Arduino to 9600
 
 pinMode(LEDBlink, OUTPUT);     // set the digital pin as output:
 pinMode(LEDButton, OUTPUT);     // set the digital pin as output:
}

void loop() { // loop program
  if (Serial.available()) { //If there is data in the Serial Line
    int dataByte = Serial.read(); //save data into integer variable dataByte
    Serial.print(dataByte, BYTE); //Print to screen the variable received

          if(dataByte == 'N'){ //if the variable is the character N
             digitalWrite(LEDBlink, HIGH); //then Sync LED pin is ON
            }

            else if(dataByte == 'F') { // if the variable is the character F
              digitalWrite(LEDBlink, LOW); // then Sync LED pin is off  
            }

          if(dataByte == 'H'){ //if the variable is the character H
             digitalWrite(LEDButton, HIGH); //then Button LED pin is ON
            }

            else if(dataByte == 'L') { // if the variable is the character L
              digitalWrite(LEDButton, LOW); // then Button LED pin is off        
            }
  }
}
9  Community / Bar Sport / Re: Oscilloscope/Function Generator Recommendations on: October 18, 2012, 02:24:44 pm
Sorry, I'm a bit new to this, how do I use pulse counter/timer to create a 100kHz squarewave?

thanks
10  Community / Bar Sport / Re: Oscilloscope/Function Generator Recommendations on: October 16, 2012, 12:07:09 pm
Hello,

For my purposes I only need to switch from zero to 5 volts at a frequency of 100kHz.  I have tried this using the digitalWrite function and it works but it seems to be a bit inconsistent.  Is there a way to create a nice clean pattern with a 10us period (100kHz)?

Thanks!
11  Using Arduino / Project Guidance / Re: Data syncing on: October 10, 2012, 11:00:10 am
When I press a button on the handheld unit I want it to wirelessly communicate a signal to the other two units at the loggers.  This signal will cause the two units at the loggers to send a 5v pulse to the dataloggers.  The dataloggers, not the arduinos, will be recording the 60 channels of data, including the sync pulses from the arduinos.
12  Using Arduino / Project Guidance / Re: Data syncing on: October 10, 2012, 09:25:05 am
My constraints are not that critical, 200ms delay is fine.  I will be logging about 60 analog signals along with these sync signals from the arduinos.  I will use the arduino signal to visually align all of the data from the two dataloggers once it has been graphed.
13  Using Arduino / Project Guidance / Re: Data syncing on: October 10, 2012, 08:55:38 am
Quote
Why do the loggers need to talk to each other? If they are going to, what is the third unit bringing to the party? One logger could simply send the signal when it is time for both loggers to do something. Whatever that something is.

Right, the 3rd unit does not need to transmit.  The handheld needs to transmit only, the first logger needs to transmit and receive and the second logger needs to receive only.  I'd like it this way because i want the periodic signal to continue even if the handheld is out of range.  If I can do this in AT that's fine.  

Quote
Up to 15 mile units to transmit 300 feet? OK.

Yes, 15 miles LOS, which is almost never the case.  The one logger will be housed in a metal box and I don't need the higher data rate of the 2.4GHz modules so why wouldnt I order the one with the best range? 

Quote
You haven't said what the idea is, other than to send "signals" from something you don't have yet to something else you don't have yet.

I'm not sure exactly what more information youre looking for.  I stated my goals, the equipment I plan to use to accomplish those goals.  Do I need to have the equipment in my hand before I seek "PROJECT GUIDANCE"?

Anyway, I do appreciate the input, and I will try to get the book on the ipad.
14  Using Arduino / Project Guidance / Data syncing on: October 10, 2012, 07:59:07 am
Hey guys,

I would appreciate some input on the particulars of this idea.

Here is what I'm trying to accomplish:

I have two dataloggers that I would like to send a periodic, synchronized 5v or 3.3v signal to.  The dataloggers will be physically isolated but not more than 20ft apart.  I would also like to send a separate, single pulse signal to both units that would be triggered by a handheld remote.  The remote must also be at least 300ft away from both loggers.

I'm pretty sure I will need to put the xbee's in API mode since there will be three, although i'm not sure yet what this means.  One thing that is important is that the signal going to the two loggers be almost perfectly synchronized.  So im thinking that the arduinos at the dataloggers should transmit and receive between each other for the periodic signal and they both should receive from the handheld unit for the intermittent pulse.  A few milliseconds lag time between units is ok.

Here is what I have in mind:

I was planning on buying 3 Uno's (to allow for future expansion), 3 xbee pro XSC's (for maximum range), and three xbee shields, project boxes, buttons, power supplies etc.

Let me know if you see any major flaws in this idea or improvements without making it too complicated.

Also, could you direct me to a project that has some simple commands like this sent wirelessly?

Thanks,
tony

15  Using Arduino / Networking, Protocols, and Devices / Re: Periodic LED and on demand on: October 10, 2012, 07:31:07 am
Thanks for the help guys.  I was able to accomplish my goal using the "blink without delay example".  If I have spare time I may try the countdown method but I'm wondering if the speed that the processor is able to get through the loop changes based on the task that it is working on.  I will be recording the 5v output signal on two different data loggers and using it sync the two units, so it's pretty important that the signal is consistent.  A few millisecs off here or there is ok but not much more.

Pages: [1] 2 3 4