Show Posts
Pages: 1 [2] 3 4 ... 17
16  Using Arduino / Networking, Protocols, and Devices / Re: SPI conflict with NRF2.4 radios on: December 30, 2013, 09:01:21 am
It appears to be a bit more complicated than just pulling the CS low...

The NRF2.4 radio refuses to work with the RA8875 attached to the SPI bus (it doesn't even have to be powered!!!)

Does anyone have any good ideas?
17  Using Arduino / Networking, Protocols, and Devices / Re: SPI conflict with NRF2.4 radios on: December 29, 2013, 10:04:13 pm
The CS pin for the tft driver/screen is pin 4. I'll give it a try.

Thank you.
18  Using Arduino / Networking, Protocols, and Devices / SPI conflict with NRF2.4 radios on: December 29, 2013, 09:20:01 pm
Is there a convenient way to stop the NRF2.4 radio from listening to the SPI bus until is is needed? I am using the maniacbug RF24 and RF24Network libraries and driver with an Adafruit RA8875 tft screen driver that also uses SPI and they are not playing nice together.

I'll have to pull each device off of the SPI bus while the other is being called but I never had to do this before with the NRF2.4 radios and the RF24(network) library.

When creating the radio instance:

Code:
RF24 radio(9,10);

can I just do this instead??:


Code:
int cePIN = 9; // set later as an output also
int csPIN = 10; // set later as an output also
...
RF24 radio(cePIN,csPIN);
...
pinMode(cePIN,OUTPUT);
pinMode(csnPIN,OUTPUT);
...
  cePIN(LOW); //*Radio Enabled* When I need to call the radio
  csnPIN(HIGH);
...
  cePIN(HIGH); //*Radio Disabled* When I need to call the tft screen
  csnPIN(LOW);
19  Using Arduino / Networking, Protocols, and Devices / Re: maniacbug's rf24 libraries - How to change data rate? on: December 28, 2013, 08:24:42 pm
Yeah... So I really feel dumb...

If anyone else runs into this problem and is using both the RF24 library and the RF24 Network library... the RF24 Network will change the data rate set in the RF24 library to 1MBPS as a default. Meaning if you set the data rate in the RF24 library or if you change the data rate using "radio.setDataRate" prior to calling "network.begin" then the setting will not persist. If you set the data after "network.begin" then the print details will not be accurate the data rate should be whatever was set.
20  Using Arduino / Networking, Protocols, and Devices / maniacbug's rf24 libraries - How to change data rate? on: December 28, 2013, 07:46:39 pm
I can't for the life of me figure out how to do this... I feel really dumb because I'm sure that it is simple, but frankly I feel that it is still beyond my abilities...

Can anyone lend a hand?

Thanks.
21  Using Arduino / Networking, Protocols, and Devices / Re: RSSI, 900mhz Vs 2.4ghz Xbees on: April 27, 2013, 07:30:27 pm
The whole point of this thread, which I believe is still remains unanwsered, is why does the 900 mhz have zero RSSI resolution (making it even useless as a "rough" indication) when the 2.4 ghz has fantastic RSSI resolution?
22  Using Arduino / Networking, Protocols, and Devices / Re: RSSI, 900mhz Vs 2.4ghz Xbees on: April 26, 2013, 09:56:24 pm
I feel like everyone is getting very hung up on range vs RSSI... Why does the RSSI signal have to be associated with a units? Why can't it just a rough indicator of signal strength as I believe it was intended to be...
23  Using Arduino / Networking, Protocols, and Devices / Re: RSSI, 900mhz Vs 2.4ghz Xbees on: April 25, 2013, 07:21:18 pm
Thanks for the information guys but I'm not sure if my answer is hidden in there or not.

I still don't know the reason why the resolution of the RSSI signal on the 900 mhz Xbee is so poor.
24  Using Arduino / Networking, Protocols, and Devices / RSSI, 900mhz Vs 2.4ghz Xbees on: April 24, 2013, 08:16:59 pm
I have this little bit of code written for a copter telemetry system and find that it works really well, however, I did notice that the RSSI strength works very well with the 2.4ghz Xbee Pro radios and not well at all with the 900mhz Pro radios. The 2.4s range from 100% to about 20% before completely dropping out and gets weaker as I walk farther from the transmitting radio. The 900s tend to hang about 46% (with the antennas within inches of each other) instead of 100% and the signal does not show that it gets all that much weak as I walk away. I get about 700ft away and the signal will begin to flicker between 46-35% and then drops.

Does anyone know what the difference is between the two radios and the way that they transmit RSSI?

Thanks

Here is the code:

Code:
#include <TextFinder.h>
#include "PCD8544.h"

TextFinder finder(Serial);

const int NUMBER_OF_FIELDS = 24; // how many comma-separated fields we expect
int fieldIndex = 0; // the current field being received
float values[NUMBER_OF_FIELDS]; // array holding values for all the fields

//Adafruit Pin out. Sparkfun may be different
// pin 7 - (SCLK)
// pin 6 - (DIN)
// pin 5 - (D/C)
// pin 4 - (CS)
// pin 3 - (RST)
PCD8544 nokia = PCD8544(7, 6, 5, 4, 3);

float batPix = 0; //Pixel for battery graphics
int rssiPix = 0; //Pixel for battery graphics
float deltaV = 0; //Used for the battery graphic
int craftHeading = 0;
int craftAlt = 0;
float craftBattery = 0;
int rssiDur = 0;
int rssiPercent;

void setup()
{
Serial.begin(57600); // Initialize serial port to send and receive at 57600 baud

pinMode(19, INPUT); //Xbee RSSI pin

  nokia.init();
  nokia.setContrast(45);
}

void loop()
{
Serial.print('x'); 

Serial.print('s'); 

nokia.clear(); //clearing LCD

for(fieldIndex = 0; fieldIndex < 24; fieldIndex ++)
{
values[fieldIndex] = finder.getFloat(); // get a numeric value
}

Serial.print('x');

//Assigning craft values based on array index numbers

  craftHeading = (values[3] * 57.17); //57.17 is to convert 0-6 to 0-359*
  craftAlt = (values[4] * 3.28084); //3.28084 to convert to feet
  craftBattery = values[22] + 0.28; //0.28 is a battery correction factor for the AQ32 wacky battery VD
  rssiDur = pulseIn(19, HIGH, 100);
  rssiPercent = 100 * rssiDur / 64;
if(rssiDur < 1){ // If the PWM = 100%, there is no duration (rssiDur = 0us)
  rssiPercent = 100; // so we use an if statement to override the false 0% reading
}

fieldIndex = 0; // ready to start over

//Graphic Math

deltaV = craftBattery - 10.0;
batPix = constrain(deltaV*13.75, 0, 33);
rssiPix = map(rssiPercent, 0, 100, 0, 33);

//--------------------------------------

nokia.setCursor(4, 0);
nokia.print("HDG");
nokia.setCursor(34, 0);
nokia.print("ALT");
nokia.setCursor(63, 0);
nokia.print("MDE");
nokia.drawline(25, 0, 25, 48, BLACK);
nokia.drawline(58, 0, 58, 48, BLACK);
nokia.drawline(0, 17, 84, 17, BLACK);
nokia.drawline(0, 27, 84, 27, BLACK);
nokia.drawline(0, 37, 84, 37, BLACK);
nokia.setCursor(4, 9);
nokia.print(craftHeading);
nokia.setCursor(34, 9);
nokia.print(craftAlt);
nokia.setCursor(0, 19);
nokia.print("BATT");
nokia.setCursor(60, 19);
nokia.print(craftBattery);
nokia.setCursor(0, 29);
nokia.print("RSSI");
nokia.setCursor(60, 29);
nokia.print(rssiPercent);
//nokia.setCursor(0, 39);
//nokia.print("ATAL");
//nokia.setCursor(30, 39);
//nokia.print("BTAL");
//nokia.setCursor(60, 39);
//nokia.print("XTRA");

nokia.fillrect(25, 19, batPix, 7, 1);
nokia.fillrect(25, 29, rssiPix, 7, 1);

if(values[23]>=1.0){
  nokia.setCursor(63, 9);
  nokia.print("ATT");
  }
  else{
  nokia.setCursor(63, 9);
  nokia.print("RTE");
  }

nokia.display();

}
25  Using Arduino / Networking, Protocols, and Devices / Re: What could be different about the Fio/Xbee? on: March 14, 2013, 08:11:06 pm
Code Part 2 (was greater than 9500 characters)

Code:
//Alarm Adjustment

//Heading

if(menuVal == 0){
    nokia.drawrect(31, 8, 21, 9, 1); //8, 17, 26
    nokia.display();
      for( ; digitalRead(ltBut) == LOW && millis() - time > debounce ; alarmHeading++ ){
        nokia.setCursor(54, 9);
        nokia.print(alarmHeading);
        nokia.display();
//        delay(shortwait);
        time = millis();
      }
        if(alarmHeading  > 359){
          alarmHeading = 0;
        }
      for( ; digitalRead(rtBut) == LOW && millis() - time > debounce ; alarmHeading-- ){
        nokia.setCursor(54, 9);
        nokia.print(alarmHeading);
        nokia.display();
//        delay(shortwait);
        time = millis();
      }
        if(alarmHeading  < 0){
          alarmHeading = 359;
        }
}

//Alt

if(menuVal == 1){
    nokia.drawrect(31, 17, 21, 9, 1); //8, 17, 26
    nokia.display();
      for( ; digitalRead(ltBut) == LOW && millis() - time > debounce ; alarmAlt++ ){
        nokia.setCursor(54, 18);
        nokia.print(alarmAlt);
        nokia.display();
//        delay(shortwait);
        time = millis();
       }
      for( ; digitalRead(rtBut) == LOW && millis() - time > debounce ; alarmAlt-- ){
        nokia.setCursor(54, 18);
        nokia.print(alarmAlt);
        nokia.display();
//        delay(shortwait);
        time = millis();
       }
      if(alarmAlt  < 0){
        alarmAlt = 0;
singleBEEP();
}

// We wait for the center button to confirm that the value should get stored in the EEPROM
  if(digitalRead(cnBut) == LOW && millis() - time > debounce){  //Caution!!!! EEPROM will not accept anything greater than 255!
    EEPROM.write(1, alarmAlt);    //If you need to save Alts greater than 255, research arduino's
//    delay(wait);             //website for instruction and more information.
        time = millis();
    doubleBEEP();
    confirmAlt = 0;
    }
}

//Bat

if(menuVal == 2){
    nokia.drawrect(31, 26, 21, 9, 1); //8, 17, 26
    nokia.display();
      for( int i = 0; digitalRead(ltBut) == LOW && millis() - time > debounce ; i++ ){
        alarmBattery = alarmBattery + (i * 0.1);
        nokia.setCursor(54, 27);
        nokia.print(alarmBattery);
        nokia.display();
//        delay(shortwait);
        time = millis();
       }
      for( int i = 0; digitalRead(rtBut) == LOW && millis() - time > debounce ; i-- ){
        alarmBattery = alarmBattery + (i * 0.1);
        nokia.setCursor(54, 27);
        nokia.print(alarmBattery);
        nokia.display();
//        delay(shortwait);
        time = millis();
       }
      if(alarmBattery  < 10.0){
        alarmBattery = 10.0;
        singleBEEP();
       }
      if(alarmBattery  > 12.4){
        alarmBattery = 12.4;
        singleBEEP();
       }
// We wait for the center button to confirm that the value should get stored in the EEPROM
  if(digitalRead(cnBut) == LOW && millis() - time > debounce){
    tempBat = (alarmBattery * 10); //this will convert our float to an int that we will convert back during power up.
    EEPROM.write(2, tempBat);      //for example 10.2 * 10 = 102. 102 / 10 = 10.2... make sense?
//    delay(wait);
        time = millis();
    doubleBEEP();
    }
}

//Bat Alarm

if(craftBattery < alarmBattery){
  doubleBEEP(); //if the battery is equal to or less than the setting, make a lot of noise continuously.
}
if(alarmHeading == craftHeading){ // maybe add && confirmHead == 0
  doubleBEEP();
  shortVib();
//  confirmHead = 1;
}

//Alt Alarm

if(alarmAlt == craftAlt && confirmAlt == 0){
  tripleBEEP(); //if the battery is equal to or less than the setting, make a lot of noise continuously.
  shortVib();
  confirmAlt = 1;
}
if(confirmAlt == 1 && craftAlt <= (alarmAlt - 3)){ //Notify that craft has lost alt below set point and 3 foot dead band
  dnBEEP();
  confirmAlt = 0;
}
if(confirmAlt == 1 && craftAlt >= (alarmAlt + 3)){ //Notify that craft has gained alt above set point and 3 foot dead band
  upBEEP();
  confirmAlt = 0;
}

}

