Show Posts
Pages: 1 2 [3] 4 5 ... 9
31  Using Arduino / Programming Questions / Re: sending structs, need clarification on some things. on: February 07, 2013, 09:41:18 am
You need to not attempt to read()  the data until it is all there.   Or else read the data which you have
and then wait for the rest to arrive.

got any examples on how would i go about doing that?
32  Using Arduino / Programming Questions / Re: sending structs, need clarification on some things. on: February 06, 2013, 12:11:41 pm
had never used .setRetries it before and saw it in a demo and looked it up on github had not saw the last statement about 15 max.

i did setup the radios like the pingpair example and they failed  %100 of the time. it's a packet size issue so i had to change the packets and if i dont have * sizeof(byte) in there it fails. so as it stands only thing that works for the following sketchs is. SetpayloadSize(20 * sizeof(byte)); {anything above 20 works so 21 22 23 24}

TX
Code:
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"

RF24 radio(48,49);
void setup(){
  Serial.begin(57600);
  //**************Start Transiever (NRF24L01) config**************
  printf_begin();
  printf("\n\rRadio Setup\n\r");
  radio.begin();
  radio.setRetries(15,15);
  radio.setDataRate(RF24_2MBPS);
  radio.setCRCLength(RF24_CRC_16);
  radio.setPayloadSize(24 * sizeof(byte));
  radio.setChannel(100);
  radio.setAutoAck(true);
  radio.openReadingPipe(1,0xF0F0F0F0E1LL);
  radio.openWritingPipe(0xF0F0F0F0D2LL);
  radio.stopListening();
  radio.printDetails();
  //**************End Transiever (NRF24L01) config**************

struct StructBuff_t {
  float imuRoll;
  float imuPitch;
  float imuYaw;
  unsigned int AP;
}
StructBuff;
//**************************************************
//************* Start Main Loop section ************
//**************************************************

void loop()
{
float roll = random(-150,150);
float pitch = random(-150,150);
float yaw = random(0,360);
unsigned int ap = random(0,75);

  StuffStructBuff(roll,pitch,yaw,ap); 
   TransStruct();
 }
//**************************************************
//************* END Main Loop section***************
//**************************************************
//-+-+-+>>>> Start Struct Transmit section<<<<<<-+-+-+
void TransStruct(){
  bool ok = radio.write((byte *) &StructBuff, sizeof(StructBuff));
  if (ok)
    printbuffs();
    //printf("ok...\n\r");
  else 
    printf("failed.\n\r");
   delay(10);
}
//-+-+-+>>>> END Struct Transmit section<<<<<<-+-+-+

void printbuffs(){
  Serial.print(StructBuff.imuRoll);
  Serial.print(",");
  Serial.print(StructBuff.imuPitch);
  Serial.print(",");
  Serial.print(StructBuff.imuYaw);
  Serial.print(",");
  Serial.print(StructBuff.AP);
  Serial.println();
 }
void StuffStructBuff(float inRoll, float inPitch, float inYaw, unsigned int inAP){//**Working**
  StructBuff.imuRoll = inRoll; 
  StructBuff.imuPitch = inPitch; 
  StructBuff.imuYaw = inYaw; 
  StructBuff.AP = inAP; 
}
RX
Code:
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"
RF24 radio(8,9);
void setup(){
  Serial.begin(57600);
  //**************Start Transiever (NRF24L01) config**************
  printf_begin();
  printf("\n\rRadio Setup\n\r");
  radio.begin();
  radio.setRetries(15,15);
  radio.setDataRate(RF24_2MBPS);
  radio.setCRCLength(RF24_CRC_16);
  radio.setPayloadSize(24 * sizeof(byte));
  radio.setChannel(100);
  radio.setAutoAck(true);
  radio.openReadingPipe(1,0xF0F0F0F0D2LL);
  radio.openWritingPipe(0xF0F0F0F0E1LL);
  radio.startListening();
  radio.printDetails();
  //**************End Transiever (NRF24L01) config**************

struct StructBuff_t {
  float imuRoll;
  float imuPitch;
  float imuYaw;
  unsigned int AP;
}
StructBuff;
//**************************************************
//************* Start Main Loop section ************
//**************************************************
void loop()
{
    RecStruct();
    }

//**************************************************
//************* END Main Loop section***************
//**************************************************
//-+-+-+>>>> Start Struct Transmit section<<<<<<-+-+-+
void RecStruct(){
  if ( radio.available() )
    {
  bool ok = radio.read((byte *)&StructBuff, sizeof(StructBuff));
  if (ok)
    printbuffs();
  //    printf("ok...\n\r");
  else 
    printf("failed.\n\r");
    }
  delay(10);

}

//-+-+-+>>>> END Struct Transmit section<<<<<<-+-+-+
void printbuffs(){
  Serial.print(StructBuff.imuRoll);
  Serial.print(",");
  Serial.print(StructBuff.imuPitch);
  Serial.print(",");
  Serial.print(StructBuff.imuYaw);
  Serial.print(",");
  Serial.print(StructBuff.AP);
  Serial.println();

}

TX output
Code:
-127.00,-41.00,0.00,65
failed.
-23.00,79.00,160.00,37
failed.
failed.
-34.00,85.00,97.00,26
failed.
-71.00,-101.00,99.00,21
failed.
35.00,95.00,308.00,16
failed.
58.00,94.00,28.00,65
failed.
-128.00,16.00,189.00,74
failed.

RX
Code:
-127.00,-41.00,0.00,65
-23.00,79.00,160.00,37
-34.00,85.00,97.00,26
-71.00,-101.00,99.00,21
35.00,95.00,308.00,16
58.00,94.00,28.00,65
-128.00,16.00,189.00,74

so size of the struct is 20 it seems. as for the timing man it's slow bout 1.5 updates per sec was hoping for 3 or 4 per sec.
33  Using Arduino / Programming Questions / Re: sending structs, need clarification on some things. on: February 05, 2013, 05:45:15 pm
I checked my hardware after i was just gunna say yeah i can use the examples and noticed the connector i made was not holding tight to the NRF so i swaped out for a new one on my UNO and ran ping and worked fine. changing delay(10) will fail transmit/rec both even (11) or no delay. the 5,1000 was from trying to achieve less fail by telling it not to retransmit more than 5 times and wait 1 sec in between tries.


TX (uno)
Code:
Now sending 87...ok...Got response 87, round-trip delay: 24
Now sending 1112...ok...Got response 1112, round-trip delay: 22
Now sending 2135...ok...Got response 2135, round-trip delay: 21
Now sending 3158...ok...Got response 3158, round-trip delay: 21
Now sending 4179...ok...Got response 4179, round-trip delay: 23
Now sending 5202...ok...Got response 5202, round-trip delay: 23

RX(Mega2560)
Code:
Got payload 87...Sent response.
Got payload 1112...Sent response.
Got payload 2135...Sent response.
Got payload 3158...Sent response.
Got payload 4179...Sent response.
Got payload 5202...Sent response.
so i got excited and tried the old code.
but when i got back to the previous TX/RX code it is choppy send/rec and some fails. also if i chage it to even 11ms much less 1000 it is %100 fail agin.
Full code as it sits.
Code:
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"

RF24 radio(48,49);
void setup(){
  Serial.begin(57600);
  //**************Start Transiever (NRF24L01) config**************
  printf_begin();
  printf("\n\rRadio Setup\n\r");
  radio.begin();
  radio.setDataRate(RF24_2MBPS);
 // radio.setCRCLength(RF24_CRC_16);
//  radio.setPayloadSize(14 * sizeof(byte));
//  radio.setChannel(80);
  radio.setAutoAck(true);
//  radio.setRetries(15,15);
  radio.openReadingPipe(1,0xF0F0F0F0E1LL);
  radio.openWritingPipe(0xF0F0F0F0D2LL);
  radio.stopListening();
  radio.printDetails();

  //**************End Transiever (NRF24L01) config**************

struct imuBuff_t{
  float imuRoll;
  float imuPitch;
  float imuYaw;
}
imuBuff;
//**************************************************
//************* Start Main Loop section ************
//**************************************************
void loop()
{
  ////////////////////////////// 
  imuBuff.imuRoll  = 31.99;   //
  imuBuff.imuPitch = -150.82; //Temp Values
  imuBuff.imuYaw   = 3.60;    //
  //////////////////////////////
  TransStruct();
}
//**************************************************
//************* END Main Loop section***************
//**************************************************
//-+-+-+>>>> Start Struct Transmit section<<<<<<-+-+-+
void TransStruct(){

  bool ok = radio.write((byte *) &imuBuff, sizeof(imuBuff));
  if (ok)
    printbuffs();
  else 
    printf("failed.\n\r");
  delay(10);
}
//-+-+-+>>>> END Struct Transmit section<<<<<<-+-+-+
void printbuffs(){
  Serial.print(imuBuff.imuRoll);
  Serial.print(",");
  Serial.print(imuBuff.imuPitch);
  Serial.print(",");
  Serial.print(imuBuff.imuYaw);
  Serial.println();
}

RX
Code:
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"
RF24 radio(8,9);
void setup(){
  Serial.begin(57600);
  //**************Start Transiever (NRF24L01) config**************
  printf_begin();
  printf("\n\rRadio Setup\n\r");
  radio.begin();
  radio.setDataRate(RF24_2MBPS);
//  radio.setCRCLength(RF24_CRC_16);
 // radio.setPayloadSize(14 * sizeof(byte));
 // radio.setChannel(80);
  radio.setAutoAck(true);
  //radio.setRetries(15,15);
  radio.openReadingPipe(1,0xF0F0F0F0D2LL);
  radio.openWritingPipe(0xF0F0F0F0E1LL);
  radio.startListening();
  radio.printDetails();
  //**************End Transiever (NRF24L01) config**************

struct IMU_t{
  float imuRoll;
  float imuPitch;
  float imuYaw;
}
imuBuff;
//**************************************************
//************* Start Main Loop section ************
//**************************************************
void loop()
{
  imuBuff.imuRoll = 0;
  imuBuff.imuPitch = 0;
  imuBuff.imuYaw= 0;
  RecStruct();
}
//**************************************************
//************* END Main Loop section***************
//**************************************************
//-+-+-+>>>> Start Struct Transmit section<<<<<<-+-+-+
void RecStruct(){
  if ( radio.available() )
  {
    bool ok = radio.read((byte *)&imuBuff, sizeof(imuBuff));
    if (ok)
      printbuffs();
    else 
      printf("failed.\n\r");
     }
  delay(10);

}
//-+-+-+>>>> END Struct Transmit section<<<<<<-+-+-+
void printbuffs(){
  Serial.print(imuBuff.imuRoll);
  Serial.print(",");
  Serial.print(imuBuff.imuPitch);
  Serial.print(",");
  Serial.print(imuBuff.imuYaw);
  Serial.println();
}



TX
Code:
failed.
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
failed.
31.99,-150.82,3.60
failed.
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
failed.
31.99,-150.82,3.60
31.99,-150.82,3.60
failed.
failed.
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
failed.
31.99,-150.82,3.60
31.99,-150.82,3.60
failed.
failed.
failed.
31.99,-150.82,3.60
RX
Code:
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
31.99,-150.82,3.60
34  Using Arduino / Programming Questions / Re: sending structs, need clarification on some things. on: February 05, 2013, 12:58:58 pm
%100 fail now

TX
Code:
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"

RF24 radio(48,49);
void setup(){
  Serial.begin(57600);
  //**************Start Transiever (NRF24L01) config**************
  printf_begin();
  printf("\n\rRadio Setup\n\r");
  radio.begin();
  radio.setDataRate(RF24_250KBPS);
//radio.setCRCLength(RF24_CRC_16);
//radio.setPayloadSize(14 * sizeof(byte));
//radio.setChannel(2);
  radio.setAutoAck(true);
  radio.setRetries(5,1000);
  radio.openReadingPipe(1,0xF0F0F0F0E1LL);
  radio.openWritingPipe(0xF0F0F0F0D2LL);
  radio.stopListening();
  radio.printDetails();

  //**************End Transiever (NRF24L01) config**************

struct imuBuff_t{
  float imuRoll;
  float imuPitch;
  float imuYaw;
}
imuBuff;
//**************************************************
//************* Start Main Loop section ************
//**************************************************
void loop()
{
  ////////////////////////////// 
  imuBuff.imuRoll  = 31.99;   //
  imuBuff.imuPitch = -150.82; //Temp Values
  imuBuff.imuYaw   = 3.60;    //
  //////////////////////////////
  TransStruct();
}
//**************************************************
//************* END Main Loop section***************
//**************************************************
//-+-+-+>>>> Start Struct Transmit section<<<<<<-+-+-+
void TransStruct(){

  bool ok = radio.write((byte *) &imuBuff, sizeof(imuBuff));
  if (ok)
    printbuffs();
  else 
    printf("failed.\n\r");
  delay(10);
}
//-+-+-+>>>> END Struct Transmit section<<<<<<-+-+-+
void printbuffs(){
  Serial.print(imuBuff.imuRoll);
  Serial.print(",");
  Serial.print(imuBuff.imuPitch);
  Serial.print(",");
  Serial.print(imuBuff.imuYaw);
  Serial.println();
}

RX
Code:
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"
RF24 radio(48,49);
void setup(){
  Serial.begin(57600);
  //**************Start Transiever (NRF24L01) config**************
  printf_begin();
  printf("\n\rRadio Setup\n\r");
  radio.begin();
  radio.setDataRate(RF24_250KBPS);
//radio.setCRCLength(RF24_CRC_16);
//radio.setPayloadSize(14 * sizeof(byte));
//radio.setChannel(2);
  radio.setAutoAck(true);
  radio.setRetries(5,1000);
  radio.openReadingPipe(1,0xF0F0F0F0D2LL);
  radio.openWritingPipe(0xF0F0F0F0E1LL);
  radio.startListening();
  radio.printDetails();
  //**************End Transiever (NRF24L01) config**************

struct IMU_t{
  float imuRoll;
  float imuPitch;
  float imuYaw;
}
imuBuff;
//**************************************************
//************* Start Main Loop section ************
//**************************************************
void loop()
{
  imuBuff.imuRoll = 0;
  imuBuff.imuPitch = 0;
  imuBuff.imuYaw= 0;
  RecStruct();
}
//**************************************************
//************* END Main Loop section***************
//**************************************************
//-+-+-+>>>> Start Struct Transmit section<<<<<<-+-+-+
void RecStruct(){
  if ( radio.available() )
  {
    bool ok = radio.read((byte *)&imuBuff, sizeof(imuBuff));
    if (ok)
      printbuffs();
    else 
      printf("failed.\n\r");
     }
  delay(10);

}
//-+-+-+>>>> END Struct Transmit section<<<<<<-+-+-+
void printbuffs(){
  Serial.print(imuBuff.imuRoll);
  Serial.print(",");
  Serial.print(imuBuff.imuPitch);
  Serial.print(",");
  Serial.print(imuBuff.imuYaw);
  Serial.println();
}


35  Using Arduino / Programming Questions / Re: sending structs, need clarification on some things. on: February 05, 2013, 12:55:50 pm
so how do i go about flushing the buffer?
Code:
imuBuff.imuRoll = 0;
imuBuff.imuPitch = 0;
imuBuff.imuYaw= 0;
smacks head on keyboard.
36  Using Arduino / Programming Questions / Re: sending structs, need clarification on some things. on: February 05, 2013, 11:22:24 am
Quote
You don't clear the receiver buffer before doing the receive, so you will never know whether data you're seeing was actually received, or is garbage left behind from a previous message.

thought that i was with the flush(). but i read they were not accessible to users they were hardware calls. so how do i go about flushing the buffer?
37  Using Arduino / Programming Questions / Re: sending structs, need clarification on some things. on: February 05, 2013, 08:42:05 am
So i took out everything unneeded and setup just a float struct to transmit and added the Start/Stop listining to the setup and flush the buffers on the TX side on fails and RX side on a sucess or fail to make sure i am always geting fresh data on the RX side. I still run into a prob with it only transmitting like the first 1 or 2 or so packets and then stops if i reset RX i "might" get a packet to take. here is my code so far.

TX
Code:
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"

RF24 radio(48,49);
void setup(){
  Serial.begin(57600);
  //**************Start Transiever (NRF24L01) config**************
  printf_begin();
  printf("\n\rRadio Setup\n\r");
  radio.begin();
  radio.setDataRate(RF24_2MBPS);
  radio.setCRCLength(RF24_CRC_16);
  radio.setPayloadSize(14 * sizeof(byte));
  radio.setChannel(2);
  radio.setAutoAck(true);
  radio.openReadingPipe(1,0xF0F0F0F0E1LL);
  radio.openWritingPipe(0xF0F0F0F0D2LL);
  radio.stopListening();
  radio.printDetails();
  //**************End Transiever (NRF24L01) config**************

struct imuBuff_t{
  float imuRoll;
  float imuPitch;
  float imuYaw;
}
imuBuff;
//**************************************************
//************* Start Main Loop section ************
//**************************************************
void loop()
{
  ////////////////////////////// 
  imuBuff.imuRoll  = 31.99;   //
  imuBuff.imuPitch = -150.82; //Temp Values
  imuBuff.imuYaw   = 3.60;    //
  //////////////////////////////
  TransStruct();
}
//**************************************************
//************* END Main Loop section***************
//**************************************************
//-+-+-+>>>> Start Struct Transmit section<<<<<<-+-+-+
void TransStruct(){

  bool ok = radio.write((byte *) &imuBuff, sizeof(imuBuff));
  if (ok)
    printbuffs();
  else 
    printf("failed.\n\r");
  uint8_t flush_tx();
  delay(10);
}
//-+-+-+>>>> END Struct Transmit section<<<<<<-+-+-+
void printbuffs(){
  Serial.print(imuBuff.imuRoll);
  Serial.print(",");
  Serial.print(imuBuff.imuPitch);
  Serial.print(",");
  Serial.print(imuBuff.imuYaw);
  Serial.println();
}
RX
Code:
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"
RF24 radio(48,49);
void setup(){
  Serial.begin(57600);
  //**************Start Transiever (NRF24L01) config**************
  printf_begin();
  printf("\n\rRadio Setup\n\r");
  radio.begin();
  radio.setDataRate(RF24_2MBPS);
  radio.setCRCLength(RF24_CRC_16);
  radio.setPayloadSize(14 * sizeof(byte));
  radio.setChannel(2);
  radio.setAutoAck(true);
  radio.openReadingPipe(1,0xF0F0F0F0D2LL);
  radio.openWritingPipe(0xF0F0F0F0E1LL);
  radio.startListening();
  radio.printDetails();
  //**************End Transiever (NRF24L01) config**************

struct IMU_t{
  float imuRoll;
  float imuPitch;
  float imuYaw;
}
imuBuff;
//**************************************************
//************* Start Main Loop section ************
//**************************************************
void loop()
{
  RecStruct();
}
//**************************************************
//************* END Main Loop section***************
//**************************************************
//-+-+-+>>>> Start Struct Transmit section<<<<<<-+-+-+
void RecStruct(){
  if ( radio.available() )
  {
    bool ok = radio.read((byte *)&imuBuff, sizeof(imuBuff));
    if (ok)
      printbuffs();
    else 
      printf("failed.\n\r");
      uint8_t flush_tx(); 
}
  delay(10);

}
//-+-+-+>>>> END Struct Transmit section<<<<<<-+-+-+
void printbuffs(){
  Serial.print(imuBuff.imuRoll);
  Serial.print(",");
  Serial.print(imuBuff.imuPitch);
  Serial.print(",");
  Serial.print(imuBuff.imuYaw);
  Serial.println();
  uint8_t flush_rx();
}
Output RX side
Code:
31.99,-150.82,3.60
but just the first packet most of the time.
38  Using Arduino / Programming Questions / Re: sending structs, need clarification on some things. on: February 05, 2013, 08:19:19 am
ahh so the locking up is result of Strings? ok ill make a char array i guess and see how it goes. i love RF24s radio control so i would love  to use it.
39  Using Arduino / Programming Questions / Re: Problem with transmitting IMU/GPS/Ultrasonic data over Nrf24L01 on: February 04, 2013, 12:09:10 pm
hey PaulS how can i (if at all) clean up the code some. As in say cut everything from below #include ( keep those in) and above void Setup and put them in an external file? this code is getting so long 504 line 16k ino file lol and i just gutted any extra code out of it.
40  Using Arduino / Programming Questions / Re: sending structs, need clarification on some things. on: February 04, 2013, 10:38:06 am
i made the changes and out the radio calls for stop and listen into the setup like they had them in there examples and i flushed the buffers but when i added the radio.available() it worked. sort of. i only get MAX 4 loops and some times 1 or even 0 loops then i reset the RX and retry max 4 but most times less. here is my code also it's slow as hell when it does send a couple sets across like 2 sec or so.. Mirf on the other hand is sending it fine so i think i might just use RF24 to setup the radios and Mirf for Transmitting/Receiving.
(resetting TX side never seems to do any good)
TX
Code:
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"

RF24 radio(48,49);
void setup(){
  Serial.begin(57600);
  //**************Start Transiever (NRF24L01) config**************
  printf_begin();
  printf("\n\rRadio Setup\n\r");
  radio.begin();
  radio.setDataRate(RF24_2MBPS);
  radio.setCRCLength(RF24_CRC_16);
  radio.setPayloadSize(20 * sizeof(byte));
  radio.setChannel(2);
  radio.setAutoAck(true);
  radio.openReadingPipe(1,0xF0F0F0F0E1LL);
  radio.openWritingPipe(0xF0F0F0F0D2LL);
  radio.stopListening();
  radio.printDetails();
  //**************End Transiever (NRF24L01) config**************

struct StructBuff_t {
  String GPS; 
  float imuRoll;
  float imuPitch;
  float imuYaw;
  unsigned int AP;
}
StructBuff;
//**************************************************
//************* Start Main Loop section ************
//**************************************************

void loop()
{
float roll = random(-150,150);
float pitch = random(-150,150);
float yaw = random(0,360);
String gps = "This is my RF test";
unsigned int ap = random(0,75);

  StuffStructBuff(roll,pitch,yaw,ap,gps); 
   TransStruct();
 }
//**************************************************
//************* END Main Loop section***************
//**************************************************
//-+-+-+>>>> Start Struct Transmit section<<<<<<-+-+-+
void TransStruct(){
  bool ok = radio.write((byte *) &StructBuff, sizeof(StructBuff));
  if (ok)
    printbuffs();
    //printf("ok...\n\r");
  else 
    printf("failed.\n\r");
   uint8_t flush_tx();
  delay(10);
}
//-+-+-+>>>> END Struct Transmit section<<<<<<-+-+-+

void printbuffs(){
  Serial.print(StructBuff.imuRoll);
  Serial.print(",");
  Serial.print(StructBuff.imuPitch);
  Serial.print(",");
  Serial.print(StructBuff.imuYaw);
  Serial.print(",");
  Serial.print(StructBuff.AP);
  Serial.println();
  Serial.print(StructBuff.GPS);
  Serial.println();
  uint8_t flush_tx();
}
void StuffStructBuff(float inRoll, float inPitch, float inYaw, unsigned int inAP, String inGPS){//**Working**
  StructBuff.imuRoll = inRoll; 
  StructBuff.imuPitch = inPitch; 
  StructBuff.imuYaw = inYaw; 
  StructBuff.AP = inAP; 
  StructBuff.GPS= inGPS;   
}

RX
Code:
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"
RF24 radio(48,49);
void setup(){
  Serial.begin(57600);
  //**************Start Transiever (NRF24L01) config**************
  printf_begin();
  printf("\n\rRadio Setup\n\r");
  radio.begin();
  radio.setDataRate(RF24_2MBPS);
  radio.setCRCLength(RF24_CRC_16);
  radio.setPayloadSize(20 * sizeof(byte));
  radio.setChannel(2);
  radio.setAutoAck(true);
  radio.openReadingPipe(1,0xF0F0F0F0D2LL);
  radio.openWritingPipe(0xF0F0F0F0E1LL);
  radio.startListening();
  radio.printDetails();
  //**************End Transiever (NRF24L01) config**************

struct StructBuff_t {
  String GPS; 
  float imuRoll;
  float imuPitch;
  float imuYaw;
  unsigned int AP;
}
StructBuff;
//**************************************************
//************* Start Main Loop section ************
//**************************************************
void loop()
{
    RecStruct();
    }

//**************************************************
//************* END Main Loop section***************
//**************************************************
//-+-+-+>>>> Start Struct Transmit section<<<<<<-+-+-+
void RecStruct(){
  if ( radio.available() )
    {
  bool ok = radio.read((byte *)&StructBuff, sizeof(StructBuff));
  if (ok)
    printbuffs();
  //    printf("ok...\n\r");
  else 
    printf("failed.\n\r");
    uint8_t flush_rx();
    }
  delay(10);

}

//-+-+-+>>>> END Struct Transmit section<<<<<<-+-+-+
void printbuffs(){
  Serial.print(StructBuff.imuRoll);
  Serial.print(",");
  Serial.print(StructBuff.imuPitch);
  Serial.print(",");
  Serial.print(StructBuff.imuYaw);
  Serial.print(",");
  Serial.print(StructBuff.AP);
  Serial.println();
  Serial.print(StructBuff.GPS);
  Serial.println();
  uint8_t flush_rx();
}

OutPut on RX  Side
Code:
-143.00,-101.00,113.00,8
This is my RF test
-127.00,-41.00,0.00,65
This is my RF test
-147.00,19.00,189.00,32
This is my RF test
-34.00,85.00,97.00,26
This is my RF test
41  Using Arduino / Programming Questions / Re: sending structs, need clarification on some things. on: February 03, 2013, 03:24:52 am
i have changed the payload size and converted the struct to a regular struct with no luck. i can do it with unions and convert from floats and chars to bytes into an output array and send them i was just under the impression i could just use 1 struct and toss that across the link to the other one. anyone know if this is true or not?
42  Using Arduino / Programming Questions / Re: sending structs, need clarification on some things. on: February 02, 2013, 11:23:41 am
So i made static values and flushed the buffer and now i get this
TX
Code:
1.01,22.02,-32.99
1.01,22.02,-32.99
1.01,22.02,-32.99
1.01,22.02,-32.99
RX
Code:
-0.00,-0.00,-0.00
-0.00,-0.00,-0.00
-0.00,-0.00,-0.00

my TX code
Code:
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"

RF24 radio(48,49);
void setup(){
  Serial.begin(57600);
  //**************Start Transiever (NRF24L01) config**************
  printf_begin();
  printf("\n\rRadio Setup\n\r");
  radio.begin();
  radio.setDataRate(RF24_2MBPS);
  radio.setCRCLength(RF24_CRC_16);
  //radio.setPayloadSize(12 * sizeof(byte));
  radio.setChannel(2);
  radio.setAutoAck(true);
  radio.openReadingPipe(1,0xF0F0F0F0E1LL);
  radio.openWritingPipe(0xF0F0F0F0D2LL);
  radio.printDetails();
  //**************End Transiever (NRF24L01) config**************

typedef struct myBuff{
  float imuRoll;
  float imuPitch;
  float imuYaw;
 }myBuff;
myBuff StructBuff;
//**************************************************
//************* Start Main Loop section ************
//**************************************************
void loop()
{
  ///////////////////////////////////////////////////////// 
  StructBuff.imuRoll  = 1.01;                          //
  StructBuff.imuPitch = 22.02;                    //Temp Values
  StructBuff.imuYaw   = -32.99;                    //
                  //
  /////////////////////////////////////////////////////////

   TransStruct();
   radio.startListening();
}
//**************************************************
//************* END Main Loop section***************
//**************************************************
//-+-+-+>>>> Start Struct Transmit section<<<<<<-+-+-+
void TransStruct(){

  radio.stopListening();
  bool ok = radio.write((byte *)&StructBuff, sizeof(StructBuff));
  if (ok)
    printbuffs();
    //printf("ok...\n\r");
  else 
    printf("failed.\n\r");
    uint8_t flush_tx();
  delay(10);
}
//-+-+-+>>>> END Struct Transmit section<<<<<<-+-+-+

void printbuffs(){
  Serial.print(StructBuff.imuRoll);
  Serial.print(",");
  Serial.print(StructBuff.imuPitch);
  Serial.print(",");
  Serial.print(StructBuff.imuYaw);
  Serial.println();
  uint8_t flush_tx();
}

RX code
Code:
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"
RF24 radio(8,9);
void setup(){
  Serial.begin(57600);
  //**************Start Transiever (NRF24L01) config**************
  printf_begin();
  printf("\n\rRadio Setup\n\r");
  radio.begin();
  radio.setDataRate(RF24_2MBPS);
  radio.setCRCLength(RF24_CRC_16);
  //radio.setPayloadSize(12 * sizeof(byte));
  radio.setChannel(2);
  radio.setAutoAck(true);
  radio.openReadingPipe(1,0xF0F0F0F0D2LL);
  radio.openWritingPipe(0xF0F0F0F0E1LL);
  radio.printDetails();
  //**************End Transiever (NRF24L01) config**************

typedef struct myBuff{
  float imuRoll;
  float imuPitch;
  float imuYaw;
}
myBuff;
myBuff StructBuff;

//**************************************************
//************* Start Main Loop section ************
//**************************************************
void loop()
{
  radio.startListening();
    RecStruct();
   }

//**************************************************
//************* END Main Loop section***************
//**************************************************
//-+-+-+>>>> Start Struct Transmit section<<<<<<-+-+-+
void RecStruct(){

  radio.startListening();
  bool ok = radio.read((byte *)&StructBuff, sizeof(StructBuff));
  if (ok)
    printbuffs();
  //    printf("ok...\n\r");
  else 
    printf("failed.\n\r");
    uint8_t flush_rx();
  delay(10);

}

//-+-+-+>>>> END Struct Transmit section<<<<<<-+-+-+


void printbuffs(){
  Serial.print(StructBuff.imuRoll);
  Serial.print(",");
  Serial.print(StructBuff.imuPitch);
  Serial.print(",");
  Serial.print(StructBuff.imuYaw);
  Serial.println();
  uint8_t flush_rx();
}

43  Using Arduino / Programming Questions / Re: Problem with transmitting IMU/GPS/Ultrasonic data over Nrf24L01 on: February 02, 2013, 09:10:04 am
that makes sense thanks.
i also made a new thread because i sense this RF part of my project is going  take a few more posts and felt the struct/transmit part should be a separate issue.
still do not know why it does not want to work for me sending a struct i even eliminated all but the floats to send just to keep it simple
44  Using Arduino / Programming Questions / sending structs, need clarification on some things. on: February 02, 2013, 09:05:32 am
Hi all. I am working on a robot project and need some clarification on some things before i can get back to it.
1. was answered thanks. ( what was (byte*) doing.
2.am i sending this wrong if so how because every example i have checked out and all the searching and the help from PaulS points to this working.
i have the same structs on both side i am sending and receiving them exact same. how ever i am getting bad data on the RX side.
now i should mention the radio settings work fine all examples work with them so i know it's not hardware. also they would fail and not print there output on good send.

here is the output on the TX side
Code:
23.00,41.00,59.00
25.00,49.00,51.00
27.00,48.00,58.00
38.00,42.00,57.00
5.00,41.00,53.00
here is the output on the RX side
Code:
0.00,0.00,0.00,0
0.00,0.00,0.00,0
0.00,0.00,0.00,0
0.00,0.00,0.00,0
0.00,0.00,0.00,0
here are the sketches i am using
TX
Code:
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"

RF24 radio(48,49);
void setup(){
  Serial.begin(57600);
  //**************Start Transiever (NRF24L01) config**************
  printf_begin();
  printf("\n\rRadio Setup\n\r");
  radio.begin();
  radio.setDataRate(RF24_2MBPS);
  radio.setCRCLength(RF24_CRC_16);
  //radio.setPayloadSize(12 * sizeof(byte));
  radio.setChannel(2);
  radio.setAutoAck(true);
  radio.openReadingPipe(1,0xF0F0F0F0E1LL);
  radio.openWritingPipe(0xF0F0F0F0D2LL);
  radio.printDetails();
  //**************End Transiever (NRF24L01) config**************
}  
typedef struct myBuff{
  float imuRoll;
  float imuPitch;
  float imuYaw;
 }myBuff;
myBuff StructBuff;
//**************************************************
//************* Start Main Loop section ************
//**************************************************
void loop()
{
  /////////////////////////////////////////////////////////  
  StructBuff.imuRoll  = random(1,40);                          //
  StructBuff.imuPitch = random(41,50);                    //Temp Values
  StructBuff.imuYaw   = random(51,60);                    //
                  //
  /////////////////////////////////////////////////////////

   TransStruct();
   radio.startListening();
}
//**************************************************
//************* END Main Loop section***************
//**************************************************
//-+-+-+>>>> Start Struct Transmit section<<<<<<-+-+-+
void TransStruct(){

  radio.stopListening();
  bool ok = radio.write((byte *)&StructBuff, sizeof(StructBuff));
  if (ok)
    printbuffs();
    //printf("ok...\n\r");
  else  
    printf("failed.\n\r");
  delay(10);
}
//-+-+-+>>>> END Struct Transmit section<<<<<<-+-+-+

void printbuffs(){
  Serial.print(StructBuff.imuRoll);
  Serial.print(",");
  Serial.print(StructBuff.imuPitch);
  Serial.print(",");
  Serial.print(StructBuff.imuYaw);
  Serial.println();
}
RX
Code:
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"
RF24 radio(8,9);
void setup(){
  Serial.begin(57600);
  //**************Start Transiever (NRF24L01) config**************
  printf_begin();
  printf("\n\rRadio Setup\n\r");
  radio.begin();
  radio.setDataRate(RF24_2MBPS);
  radio.setCRCLength(RF24_CRC_16);
  //radio.setPayloadSize(12 * sizeof(byte));
  radio.setChannel(2);
  radio.setAutoAck(true);
  radio.openReadingPipe(1,0xF0F0F0F0D2LL);
  radio.openWritingPipe(0xF0F0F0F0E1LL);
  radio.printDetails();
  //**************End Transiever (NRF24L01) config**************
}  
typedef struct myBuff{
  float imuRoll;
  float imuPitch;
  float imuYaw;
 }myBuff;
myBuff StructBuff;

//**************************************************
//************* Start Main Loop section ************
//**************************************************
void loop()
{
  
   RecStruct();
}
//**************************************************
//************* END Main Loop section***************
//**************************************************
//-+-+-+>>>> Start Struct Transmit section<<<<<<-+-+-+
void RecStruct(){

  radio.startListening();
  bool ok = radio.read((byte *)&StructBuff, sizeof(StructBuff));
  if (ok)
    printbuffs();
//    printf("ok...\n\r");
  else  
    printf("failed.\n\r");
  delay(10);
 
}
//-+-+-+>>>> END Struct Transmit section<<<<<<-+-+-+


void printbuffs(){
  Serial.print(StructBuff.imuRoll);
  Serial.print(",");
  Serial.print(StructBuff.imuPitch);
  Serial.print(",");
  Serial.print(StructBuff.imuYaw);
  Serial.println();
}
45  Using Arduino / Programming Questions / Re: Problem with transmitting IMU/GPS/Ultrasonic data over Nrf24L01 on: February 02, 2013, 07:18:49 am
this is prob a silly question but what is (byte *) doing for the function readio.----?
Pages: 1 2 [3] 4 5 ... 9