如何提升Ebyte收发器每秒传输速率至8次?
Ebyte收发器传输速率优化问题
我购置了一款Ebyte收发器,使用对应的C语言/Arduino库开发,希望将传输速率提升至每秒8次。目前已通过调整库中的超时变量将速率提升至每秒4次,但修改库头文件中的波特率、空中数据速率等参数后,传输速率仍无法突破4次/秒。操作参考了库作者的相关Issue建议。
现有测试代码
/* This example shows how to connect to an EBYTE transceiver using an ESP32 This code for the sender ESP32 won't allow SoftwareSerial (at least I can't get that lib to work so you will just hardwire your EBYTE directly to the Serial2 port */ #include "EBYTE.h" /* WARNING: IF USING AN ESP32 DO NOT USE THE PIN NUMBERS PRINTED ON THE BOARD YOU MUST USE THE ACTUAL GPIO NUMBER */ #define PIN_RX 16 // Serial2 RX (connect this to the EBYTE Tx pin) #define PIN_TX 17 // Serial2 TX pin (connect this to the EBYTE Rx pin) #define PIN_M0 4 // D4 on the board (possibly pin 24) #define PIN_M1 22 // D2 on the board (possibly called pin 22) #define PIN_AX 21 // D15 on the board (possibly called pin 21) // i recommend putting this code in a .h file and including it // from both the receiver and sender modules struct DATA { unsigned long Count; int Bits; float Volts; float Amps; }; // these are just dummy variables, replace with your own int Chan; DATA MyData; unsigned long Last; // create the transceiver object, passing in the serial and pins EBYTE Transceiver(&Serial2, PIN_M0, PIN_M1, PIN_AX); void setup() { Serial.begin(19200); Serial.println("Starting Reader"); Serial2.begin(19200); Transceiver.init(); Transceiver.SetMode(MODE_PROGRAM); Transceiver.SetSpeed(19200); Transceiver.SetTransmitPower(OPT_TP20); Transceiver.SetUARTBaudRate(UDR_19200); Transceiver.SetAirDataRate(ADR_19200); Transceiver.SetAddressH(0); Transceiver.SetAddressL(0); Transceiver.SetChannel(13); Transceiver.SaveParameters(PERMANENT); Transceiver.Reset(); Transceiver.PrintParameters(); Transceiver.SetMode(MODE_NORMAL); Transceiver.Reset(); Serial2.flush(); } void loop() { // measure some data and save to the structure MyData.Count++; MyData.Bits = analogRead(A0); MyData.Volts = MyData.Bits * ( 5.0 / 1024.0 ); // i highly suggest you send data using structures and not // a parsed data--i've always had a hard time getting reliable data using // a parsing method Transceiver.SendStruct(&MyData, sizeof(MyData)); // note, you only really need this library to program these EBYTE units // you can call write directly on the EBYTE Serial object // Serial2.write((uint8_t*) &Data, PacketSize ); // let the user know something was sent Serial.print("Sending: "); Serial.println(MyData.Count); delay(8); }
宏定义参数疑问
尝试使用库头文件规定外的参数时,发现宏定义的二进制值与标注的波特率不匹配,例如:
// air data rates (certain types of modules) // (must be the same for transmitter and receiver) #define ADR_300 0b000 // 300 baud #define ADR_1200 0b001 // 1200 baud #define ADR_2400 0b010 // 2400 baud #define ADR_4800 0b011 // 4800 baud #define ADR_9600 0b100 // 9600 baud #define ADR_19200 0b101 // 19200 baud
0b101转换为十进制后与19200完全不相等。
内容的提问来源于stack exchange,提问作者Peace David
相关产品推荐
相关产品推荐