//-------------------------------------------

void singleBEEP() {
  // play a note on pin 9 at 1000hz for 75 ms:
  tone(buzzPin, 1000, 75);
}

//-------------------------------------------

void doubleBEEP() {
  tone(buzzPin, 1000, 75);
  delay(125);
  tone(buzzPin, 1000, 75);
}

//------------------------------------------

void tripleBEEP() {
  tone(buzzPin, 1000, 75);
  delay(125);
  tone(buzzPin, 1000, 75);
  delay(125);
  tone(buzzPin, 1000, 75);
}

//-----------------------------------------

void upBEEP() {
  tone(buzzPin, 800, 125);
  delay(100);
  tone(buzzPin, 1000, 125);
}

//----------------------------------------

void dnBEEP() {
  tone(buzzPin, 1000, 125);
  delay(100);
  tone(buzzPin, 800, 125);
}

//---------------------------------------

void shortVib() {     
  analogWrite(motorPin, 100); //where speed = 0-255
  delay(250);
  analogWrite(motorPin, 0); //where speed = 0-255}
}
26  Using Arduino / Networking, Protocols, and Devices / Re: What could be different about the Fio/Xbee? on: March 14, 2013, 08:10:28 pm
Code:
#include <TextFinder.h>
#include "PCD8544.h"
#include <EEPROM.h>

