[問題] 新手發問-如何接收H36F信號

作者: Darkautism (達卡特森)   2020-05-10 21:52:10
Hi, 各位先進
我想要讓我的Arduino可以接收H36F的訊號,讓我可以操作我的Arduino遙控車
經過一連串的爬文和研究,發現H36F的protocol是和E010一樣的(#1)
這顆遙控器是2.4G頻段,也有不少自製tx的範例,唯獨rx的研究相對稀少
我手邊有Arduino和一個nrf24l01,但我依照預定的地址嘗試讀取資料卻沒有獲得內容
想請問我在設定上發生甚麼問題嗎?
原始碼:
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"
RF24 radio(9, 10);
#define MJX_PACKET_SIZE 16
#define MJX_RF_NUM_CHANNELS 4
#define MJX_ADDRESS_LENGTH 5
#define MJX_BIND_COUNT 150
#define MJX_PACKET_PERIOD 4000 // Timeout for callback in uSec
static const struct
{
u8 e010_txid[2];
u8 rfchan[MJX_RF_NUM_CHANNELS];
} e010_tx_rf_map[] = {{{0x4F, 0x1C}, {0x3A, 0x35, 0x4A, 0x45}},
{{0x90, 0x1C}, {0x2E, 0x36, 0x3E, 0x46}},
{{0x24, 0x36}, {0x32, 0x3E, 0x42, 0x4E}},
{{0x7A, 0x40}, {0x2E, 0x3C, 0x3E, 0x4C}},
{{0x61, 0x31}, {0x2F, 0x3B, 0x3F, 0x4B}},
{{0x5D, 0x37}, {0x33, 0x3B, 0x43, 0x4B}},
{{0xFD, 0x4F}, {0x33, 0x3B, 0x43, 0x4B}},
{{0x86, 0x3C}, {0x34, 0x3E, 0x44, 0x4E}}};
uint8_t transmitterID[4];
static u8 mjx_txid[3];
static u8 mjx_rf_chan;
static u8 mjx_rf_channels[MJX_RF_NUM_CHANNELS];
void setup(void)
{
Serial.begin(115200);
while (!Serial)
; // 由於我這台是Leonardo,要等一下Serial
delay(5000);
//const uint64_t pipe = 0x6d6a777777LL;
//const uint64_t pipe = 0x7777776a6dLL;
const uint64_t tx_pipe = 0x000C710F55LL; // 地址來源請看#2
const uint64_t rx_pipe = 0x2F7D872649LL; // 地址來源請看#2
u8 rx_tx_addr[MJX_ADDRESS_LENGTH];
memcpy(mjx_txid, e010_tx_rf_map[transmitterID[0] %
(sizeof(e010_tx_rf_map)/sizeof(e010_tx_rf_map[0]))].e010_txid, 2);
mjx_txid[2] = 0x00;
memcpy(rx_tx_addr, "\x6d\x6a\x77\x77\x77", sizeof(rx_tx_addr));
memcpy(mjx_rf_channels, "\x36\x3e\x46\x2e", sizeof(mjx_rf_channels));
printf_begin();
radio.begin();
while (!radio.isChipConnected())
delay(100);
radio.setAddressWidth(MJX_ADDRESS_LENGTH);
radio.openReadingPipe(1, rx_pipe);
radio.openWritingPipe(tx_pipe);
radio.flush_rx();
radio.flush_tx();
radio.setPayloadSize(MJX_PACKET_SIZE);
radio.setAutoAck(false);
radio.setRetries(0,0);
radio.setPALevel(RF24_PA_MAX);
radio.setDataRate(RF24_250KBPS);
radio.disableDynamicPayloads();
radio.disableCRC();
//radio.setChannel(0x4E);
radio.startListening();
radio.printDetails();
}
void loop(void)
{
byte buf[16];
if( radio.available()) {
memset(buf, 0, 16);
radio.read(buf, 16);
int sum = 0;
for (int i = 0; i < 16; i++)
{
printf("%02x", buf[i]);
sum += buf[i];
radio.stopListening();
radio.setChannel(mjx_rf_channels[mjx_rf_chan++ / 2]);
mjx_rf_chan %= 2 * sizeof(mjx_rf_channels);
radio.startListening();
}
printf("\r");
if(sum)
printf("\n");
}
}
#1 H36F可用E010的相關討論 https://reurl.cc/j7QK9M
#2 E010地址的相關原始碼 https://reurl.cc/oLVEK5
#3 使用的nrf library https://github.com/nRF24/RF24
作者: Darkautism (達卡特森)   2020-05-17 21:59:00
自己回一下, address width改短就好

Links booklink

Contact Us: admin [ a t ] ucptt.com