Code for wireless transceiver nRF2401A ? (edit: or nRF24L01)

General discussion on mikroPascal for dsPIC30/33 and PIC24.
Author
Message
OT
Posts: 581
Joined: 19 May 2005 05:08
Location: Fairbanks, Alaska

Code for wireless transceiver nRF2401A ? (edit: or nRF24L01)

#1 Post by OT » 31 Oct 2007 06:05

I got tempted to order a couple of these wireless transceivers to try out:
http://www.sparkfun.com/commerce/produc ... cts_id=152

I am aware of Anton's PIC unit for the nrF2401,
http://www.mikroe.com/forum/viewtopic.php?t=12096
however there are some assembly statements there that do not easily translate for someone not familiar with assembly...

So would anyone have any dsPIC code for nRF2401A/nrF2401 they would be willing to share before I start with Anton's code and data sheets?
Also dsPIC code for the nRF24L01 could be interesting. I am initially looking to receive/transmit one channel at a time only. The ShockBurst™ mode looks quite interesting to save power though...

The immediate problems I see with modification of Anton's unit is the variable

Code: Select all

FSR
which seems to be a mPascal variable but not a mPascal dsPIC variable, and the inline assembly pieces:

Code: Select all

  FSR := PortAddress;
   asm
      BSF FSR,7
    end;
  ClearBit(INDF,___DATA);       // Output
and

Code: Select all

  FSR := PortAddress;
   asm
       BSF FSR,7
   end;
   SetBit(INDF,___DATA);
and

Code: Select all

  FSR := PortAddress;
  ClearBit(INDF,___CE);         // Output
  ClearBit(INDF,___CS);         // Output
  ClearBit(INDF,___CLK1);       // Output
  ClearBit(INDF,___DATA);       // Output
    asm
        BSF   FSR,7
    end;
   // Set up TRIS register
   ClearBit(INDF,___CE);
I assume differences between SPI on the dsPIC and PIC may also need some modifications.

I will probably be testing on dsPC30F4013, and then move over to a dsPIC30F2011 target or another small 18-pin version for the transmitter/logger part.
Last edited by OT on 01 Nov 2007 07:23, edited 1 time in total.

OT
Posts: 581
Joined: 19 May 2005 05:08
Location: Fairbanks, Alaska

Might be going for nRF24L01

#2 Post by OT » 01 Nov 2007 07:21

No-one interested in wireless?

Anyway, after checking around, I became aware that the nRF2401A does not have an SPI interface, so I might return the breakout board for one with the newer nRF24L01 that has one, although that board is slightly larger. Should have done my homework before ordering...

I found some tutorials here:
http://www.diyembedded.com/

anton
Posts: 807
Joined: 23 Sep 2004 09:16
Location: South-Africa
Contact:

#3 Post by anton » 01 Nov 2007 21:08

Hi OT,

The nRF2401 does work with SPI. I only used bit bang mode. The assembly is only to access the port indirectly and you don't need to use the INDF and FSR registers. You can hardcode the nRF2401 to a specific port.

I would really recommend these modules. They work very well.

Anton
Another proud user of LV 24-33A Development System and mikroPascal PRO for dsPIC :)
PortA not working? Add CMCON := 7; PortD not working? Add ADCON1 := 6;
To paste code on the forum, please use the [b] Code [/b] button !! ;)

OT
Posts: 581
Joined: 19 May 2005 05:08
Location: Fairbanks, Alaska

#4 Post by OT » 02 Nov 2007 07:08

Thanks for the explanation anton. It seems they are both very nice chips. I am still wiggling on which of these to get.

Some members on the Sparkfun forum seems to be very enthusiastic about the new chip, it seems clear that while the 2401(A) can be written to as with SPI, one cannot do things like reading registers (post by breannan, the author of the tutorial page):
http://forum.sparkfun.com/viewtopic.php ... irf++umirf
Posted: Wed Mar 07, 2007 8:12 am Post subject:
--------------------------------------------------------------------------------
Just my two cents, but the nRF24L01 chip (used in the MiRF-v2 module from SparkFun) is superior in just about every way to the nRF2401 chip that is in the MiRF and the uMiRF modules. For starters, the 24L01 has a true SPI interface and allows you to read registers instead of just writing them (which makes debugging a million times easier). It also has built-in functionality for acknowledgements and some other cool features.
Also some features like automatic resend seems very useful.

Did you make your own board for the 2401 chip?

anton
Posts: 807
Joined: 23 Sep 2004 09:16
Location: South-Africa
Contact:

#5 Post by anton » 02 Nov 2007 09:22

Hi OT,
Did you make your own board for the 2401 chip?
No, I also used these modules from Sparkfun.
http://www.sparkfun.com/commerce/produc ... cts_id=151

Anton
Another proud user of LV 24-33A Development System and mikroPascal PRO for dsPIC :)
PortA not working? Add CMCON := 7; PortD not working? Add ADCON1 := 6;
To paste code on the forum, please use the [b] Code [/b] button !! ;)

OT
Posts: 581
Joined: 19 May 2005 05:08
Location: Fairbanks, Alaska

#6 Post by OT » 02 Nov 2007 10:27

Yes, those are the ones that tested out with a really excellent range on the "how far does it go" page. http://www.sparkfun.com/commerce/present.php?p=HowFar
Too big for the data transmitter part of my possible project though...

jpc
Posts: 1986
Joined: 22 Apr 2005 17:40
Location: France 87

#7 Post by jpc » 02 Nov 2007 10:52

half of the size is the antenna , you will not easily build it any smaller i think. I have used these on p16/p18 and P30 , excellent performance . Outdoor tests have confirmed the range.