TextFinder finder(Serial);

const int NUMBER_OF_FIELDS = 24; // how many comma-separated fields we expect
int fieldIndex = 0; // the current field being received
float values[NUMBER_OF_FIELDS]; // array holding values for all the fields

//Adafruit Pin out. Sparkfun may be different
// pin 7 - (SCLK)
// pin 6 - (DIN)
// pin 5 - (D/C)
// pin 4 - (CS)
// pin 3 - (RST)
PCD8544 nokia = PCD8544(7, 6, 5, 4, 3);

const int upBut = 14;
const int dnBut = 15;
const int rtBut = 16;
const int ltBut = 17;
const int cnBut = 18;
const int buzzPin = 9;
const int motorPin = 11;

int batPix = 0; //Pixel for battery graphics
float deltaV = 0; //Used for the battery graphic
int craftHeading = 0;
int alarmHeading = 0;
int craftAlt = 0;
int alarmAlt;
float craftBattery = 0;
float alarmBattery;
int menuVal = 0;
int debounce = 25;
int shortwait = 75;
float tempBat;
int confirmHead = 0;
int confirmAlt = 0;
int craftMode = 0;
unsigned long time = 0;
String mode;

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

  pinMode(upBut, INPUT);
  pinMode(dnBut, INPUT);
  pinMode(rtBut, INPUT);
  pinMode(ltBut, INPUT);
  pinMode(cnBut, INPUT);
  pinMode(motorPin, OUTPUT);
  
  
