Go Down

Topic: Problem with transmitting IMU/GPS/Ultrasonic data over Nrf24L01 (Read 5 times) previous topic - next topic

Cyric


The function to send an array of bytes can send the bytes from any memory location. Define a struct. Store the data in an instance of the struct. Call the function to send the data with the struct instance and the size of the struct.

That function does not want a struct? Lie to it. Tell it that the struct is really a collection of bytes, using a cast - (byte *). Use the sizeof() function to get the number of bytes to send.


this does not compile i know. just wanted to know if i am heading in the right direction
Code: [Select]

   typedef struct{
    float roll;
    float pitch;
    float yaw;
  }floatImu;
 
   floatImu inImu[2];
  inImu[0].roll  = ToDeg(roll);
  inImu[0].pitch = ToDeg(pitch);
  inImu[0].yaw   = ToDeg(yaw);
  inImu[1] = (floatImu){roll,pitch,yaw};
  outD = inImu[1];
 
  Mirf.setTADDR((byte *)"base1"); // set name of Reciever
  Mirf.send(outD); // data to send
  while(Mirf.isSending()){
  }
  delay(10);


PaulS

Quote
just wanted to know if i am heading in the right direction

You are not headed in the wrong direction.

It isn't clear why you have two instances of the struct, or what roll, pitch, and yaw are, or what outD is.

Cyric

eep! 2? my understanding of stucts must be way off then here is what i understood it to be
Code: [Select]

RPYtransmit(ToDeg(roll),ToDeg(pitch),ToDeg(yaw));

Code: [Select]

void RPYtransmit(float inRoll, float inPitch, float inYaw){ //recieve current vals for ToDeg(roll),ToDeg(pitch),ToDeg(yaw)

    typedef struct
    {
    float roll; // place for roll value here
    float pitch;// place for pitch value here
    float yaw;  // place for yaw value here
   }RPYT_type; // lable the struct

    RPYT_type imuArray[2]; // create an array to hold roll,pitch,yaw for transmission


  imuArray[0].roll  = inRoll; // give float roll in RPYT_type value from incoming function argument inRoll
  imuArray[0].pitch = inPitch;// give float pitch in RPYT_type value from incoming function argument inPitch
  imuArray[0].yaw   = inYaw;// give float yaw in RPYT_type value from incoming function argument inYaw
  imuArray[1] = (RPYT_type) {inRoll,inPitch,inYaw}; // combine inRoll,inPitch,inYaw from RPYT_type into imuArray position 2 (0 being first position in array)

  Mirf.setTADDR((byte *)"base1"); // set name of Receiver
  Mirf.send(imuArray[2]); // figure out how to access and transmit second array segment containing inRoll,inPitch,inYaw
  while(Mirf.isSending()){
  }
  delay(10);
}

PaulS

Code: [Select]
    RPYT_type imuArray[2]; // create an array to hold roll,pitch,yaw for transmission
This is creating an array of structs. The question is why? Why 2?

Each instance of the struct can hold roll, pitch, AND yaw. You do not heed three instances of the struct to hold the three values. And, you certainly don't need two instance for three values.

Cyric

ahh ok think im starting to see now

Code: [Select]

void RPYtransmit(float inRoll, float inPitch, float inYaw){ //recieve current vals for ToDeg(roll),ToDeg(pitch),ToDeg(yaw)

    typedef struct
    {
    float roll; // place roll value here
    float pitch;// place pitch value here
    float yaw;  // place yaw value here
   }RPYT_type; // lable the struct

  RPYT_type imuVal = {inRoll,inPitch,inYaw}; // give float roll in RPYT_type value from incoming function argumet inRoll
  Serial.println("");
    Serial.print(imuVal.roll);
  Serial.print(" , ");
    Serial.print(imuVal.pitch);
  Serial.print(" , ");
    Serial.print(imuVal.yaw);
  Serial.println("");
}

so how do i trick Mirf.send(); into thinking this is once piece of data?

Go Up