Want to make me some Propeller Code?
A certain person with a kitty cat as his avatar has introduced me to, what looks like, a wonderful little chip. It's an nRF24L01 wireless tranciever from Nordic. It looks like it's got great range, very fast speed(2Mbps), and very small. It looks like an easy chip to interface to the propeller, so if anyone wants to write some code for it, I'll produce a couple of chips and finished PCBs to work with, and to keep for yourself. If need be, I'll also pay to have it done.·I really want to get this thing going as I have many uses for it, but not the know-how or time to learn it.
Thanks again, Leon! [noparse]:)[/noparse]
Thanks again, Leon! [noparse]:)[/noparse]
Comments
·for 180$ or so.· Only 1W .· Go and find out what kind of power a CB radio needs for 40mi.· Its most likely 1000 times over the legal civilian·limit.· Im pretty sure it's all royalty free.
The best part about these... they have the configuration of "transparent" operation, where the modules behave as a serial line replacement.· Killer.· The serial objects in the object exchange default to XBEE's protocol. 8 bits 1 stop bit no parity?· I could be wrong, i just know that it works without modifying the object.· Simple serial is one. Just find a serial object written by chip and it will work with the XBEE modules without any software mods.
If you have government code-cracker friends like mine, theyve most certainly told you·that bluetooth is a joke with regards to security.·· Specifically, passwords are shared between points without encryption, in configuration stages.· For XBEE, 128 bits is would take quite a few weeks to crack under ideal circumstances. ·Like roadrunner circumstances. Bluegene? The algorithim is only a few years old.· Modules act like routers.· I think max baud rate 4 times faster than A 56k modem. Decent for anything short of streaming video.· 3 on board ADC channels.· IDE configuration PC application.
www.digi.com, you can get xbee modules direct.·
Not many people develop these.· Just about as new as the propeller itself (2.5 yrs or so).·
Post Edited By Moderator (Chris Savage (Parallax)) : 1/5/2009 8:00:10 PM GMT
Leon
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM
Suzuki SV1000S motorcycle
www.sparkfun.com/commerce/product_info.php?products_id=705
It looks like an SPI interface. Not my cup of tea, but it shouldn't be too hard for
someone with a little experience that direction. Good project!
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Check out: Protoboard Introduction , Propeller Cookbook 1.4 & Software Index
Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
Got an SD card connected? - PropDOS
/* ** Rx.c ** Receive test program for PIC18F4520 and nRF24L01 or nRF24L01+ ** Uses the Microchip C18 compiler ** Based on SFE code for the CC5X compiler in 24L01demo_V01.c ** ** The LED is flashed five times when data are received. ** The received data in the buffer may be checked using the ** debugger Watch window.*/ #include <p18cxxx.h> #include <spi.h> #include <timers.h> // Pragmas #pragma config OSC = INTIO67 #pragma config PWRT = ON #pragma config MCLRE = OFF #pragma config BOREN = OFF //function prototypes void init(void); void reset_RX(void); void configure_RX(void); unsigned char spi_Send_Read(unsigned char); void dly(unsigned int); // Defines #define SPI_SCK LATCbits.LATC3 // Clock pin, PORTC pin 3 #define SPI_SO LATCbits.LATC5 // Serial output pin, PORTC pin 5 #define SPI_SI PORTCbits.RC4 // Serial input pin, PORTC pin 4 #define SPI_CSN LATCbits.LATC2 // CSN output pin, PORTC pin 2 #define SPI_CE LATCbits.LATC1 // CE output pin, PORTC pin 1 #define SPI_IRQ PORTBbits.RB0 // IRQ input pin, PORTB pin 0 #define SPI_SCALE 4 // postscaling of signal #define LED LATAbits.LATA0 #define PB PORTAbits.RA1 // Macros #define nop() _asm nop _endasm void main(void) { unsigned char i; init(); configure_RX(); while(1) { if (SPI_IRQ == 0) //wait for anything { for (i = 0; i < 5; i++) //flash LED 5 times if data received { LED = 1; dly(63973); // 200 ms delay LED = 0; dly(63973); // 196 ms } dly(63973); // 196 ms reset_RX(); } } } // initialise 18F4520 void init(void) { // run internal oscillator at 8 MHz OSCCON = OSCCON | 0x70; while (OSCCONbits.IOFS == 0) ; PORTA = 0x00; ADCON1 = 0x0F; // set up PORTA to be digital I/Os TRISA = 0x02; // PORTA<7.2,0> outputs PORTA<1> input TRISCbits.TRISC3 = 0; // SDO output TRISCbits.TRISC5 = 0; // SCK output TRISCbits.TRISC2 = 0; // CSN output TRISCbits.TRISC1 = 0; // CE output TRISBbits.TRISB0 = 1; // IRQ input OpenSPI(SPI_FOSC_16, MODE_00, SMPMID); //open SPI1 OpenTimer0( TIMER_INT_OFF & T0_16BIT & T0_SOURCE_INT & T0_PS_1_256 ); } //configure nRF24L01 for receive void configure_RX(void) { unsigned char i, j; SPI_CSN = 0; SPI_CE = 0; //PRX, CRC enabled spi_Send_Read(0x20); spi_Send_Read(0x39); SPI_CSN = 1; SPI_CSN = 0; //disable auto-ack for all channels spi_Send_Read(0x21); spi_Send_Read(0x00); SPI_CSN = 1; SPI_CSN = 0; //address width = 5 bytes spi_Send_Read(0x23); spi_Send_Read(0x03); SPI_CSN = 1; SPI_CSN = 0; //data rate = 1MB spi_Send_Read(0x26); spi_Send_Read(0x07); SPI_CSN = 1; SPI_CSN = 0; //4 byte payload spi_Send_Read(0x31); spi_Send_Read(0x04); SPI_CSN = 1; SPI_CSN = 0; //set channel 2 spi_Send_Read(0x25); spi_Send_Read(0x02); SPI_CSN = 1; SPI_CSN = 0; //set address E7E7E7E7E7 spi_Send_Read(0x30); for (j = 0; j < 5; j++) spi_Send_Read(0xE7); SPI_CSN = 1; SPI_CSN = 0; //PWR_UP = 1 spi_Send_Read(0x20); spi_Send_Read(0x3B); SPI_CSN = 1; SPI_CE = 1; } void reset_RX(void) { unsigned char i, j; unsigned char buffer; //Read RX payload SPI_CSN = 0; spi_Send_Read(0x61); for (j = 0; j < 4; j++) { buffer[noparse][[/noparse]j] = spi_Send_Read(0); } SPI_CSN = 1; //Flush RX FIFO SPI_CSN = 0; spi_Send_Read(0xE2); SPI_CSN = 1; SPI_CSN = 0; //reset int spi_Send_Read(0x27); spi_Send_Read(0x40); SPI_CSN = 1; } unsigned char spi_Send_Read(unsigned char byte) { SSPBUF = byte; while(!DataRdySPI()) ; return SSPBUF; } void dly(unsigned int c) { INTCONbits.TMR0IF = 0; WriteTimer0(c); while (INTCONbits.TMR0IF == 0) ; }
/* ** Tx.c ** Transmit test program for PIC18F4520 and nRF24L01 or nRF24L01+ ** Uses the Microchip C18 compiler ** Based on SFE code for the CC5X compiler in 24L01demo_V01.c */ #include <p18cxxx.h> #include <spi.h> #include <timers.h> // Pragmas #pragma config OSC = INTIO67 #pragma config PWRT = ON //#pragma config MCLRE = OFF #pragma config BOREN = OFF //function prototypes void init(void); void transmit_data(void); void configure_transmitter(void); unsigned char spi_Send_Read(unsigned char); unsigned char spi1_send_read_byte(unsigned char byte); void dly(unsigned int); // Defines #define SPI_SCK LATCbits.LATC3 // Clock pin, PORTC pin 3 #define SPI_SO LATCbits.LATC5 // Serial output pin, PORTC pin 5 #define SPI_SI PORTCbits.RC4 // Serial input pin, PORTC pin 4 #define SPI_CSN LATCbits.LATC2 // CSN output pin, PORTC pin 2 #define SPI_CE LATCbits.LATC1 // CE output pin, PORTC pin 1 #define SPI_IRQ PORTBbits.RB0 // IRQ input pin, PORTB pin 0 #define SPI_SCALE 4 // postscaling of signal #define LED LATAbits.LATA0 #define PB PORTAbits.RA1 // Macros #define nop() _asm nop _endasm void main(void) { init(); configure_transmitter(); while (1) { transmit_data(); LED = 1; dly(63973); //200 ms delay LED = 0; dly(40000); //3.27 s delay nop(); } } void init(void) { // run internal oscillator at 8 MHz OSCCON = OSCCON | 0x70; while (OSCCONbits.IOFS == 0) ; PORTA = 0x00; ADCON1 = 0x0F; // set up PORTA to be digital I/Os TRISA = 0x02; // PORTA<7.2,0> outputs PORTA<1> input TRISCbits.TRISC3 = 0; // SDO output TRISCbits.TRISC5 = 0; // SCK output TRISCbits.TRISC2 = 0; // CSN output TRISCbits.TRISC1 = 0; // CE output TRISBbits.TRISB0 = 1; // IRQ input OpenSPI(SPI_FOSC_16, MODE_00, SMPMID); //open SPI1 OpenTimer0( TIMER_INT_OFF & T0_16BIT & T0_SOURCE_INT & T0_PS_1_256 ); } void configure_transmitter(void) { unsigned char i, j, data, cmd; SPI_CE = 0; SPI_CSN = 0; // PTX, CRC enabled, mask a couple of ints spi_Send_Read(0x20); spi_Send_Read(0x38); SPI_CSN = 1; SPI_CSN = 0; //auto retransmit off spi_Send_Read(0x24); spi_Send_Read(0x00); SPI_CSN = 1; SPI_CSN = 0; //address width = 5 spi_Send_Read(0x23); spi_Send_Read(0x03); SPI_CSN = 1; SPI_CSN = 0; //data rate = 1MB spi_Send_Read(0x26); spi_Send_Read(0x07); SPI_CSN = 1; SPI_CSN = 0; //set channel 2, this is default but we did it anyway... spi_Send_Read(0x25); spi_Send_Read(0x02); SPI_CSN = 1; //set address E7E7E7E7E7, also default... spi_Send_Read(0x30); for (j = 0; j < 5; j++) { spi_Send_Read(0xE7); } SPI_CSN = 1; SPI_CSN = 0; //disable auto-ack, RX mode //shouldn't have to do this, but it won't TX if you don't spi_Send_Read(0x21); spi_Send_Read(0x00); SPI_CSN = 1; } void transmit_data(void) { unsigned char i, data, cmd; SPI_CSN = 0; //clear previous ints spi_Send_Read(0x27); spi_Send_Read(0x7E); SPI_CSN = 1; SPI_CSN = 0; //PWR_UP = 1 spi_Send_Read(0x20); spi_Send_Read(0x3A); SPI_CSN = 1; SPI_CSN = 0; //clear TX fifo //the data sheet says that this is supposed to come up 0 after POR, but that doesn't seem to be the case spi_Send_Read(0xE1); SPI_CSN = 1; SPI_CSN = 0; //4 byte payload spi_Send_Read(0xA0); spi_Send_Read(0x34); spi_Send_Read(0x33); spi_Send_Read(0x32); spi_Send_Read(0x31); SPI_CSN = 1; //Pulse CE to start transmission SPI_CE = 1; dly(65000); //delay 69 ms SPI_CE = 0; } unsigned char spi_Send_Read(unsigned char byte) { SSPBUF = byte; while(!DataRdySPI()) ; return SSPBUF; } void dly(unsigned int c) { INTCONbits.TMR0IF = 0; WriteTimer0(c); while (INTCONbits.TMR0IF == 0) ; }
Porting it to the Propeller should be trivial. Get the SPI function working first, you should be able to write data to the Nordic chip registers and read it back.
Leon
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM
Suzuki SV1000S motorcycle
Post Edited (Leon) : 1/5/2009 4:05:35 PM GMT
As for bluetooth. SG is completely correct. Even 805.11b and g are not secure (they were not meant to be due to export regulations - can't make your world opaque to big brother, sorry). I worked on a CDMA precursor protocol (called FDMA) in the late 80s for the military (well, I actually fixed the gear that used the protocol - a telemetric data transceiver). Now, that protocol was secure. I had to check out a book under lock and key to troubleshoot that particular piece of gear. They don't even allow bluetooth devices inside secured server rooms in the military today (at least marine corps doesn't as of 2 years ago when I had a gig with the USN). You have to leave your borg device at the door if you want to check out a hard drive and enter the secure room. If you are looking to transmit sensitive data I would look at some kind of encryption algorithm. They actually make ASIC's for doing just that - you pass in a string and it passes out an encrypted blob.
Also, quick question - this line of sight only right? I don't believe these modules work other than line of sight. Make sense as most RC transmitters - which have a distance of about 3000 feet (1/2 mile) will die horrid deaths if line of sight is broken. Try walking behind a big building while flying your plane - then walk over to where the pieces are and hope you have enough CA glue to fix it all.
If you've ever seen the show Robot Wars, that will be the type of application(for now). My university is sponsoring our Robotics team and we will be designing a robot to compete with other robots. It will be fairly line of sight, since we have to be able to see the robot to control it... However, the tranciever will be located inside the robots metal body... We might be able to add an external antenna.
So, the problems we have so far are:
1. LOS issues - for good reception, you will need line of sight
2. Data interface issues - very finiky about the exact configuration of the device
3. ?
Oh, and I love that show Robot Wars. They used to play it on comedy central (still trying to figure that one out) before comedy central got so corporate. Now I think you can catch it on A&E sometimes. That and that one show - myth busters - are probably the only times that energy is radiated from the electron tube sitting in my room.
I doubt the SPI issues are too hard to work out. Leon seems to have given us a sort of template for the code, so it shouldn't be too hard.
There's still a bit of work to do to ensure that what you have here will work for prop - but I've usually found that something hard to do in pic or avr land is a no brainer in propeller land so you shouldn't have too many issues. Also, I believe there may be some SPI code in obex already, so the low level protocol details can be hidden and you can work on high level constructs and not have to worry about pulsing pins and the like.
22pF C1 0402 NPO, +/- 2%
22pF C2 0402 NPO, +/- 2%
2.2nF C3 0402 X7R, +/- 10%
4.7pF C4 0402 NPO, +/- 0.25pF
1.5pF C5 0402 NPO, +/- 0.1pF
1,0pF C6 0402 NPO, +/- 0.1pF
33nF C7 0402 X7R, +/- 10%
1nF C8 0402 X7R, +/- 10%
10nF C9 0402 X7R, +/- 10%
8,2nH L1 0402 chip inductor +/- 5%
2.7nH L2 0402 chip inductor +/- 5%
3,9nH L3 0402 chip inductor +/- 5%
22kΩ R2 0402 +/-1%
16MHz X1 +/-60ppm, CL=12pF
Probably about $2 in production quantities, including the PCB.
Leon
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM
Suzuki SV1000S motorcycle
RF isn't difficult, even at 2.4 GHz. Radio amateurs deal with it all the time. There is some good software around, like Microwave Office.
Leon
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM
Suzuki SV1000S motorcycle
Wow - $4 in parts for a wireless comm. link. Maybe after assembly $10? Pretty cheap! I sure hope this works...
By the way, someone PM'ed me saying he might be able to get some code together in his spare time. I'm going to go ahead and order a couple of these from sparkfun and send them to him, so he can start work on getting a driver going for the propeller. If anyone else is interested in getting some code done, please let me know through PM.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Prop Tools under Development or Completed (Index)
http://forums.parallax.com/showthread.php?p=753439
cruising][noparse][[/noparse]url=http://www.bluemagic.biz]cruising[noparse][[/noparse]/url][/url]
This is a [noparse][[/noparse]b]bold[noparse][[/noparse]/b] test.
Leon
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM
Suzuki SV1000S motorcycle
It could be used as a cool standalone RF terminal (VGA, Keyboard, and RF serial interface)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Prop Tools under Development or Completed (Index)
http://forums.parallax.com/showthread.php?p=753439
cruising][noparse][[/noparse]url=http://www.bluemagic.biz]cruising[noparse][[/noparse]/url][/url]
This is a [noparse][[/noparse]b]bold[noparse][[/noparse]/b] test.
I used both XBee Pro and Nordic. They both work well. However, in the end, I've dropped XBee Pro and work only with Nordic now mainly because the footprint is SO MUCH smaller and they work very reliably. I have never encountered problems with this IC, it really rocks with chip antennae, very little detuning, etc. I bought Nordic initially from SparkFun (2 ranges) but my preferred supplier/distributor is http://www.semiconductorstore.com (you can get a dev kit that includes a dongle for your PC, very practical). BTW, SparkFun as a tutorial on their experience with Rf ranges and this also applies (from my humble experience) to XBee Pro at http://www.sparkfun.com/commerce/tutorial_info.php?tutorials_id=48&page=). Nordic sells an extensive line of ICs and derived products, their documentation is stellar, and their products are widely used (mainly in Europe). Finally, Nordic is not Bluetooth. Like XBee Pro, it shares the 2.4GHz ISM public bands. I would recommend these transceivers without hesitation.
Cheers,
Alex
Yes that work without problem.
XBEE modules use DSSS (Direct Sequence Spread Spectrum), just like 802.11 networks. XBEE has its own IEEE 802.15.4 designation. This results in less chance of getting hacked by sniffers, less chance of getting jammed inadvertantly (or intentionally), less chance of interference (it also employs collision avoidance). The signal appears as white noise on an analyzer.
Nordic uses GFSK(Gaussian Frequency Shift Keying), just like basic mode FHSS of bluetooth, and is very very hackable by sniffers and a man-in-the-middle intercept of initial transfer of network keys. Code cracker buddies of mine laugh at bluetooth's vunerability, and nordic should be similar, judging on the method. This method of modulation does however provide a higher bit rate than XBEE.
Nordic does not have IEEE wireless protocol specification, a one up for XBEE. XBEE also auto-configures any networks, has either API or transparent operation, will automatically route-find and will "hop" between modules when the destination module is out of range of the source module. You can increase range of the network by simply adding more modules pathwise, and without having to re-configure pre-existing networks. It also is self-repairing.
XBEE ver. 1 can get you 100m range with just 1mW , which is the same as Nordic. XBEE ver. 2 will get you 100m with 2mW. AND XBEE PRO ver. 2 modules will get a mile with just 50mW. DIGI even makes XTEND modules that can get you 40 miles , line of sight, with only 1 watt! pretty expensive @ 179$ for the 40 mile range modules , but it leaves the option available... And you can mix and match the XBEE modules of different ranges to a network of your choosing.
XBEE modules (so ive heard) should be able to range themselves accurately to within one meter. Im NOT actually sure if this is true, ive actually just read the info, about to try some ranging now.
Nordic does have the size and bitrate advantage, tho. It has its niche. I wouldnt try to achieve "secure" or long distance networks with Nordic. I would also not use Nordic in situations where high ambient 2.4Ghz flux is encountered. XBEE is much less suceptable to interference.
I also dont like Nordic's website or datasheets very much. DIGI's data sheets are written for engineers, Nordic's are written for techs (or so it seems)
Post Edited (Sleazy - G) : 1/20/2009 4:23:42 PM GMT
It seems its already been done, for those of you who want to give the nrf2401 a try, Thank Allen Marincak
obex.parallax.com/objects/112/
Cheers,
TJ