//  alarmHeading = EEPROM.read(0); Not sure what the value of storing the heading is yet... It will always be different so...
  alarmAlt = EEPROM.read(1);
  tempBat = (EEPROM.read(2));
  alarmBattery = tempBat / 10; //converting int back to a float.


  nokia.init();
  nokia.setContrast(60);
  
  nokia.setCursor(0, 0);
  nokia.print("Connecting to Craft.......");
  nokia.display();
  
  delay(2500); //waiting for system to catch up
  Serial.print('s'); //sending the "s" command will tell the craft to "Read All Flight Values" and send them via serial
                     //refer to http://aeroquad.com/showwiki.php?title=Serial+Commands:+AeroQuad+Ground+Station+Interface+Definitions

}

void loop()
{
  
nokia.clear(); //clearing LCD

Serial.print('s');

while (Serial.available() ==0)
{
//wait for availiable serial data
}
//Reading and sorting serial data into an array
for(fieldIndex = 0; fieldIndex < 24; fieldIndex ++)
{
values[fieldIndex] = finder.getFloat(); // get a numeric value
}
Serial.print('x');

//Assigning craft values based on array index numbers

  craftHeading = (values[3] * 57.17); //57.17 is to convert 0-6 to 0-359*
  craftAlt = (values[4] * 3.28084); //3.28084 to convert to feet
  craftBattery = values[22] + 0.28; //0.28 is a battery correction factor for the AQ32 wacky battery VD
  craftMode = values[23]; // 0= Rate, 1= Att
  
//Battery Graphic Math

deltaV = 12.4 - craftBattery;
batPix = (60 - (25 * deltaV));

//Setting up grapfics display

nokia.setCursor(0, 0);
nokia.println("CRAFT    STTNG");
nokia.setCursor(0, 9);
nokia.print(craftHeading);
nokia.setCursor(33, 9);
nokia.print("HDG");
nokia.setCursor(54, 9);
nokia.print(alarmHeading);

nokia.setCursor(0, 18);
nokia.print(craftAlt);
nokia.setCursor(33, 18);
nokia.print("ALT");
nokia.setCursor(54, 18);
nokia.print(alarmAlt);

nokia.setCursor(0, 27);
nokia.print(craftBattery);
nokia.setCursor(33, 27);
nokia.print("BAT");
nokia.setCursor(54, 27);
nokia.print(alarmBattery);

nokia.setCursor(40, 0);
nokia.println(craftMode);

nokia.setCursor(0, 38);
nokia.print("E");
nokia.setCursor(78, 38);
nokia.print("F");

//Drawing battery at bottom

nokia.drawline(8, 36, 69, 36, BLACK);
nokia.drawline(8, 47, 69, 47, BLACK);
nokia.drawline(69, 36, 69, 47, BLACK);
nokia.drawline(8, 36, 8, 47, BLACK);
nokia.drawline(70, 38, 72, 38, BLACK);
nokia.drawline(70, 45, 72, 45, BLACK);
nokia.drawline(73, 38, 73, 45, BLACK);

nokia.fillrect(9, 37, batPix, 10, 1);
nokia.display();

fieldIndex = 0; // ready to start character index over

//Rate or Att mode display

//  if(craftMode == 0){
//    mode = ('R');
//  }
// else{
//    mode = ('A');
//  }

//menu nav
//menuVal 0 = Heading, 1 = Alt, 2 = Bat
if(digitalRead(dnBut) == LOW && millis() - time > debounce){
        menuVal = menuVal + 1;
//        delay(wait);
        time = millis();
  if(menuVal  > 2){
    menuVal = 2;
    singleBEEP();
  }
}

if(digitalRead(upBut) == LOW && millis() - time > debounce){
        menuVal = menuVal - 1;
//        delay(wait);
        time = millis();
  if(menuVal  < 0){
     menuVal = 0;
     singleBEEP();
  }
}
27  Using Arduino / Networking, Protocols, and Devices / What could be different about the Fio/Xbee? on: March 14, 2013, 08:09:13 pm
I have working on a quadcopter telemetry system and had it running pretty good on a Uno and then moved it to a home brew 8mhz arduino, which also worked well. I posted my code and a fellow flyer tried the system with a Fio v2 and we can't get it to run properly. It seems that the serial buffer gets overrun. The first set of data comes in fine but then the values get all jumbled up after that. The communication is done by Xbees Pros set at 115200.

A brief explaination of whats happening:
Sending "s" to the quadcopter will tell it to send a stream of data. The expected return is:
Code:
0,0.02,-0.01,9.82,2.0,0,1500,1500,1500,1000,1000,2000,0,0,1000,1000,1000,1000,0,0,0,0,11.3,0\r\n

Sending "x" will stop the stream. From there I'm just sorting and displaying the data (and a few other small things).

Please let me know if there is anything special that needs to be done for this code to run with the Fio.

Thank you!
28  Using Arduino / Programming Questions / Re: What happens when you hit "send" in the serial monitor? on: January 27, 2013, 12:51:29 pm
Sorry gentlemen if I am causing confusion by referring to the serial monitor. I have confirmed that both units will talk and respond accordingly using the serial monitor. Unit A will start streaming data after the "s" is sent and unit B is indeed sending the "s". The original question linking the serial monitor to the serial arduino communication was that both units work individually through the monitor but not together without it, hence, was there something extra sent by the serial monitor that I was not replicating with the code.
29  Using Arduino / Programming Questions / Re: What happens when you hit "send" in the serial monitor? on: January 27, 2013, 12:58:23 am
The 111111 vs the 115200 is because the serial is being done over Xbee and I get errors at 115200. The other unit is also transmitting at 111111. Sorry I forgot to clear that up before.

I noticed that you only used single quotes rather than double quotes. Would that have anything to do with it? I have tried Serial.print("s"); before with no luck.
30  Using Arduino / Programming Questions / Re: 'OUTPUT' was not declared in this scope on: January 27, 2013, 12:49:17 am
I tried your code with the "attiny85 w/ arduino as ISP" and it complied fine using v22.

I wonder if you installed the Attiny files correctly.
Pages: 1 [2] 3 4 ... 17