How does scan_channels Crazyradio work?

Firmware/software/electronics
Post Reply
aliher1911
Beginner
Posts: 5
Joined: Mon Sep 29, 2014 11:34 am

How does scan_channels Crazyradio work?

Post by aliher1911 »

Hi,

I'm trying to reuse Crazyradio class to work with some generic nRF24L01+ receiver connected to Arduino.
Curious how does scan work? Is it sending any packets for the fixed address on all channels and expecting them to back as an ACK?
To make it work, does the receiver need to send straight back the packet it just received?

Regards
chad
Expert
Posts: 555
Joined: Sun Sep 28, 2014 12:54 am
Location: New York, USA
Contact:

Re: How does scan_channels Crazyradio work?

Post by chad »

I'm curious... Does this wiki page answer your question adequately...?

http://wiki.bitcraze.se/projects:crazyr ... s_scanning
Crazyflier - my CF journal...
4x Crazyflie Nano (1.0) 10-DOF + NeoPixel Ring mod.
3x Crazyflie 2.0 + Qi Charger and LED Decks.
Raspberry Pi Ground Control.
Mac OS X Dev Environment.
Walkera Devo7e, ESky ET6I, PS3 and iOS Controllers.
aliher1911
Beginner
Posts: 5
Joined: Mon Sep 29, 2014 11:34 am

Re: How does scan_channels Crazyradio work?

Post by aliher1911 »

I've read that page and trying to understand what I need to do on receiver side to be scannable. Is the payload there solely because we can't initiate transmission without data? But then why isn't it hardcoded with some default value.
I have hw that receives data from python script, but scan doesn't pick it up. So I'm trying to identify the source of a problem.
aliher1911
Beginner
Posts: 5
Joined: Mon Sep 29, 2014 11:34 am

Re: How does scan_channels Crazyradio work?

Post by aliher1911 »

Ok, I figured out what was missing.
I had to do:

Code: Select all

r = drivers.crazyradio.Crazyradio()
# set up  address, rate and retry count before scanning
r.set_address((0x1, 0x1, 0x1, 0x01, 0x1))
r.set_data_rate(1)
r.set_arc(3)
# find active receivers
print r.scan_channels(0, 125, [0x61])
Problem was that I need to set up radio before doing scan, which looks obvious in hindsight. And it doesn't matter if I return any payload in ack or not from the receiving side.
I will assume that we can pass a payload to scan so that payload could be chosen that will not trigger any harmful actions in receiver.
druegg92
Beginner
Posts: 1
Joined: Mon Sep 29, 2014 12:29 pm

Re: How does scan_channels Crazyradio work?

Post by druegg92 »

Hello aliher1911,

I Recently started almost the same project. I want to control a RC-Plane with an Arduino and one of these compact NRF24L+ Chips with zigzag-antenna.

My questions to you are:

Which library are you using (there are many different) on the Arduino side to drive the NRF24L+?

Could you provide me the Code of your project for making it easier for me to get started with my project?

Do you only use this one phyton-script, which can be found in the lib-folder of the Crazyradio-project, to innitiate the communication and send/receive Data with the arduino?

Best Regards from Germany,

David
aliher1911
Beginner
Posts: 5
Joined: Mon Sep 29, 2014 11:34 am

Re: How does scan_channels Crazyradio work?

Post by aliher1911 »

Hi David,

For what I'm trying to do crazyradio driver from lib in crazyradio. But I'm not doing anything realtime, I'm just collecting temperature readings form multiple sensors on beer fermenter. ;)

I'm on the early stage at the moment and I tried Mirf and RF24 libraries for Arduino. I started with Mirf first, but it looks like it doesn't work in ShockBurst mode so I'll have to switch from transmit to receive and back all the time to maintain bidirectional communication. Moreover I think default firmware on Crazyradio only works in ShockBurst so I'm not sure it will work at all. So I tried RF24 and it seem to work fine.

Here's a little example that I used with python script to test it:

Code: Select all

#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"

// Those are 2 configurable pins (beside fixed SPI ones) to which you connect radio module
RF24 radio(8,7);

// this is a 5 byte address of Arduino
const uint64_t pipe = 0x0101010101LL;

void setup() {
  Serial.begin(57600);
  
  Serial.println("Initializing radio.");
  radio.begin();
  radio.setChannel(0);
  radio.setDataRate(RF24_250KBPS);
  radio.setPALevel(RF24_PA_MAX);
  radio.setPayloadSize(1);
  // to enable 2-way communication on ACKs
  radio.enableAckPayload();
  radio.openReadingPipe(1, pipe);
  // first ack goes back without payload
  radio.startListening();
  Serial.println("Working as PRX without ACK payload.");
}

void loop() {
  if (radio.available()) {
    byte value;
    bool done = false;
    while(!done) {
      done = radio.read(&value, sizeof(byte));
    }
    Serial.println(value, HEX);
    // we return ping payload on the next ping using ACK
    radio.writeAckPayload(1, &value, sizeof(byte));
  }
}
Payload size is hardcoded to 1 byte, I think support for dynamic payload size is not functional in Arduino lib, at least that's what comments in the code say. :)
But you can work with fixed size packets. And you'll have to constantly ping your plane to receive your telemetry data.
aliher1911
Beginner
Posts: 5
Joined: Mon Sep 29, 2014 11:34 am

Re: How does scan_channels Crazyradio work?

Post by aliher1911 »

One more note, if you are going to use RF24 be careful with available() method. It actually resets availability flag so if you call it twice, second time it would be false.
humblehacker
Member
Posts: 34
Joined: Thu May 16, 2013 7:42 pm

Re: How does scan_channels Crazyradio work?

Post by humblehacker »

I'd be very interested in how this setup works as well. Initially, I was looking into the potential for using the Crazyradio to control another UAV with a generic nRF24L01. Unfortunately my Crazyradio seems to have disappeared from my workbench though I still have plenty of generic nRF transceivers... So now I'm wondering if I can do the opposite of my first idea by controlling the CF with a generic nRF tranceiver attached to an Arduino. There's certainly plenty of documentation online about using an Arduino as a standalone controller, but I only just need it to connect to my pc-client for now.
whoenig
Expert
Posts: 395
Joined: Mon Oct 27, 2014 2:55 am

Re: How does scan_channels Crazyradio work?

Post by whoenig »

That should be possible if you reimplement the protocol on the arduino. Most people connect the arduinos with uart (serial port), or uart over usb (using a uart to usb bridge from FTDI).
humblehacker
Member
Posts: 34
Joined: Thu May 16, 2013 7:42 pm

Re: How does scan_channels Crazyradio work?

Post by humblehacker »

whoenig wrote:That should be possible if you reimplement the protocol on the arduino.
Is there a particular sketch that you can upload to the Arduino like you would do with any generic nRF24L01? Or do you have to get down and dirty with AT Commands and all that jazz :?
I have an FTDI-USB adapter called the "uARTsBee" http://www.seeedstudio.com/depot/UartSBee-V4-p-688.html that I use to program things like XBees, but I wouldnt know where to start with a DIY Crazyradio...
Post Reply