piort
Posts: 1379
Joined: 28 Dec 2005 16:42
Location: Laval,Québec,Canada,Earth... :-)
Contact:

#8 Post by piort » 02 Nov 2007 20:42

hi,

when i work on wireless project, i use http://www.maxstream.net/products/xbee/ ... zigbee.php
Those work good and are easy to configure and they are a bit cheaper )
You can use them as wireless rs-232 or in network (Zigbee protocol)...
Work good with P18 and P30... Will make a new network project with P24 or P33 in the next few month...if i can find the time lolol

OT
Posts: 581
Joined: 19 May 2005 05:08
Location: Fairbanks, Alaska

#9 Post by OT » 03 Nov 2007 03:54

jpc wrote:half of the size is the antenna , you will not easily build it any smaller i think.
:D The version I am looking at does not need any external antenna:

Image

The uMIRF from Sparkfun that arrived today to the lower right; the ceramic chip antenna is on the bottom right of the board.

To the left is shown the data logger from Onset Computer that we have used for recording body temperature of animals in the field up to now. It has to be dipped in El-wax to seal it and and then later the El-wax removed before downloading. It would be very much more elegant with a logger with a short range wireless link for downloading. We cannot go bigger in size/weight than the Onset logger.

The slightly bigger (but acceptable) MiRF v2 with the nRF24L01 I am considering instead also has a ceramic chip antenna.

The downloading station could use a bigger external antenna with better range. I posted a request in the Sparkfun wireless forum about comparative range. It could seem that the MirFv2 with the ceramic antenna is not as well designed for it, since the same board appears to be used for external antenna connection. One of those ground pads appears to be right under the ceramic antenna:
http://www.sparkfun.com/commerce/produc ... cts_id=691

But then the newer chip might seem more attractive for a new project...

OT
Posts: 581
Joined: 19 May 2005 05:08
Location: Fairbanks, Alaska

#10 Post by OT » 03 Nov 2007 04:45

piort wrote:hi,
when i work on wireless project, i use http://www.maxstream.net/products/xbee/ ... zigbee.php
Those work good and are easy to configure and they are a bit cheaper )
...
Thanks for the link. I find there is too much overhead with zigbee and I do not need networking feature. Also power consumption is < 1/4 for the Nordic chip, the nRF24L01 consumes only 11mA in receive mode and about the same in transmit mode (the 2401A is up at 19mA in receive mode). The Sparkfun module is also <1/2 the size. When you add an antenna to the XBee, cost is probably about the same. (The MiRF v.2 for external antenna is about the same price).

piort
Posts: 1379
Joined: 28 Dec 2005 16:42
Location: Laval,Québec,Canada,Earth... :-)
Contact:

#11 Post by piort » 03 Nov 2007 12:00

hi OT,

about size and consumption; basicly is the same chip (CC2410) but xbee come with a preprogramed freescale mcu... so you have some I/O and 4 can be analogic... add the power source ( 3.3 v) and your favorite memory chip...its all what you need to have your wireless data logger )))

have fun

OT
Posts: 581
Joined: 19 May 2005 05:08
Location: Fairbanks, Alaska

#12 Post by OT » 04 Nov 2007 03:47

Now give me that or the corresponding Nordic chip with a dsPIC core with 12 bit converter, programmable from mikropascal dsPIC instead of an 8052 core and I will start listening. :D :D

jpc
Posts: 1986
Joined: 22 Apr 2005 17:40
Location: France 87

#13 Post by jpc » 11 Jan 2008 16:10

Hi OT,

did you ever bring these transceivers to life? I have used the TRW24-G modules (nRF2401) on both PIC and dsPIC , now want to switch to the nRF24L01 successor on the DCBT-24N module. If ever you have any code to share i would be interested.

OT
Posts: 581
Joined: 19 May 2005 05:08
Location: Fairbanks, Alaska

#14 Post by OT » 12 Jan 2008 05:31

Hi jpc,
Good to hear that others are interested; I have not gotten that far yet. One MiRFv2. with nRF24L01 is sitting connected in my breadboard ready to be tested. I started to wire up a smaller transmitter board, however I was trying to solve the dsPIC sleep and LP oscillator issue with it before wiring up anything more on it, and I have been too short of time lately even to post a request for a workaround for the sleep errata issue.

I did start collecting example code from different sources, mostly from the Sparkfun site and Brennans tutorials, + another one on his page, and just got started translating some of it (from C and basic), and that is where it stopped, with nothing even at the early testing stage yet.

The modules I finally got were two of the MiRF v. 2 with external antenna, they were out of stock of the smaller ones with ceramic antenna. Hope to desolder the connector and add a ceramic antenna later to one of them (boards are the same), or perhaps just buy another module with ceramic antenna when in stock. It is probably a good idea anyway to have a setup with excellent signal fidelity during the testing stage. I am not familiar with the DCBT-24N module. Who are supplying those?

A nice thing about the MiRFs v2, at least during the development stage, is that they have a voltage regulator, so that it can be connected directly to both 5V and 3.3V development boards. And of course the inputs of the nRF24L01 are 5V tolerant.

jpc
Posts: 1986
Joined: 22 Apr 2005 17:40
Location: France 87

#15 Post by jpc » 12 Jan 2008 10:48

i would not know about a supplier for the DCBT-24N but you might be interested to have a look at http://www.decibit.com/index1.html.
Anyway , we would be working on the same chip , i will start on P18 and possibly simultaneously P30 both in Pascal only as i had good results on the TRW24-G modules.

Post Reply

Return to “mikroPascal for dsPIC30/33 and PIC24 General”