Show Posts
|
|
Pages: 1 ... 4 5 [6] 7
|
|
76
|
Using Arduino / Networking, Protocols, and Devices / Re: Arduino Nrf24L01p mbed help( want Arduino to ping mbed over Nrf24's)
|
on: May 22, 2012, 02:46:04 am
|
|
i did get the Arduino and mbed to talk and exchange data now i can remote controll it with thumbsticks.
yeah way out of my simple programing range im afraid. could you point me to the shockburst and enhanced shockbust mode features in the RF24 lib would be verry interested. BTW if you want to take a stab at porting RF24 to
mbed i would help where i could ( not a lot due to my programing skills being simple yet) but i could bench test it for you if you dont have one.
|
|
|
|
|
77
|
Using Arduino / Networking, Protocols, and Devices / Re: Arduino Nrf24L01p mbed help( want Arduino to ping mbed over Nrf24's)
|
on: May 19, 2012, 04:34:50 pm
|
yeah that a bit much for this test. i just need to init the Nrf24's on both the arduino and mbed with the same settings and send a packet from the arduino to the mbed and open it. i want the thinnest code to eliminate possible errors and conflicts. getting two radios to talk on two different hardware platforms with two different code bases is more than a little challenging for me. i used the RF24 lib because it had the most custom radio inits and i use the nrf24l01 lib for mbed cos it's the only one available that i have found. what i have so far. Arduino. #include <SPI.h> #include "nRF24L01.h" #include "RF24.h" #include "printf.h"
RF24 radio(9,10); const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL }; void setup(void) { Serial.begin(57600); printf_begin(); printf("\n\rRadio Setup\n\r"); radio.begin(); radio.setDataRate(RF24_2MBPS); radio.setCRCLength(RF24_CRC_8); radio.setPayloadSize(10); radio.setChannel(101); radio.setAutoAck(true); radio.printDetails(); } void loop(void) { radio.stopListening(); radio.openWritingPipe(0x00F0F0F0F0); unsigned long time = millis(); printf("Now sending %lu...",time); bool ok = radio.write( &time,sizeof(unsigned long)); if (ok) printf("ok...\n\r"); else printf("failed.\n\r"); delay(100); }
reports back that it's "ok" when i have the other radio powerd so it seems it is getign ACk back. now for the mbed. does not seem to print to the serial. #include "mbed.h" #include "nRF24L01P.h"
Serial pc(USBTX, USBRX); // tx, rx nRF24L01P my_nrf24l01p(p5, p6, p7, p8, p9, p10); // mosi, miso, sck, csn, ce, irq
int main() { #define TRANSFER_SIZE 10
char rxData[TRANSFER_SIZE]; my_nrf24l01p.powerUp(); my_nrf24l01p.setRfFrequency (2501); my_nrf24l01p.setTransferSize(10); my_nrf24l01p.setCrcWidth(8); my_nrf24l01p.enableAutoAcknowledge(NRF24L01P_PIPE_P0); my_nrf24l01p.setRxAddress(0x00F0F0F0F0); my_nrf24l01p.setTxAddress(0xF0F0F0F0D2LL); // Display the setup of the nRF24L01+ chip pc.printf( "nRF24L01+ Frequency : %d MHz\r\n", my_nrf24l01p.getRfFrequency() ); pc.printf( "nRF24L01+ Data Rate : %d kbps\r\n", my_nrf24l01p.getAirDataRate() ); pc.printf( "nRF24L01+ TX Address : 0x%010llX\r\n", my_nrf24l01p.getTxAddress() ); pc.printf( "nRF24L01+ RX Address : 0x%010llX\r\n", my_nrf24l01p.getRxAddress() ); pc.printf( "nRF24L01+ CrC Width : %d CrC\r\n", my_nrf24l01p.getCrcWidth() ); pc.printf( "nRF24L01+ TransferSize : %d Paket Size\r\n", my_nrf24l01p.getTransferSize () ); my_nrf24l01p.setReceiveMode(); my_nrf24l01p.enable(); pc.printf( "Setup complete, Starting While loop\r\n"); while (1) { if(my_nrf24l01p.readable(NRF24L01P_PIPE_P0)){ do{ my_nrf24l01p.read( NRF24L01P_PIPE_P0, rxData, sizeof( rxData ) ); int i; for (i = 0; i > 0; i ++) { pc.printf("Vals : %d\n\r", rxData[i]); } }while(my_nrf24l01p.readable(NRF24L01P_PIPE_P0)== true ); } } }
the radio seems to be geting the packets if i turn off the mbed radio the arduino will fail on transfer so i guess im not checking the radio properly to see IF there is a packet and what to do with it after. any help would be great thanks
|
|
|
|
|
78
|
Using Arduino / Networking, Protocols, and Devices / Re: Arduino Nrf24L01p mbed help( want Arduino to ping mbed over Nrf24's)
|
on: May 18, 2012, 05:24:13 pm
|
const uint64_t pipes[1] = { 0x3336337830LL}; Does not open 1 pipe? ( i just want to send for now a ping to keep things simple) radio.begin(); radio.openWritingPipe(pipes[1]); radio.setDataRate(RF24_2MBPS); radio.setPayloadSize(8); radio.setCRCLength(RF24_CRC_8); radio.setChannel(101); radio.setAutoAck(false); radio.startListening(); // Dump the configuration of the rf unit for debugging radio.printDetails();
setup the radio with 8 byte paload better? ( just sending time now) now im only opening the 1 pipe for the ping radio.stopListening(); radio.openWritingPipe( 0x3336337830LL);
unsigned long time = millis(); printf("Now sending %lu...\n\r",time); bool ok = radio.write( &time, sizeof(unsigned long) );
now im sending a time value on the 0x3336337830LL pipe yes?
|
|
|
|
|
79
|
Using Arduino / Networking, Protocols, and Devices / Arduino Nrf24L01p mbed help( want Arduino to ping mbed over Nrf24's)
|
on: May 18, 2012, 12:46:15 pm
|
Ok so i have an Arduino uno and an mbed NXP LPC1768 and some Nrf24L01+s Now i have looked at these libs and tried to come up with a simple Ping program one for mbed and one for the arduino ****Arduino libs**** Mirf : https://github.com/aaronds/arduino-nrf24l01RF24: http://maniacbug.github.com/RF24/classRF24.html *********************** ****mbed lib**** nRF24l0p: http://mbed.org/users/Owen/libraries/nRF24L01P/llb0xs/docs/classnRF24L01P.html******************* so i have come up with 2 codes and i cant seem to get them to work could some one take a look and give me a hand. **Arduino code** #include <SPI.h> #include "nRF24L01.h" #include "RF24.h" #include "printf.h"
RF24 radio(9,10); const uint64_t pipes[1] = { 0x3336337830LL}; int val;
void setup(void) {
Serial.begin(57600); printf_begin(); printf("\n\rRadio Setup\n\r"); // Setup and configure rf radio radio.begin(); radio.openWritingPipe(pipes[1]); radio.openReadingPipe(1,pipes[0]); radio.setDataRate(RF24_2MBPS); radio.setPayloadSize(32); radio.setCRCLength(RF24_CRC_8); radio.setChannel(101); radio.setAutoAck(false); radio.startListening(); // Dump the configuration of the rf unit for debugging radio.printDetails(); }
void loop(void) { radio.stopListening(); val = 233; Serial.println(val); radio.openWritingPipe(0x3631337830LL); bool ok = radio.write( &val,32 ); if (ok) printf("ok..."); else printf("failed.\n\r"); delay(1000); }
Now mbed code #include "mbed.h" #include "nRF24L01P.h"
Serial pc(USBTX, USBRX); // tx, rx
nRF24L01P my_nrf24l01p(p5, p6, p7, p8, p9, p10); // mosi, miso, sck, csn, ce, irq
DigitalOut myled1(LED1); DigitalOut myled2(LED2);
int main() {
#define TRANSFER_SIZE 32
char txData[TRANSFER_SIZE], rxData[TRANSFER_SIZE]; int txDataCnt = 0; int rxDataCnt = 0;
my_nrf24l01p.powerUp(); my_nrf24l01p.setRfFrequency (2501); my_nrf24l01p.setTransferSize(32); my_nrf24l01p.setCrcWidth(8); my_nrf24l01p.disableAutoAcknowledge(); my_nrf24l01p.setRxAddress(0x0403020100LL); my_nrf24l01p.setTxAddress(0x3631337830LL); // Display the (default) setup of the nRF24L01+ chip pc.printf( "nRF24L01+ Frequency : %d MHz\r\n", my_nrf24l01p.getRfFrequency() ); pc.printf( "nRF24L01+ Output power : %d dBm\r\n", my_nrf24l01p.getRfOutputPower() ); pc.printf( "nRF24L01+ Data Rate : %d kbps\r\n", my_nrf24l01p.getAirDataRate() ); pc.printf( "nRF24L01+ TX Address : 0x%010llX\r\n", my_nrf24l01p.getTxAddress() ); pc.printf( "nRF24L01+ RX Address : 0x%010llX\r\n", my_nrf24l01p.getRxAddress() ); pc.printf( "nRF24L01+ CrC Width : %d CrC\r\n", my_nrf24l01p.getCrcWidth() ); pc.printf( "nRF24L01+ TransferSize : %d Paket Size\r\n", my_nrf24l01p.getTransferSize () );
my_nrf24l01p.setReceiveMode(); my_nrf24l01p.enable(); pc.printf( "Setup complete, Starting while loop\r\n"); while (1) { // // If we've received anything in the nRF24L01+... if ( my_nrf24l01p.readable(NRF24L01P_PIPE_P0) ) { pc.printf( "Got readable"); /// ...read the data into the receive buffer rxDataCnt = my_nrf24l01p.read( NRF24L01P_PIPE_P0, rxData, sizeof( rxData ) ); pc.printf( "Read into rxData"); // Display the receive buffer contents via the host serial link for ( int i = 0; rxDataCnt > 0; rxDataCnt--, i++ ) { pc.printf( "For loop to output rxData"); pc.printf( "Recieved this"); pc.putc( rxData[i] ); }
} } }
|
|
|
|
|
84
|
Using Arduino / Networking, Protocols, and Devices / Re: Help with code to run NRF24L01 without using SPI pins.
|
on: October 15, 2011, 10:56:23 am
|
yes i baught it. and the socket in the one next to the BT/Xbee socket the 8 pin socket. at the bottom of the page it has a pdf with the pinouts etc.. i still dont know why they did not link it to the SPI and the L298 to the PWM/IO pins LOL but i have it now so i figured i will have to try.. ( I can drive the board externaly with wires to the headers on top of the shild but i wanted to take a stab at learing how to use it as a shild). Pic with the NRF24L01 attached. 
|
|
|
|
|
86
|
Using Arduino / Networking, Protocols, and Devices / Re: Need help transmitting 2x thumbstick data
|
on: October 09, 2011, 03:24:34 pm
|
Looks like it's all finished. here is the code for both if anyone wants Reciever #include <Servo.h> #include <Mirf.h> #include <MirfHardwareSpiDriver.h> #include <MirfSpiDriver.h> #include <nRF24L01.h> #include <SPI.h> //**************Setup # servos to use********* Servo myservo0; Servo myservo1; // Servo myservo#; //**************End Servo Setup*************** //***** set vars for each pots/sensor reading from transmitter int val0; // servo 1 int val1; // servo 2 int oldVal0; int IN1 = 2; //L298 int IN2 = 4; //L298 int ENA = 5; //L298 Enable A //********************************************* void setup(){ Serial.begin(9600); pinMode(ENA, OUTPUT); pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT); //************ Pin set for servos************* myservo0.attach(3); // myservo1.attach(6); // End Pinset for servos //**************Start Transiever (NRF24L01) config************** Mirf.csnPin = 9; Mirf.cePin = 8; Mirf.spi = &MirfHardwareSpi; Mirf.init(); Mirf.setRADDR((byte *)"reci1"); Mirf.payload = 4 * sizeof(byte); Mirf.config(); //**************End Transiever (NRF24L01) config************** Serial.println("Beginning..."); // print somthing once to Serial to know your up } void loop(){ //+++++++++++Start data collection from transciever+++++++++ byte data[Mirf.payload]; if(Mirf.dataReady()){ do{ Mirf.getData(data); //*********** Start array to collect pot/sensor data ********* val0 = data[0]; //Pot 1 on Transmitter val1 = data[1]; //Pot 2 on Transmitter //*********** End array to collect pot/sensor data ********* //**********Start Loop to print array to Serial Monitor //int i; // for (i = 0; i < 2; i = i + 1) { // Serial.println(data[i], DEC); //} //**********End Loop to print array to Serial Monitor delay(10); }while(!Mirf.rxFifoEmpty()); } //++++++++ END data collection from transciever++++++++++++ //++++++++ Do Stuff here++++++++++++
int delta0 = abs(val0 - oldVal0); if(delta0 > 2){ myservo0.write(val0); } if(val1 < 110){ motorFoward(); } else if(val1 > 135){ motorReverse(); } else{ motorStop(); } } // end of program //*********************** int motorFoward() { val1 = map(val1, 110, 0, 100, 254); analogWrite(ENA, val1); digitalWrite(IN1, LOW); digitalWrite(IN2, HIGH); }
int motorReverse() { val1 = map(val1, 135, 254, 0, 254); analogWrite(ENA, val1); digitalWrite(IN1, HIGH); digitalWrite(IN2, LOW); }
int motorStop(){ analogWrite(ENA, LOW); digitalWrite(IN1, LOW); digitalWrite(IN2, LOW); }
Transmitter: #include <Mirf.h> #include <MirfHardwareSpiDriver.h> #include <MirfSpiDriver.h> #include <nRF24L01.h> #include <SPI.h>
//**************Start Pin Setup*************** int pot1pinX = 0; // analog pin used for the pot 1 int pot2pinY = 1; // analog pin used for the pot 2 //**************End Pin Setup***************
//**************Global vars Setup*************** int val0; int val1; //**************END vars Setup*************** void setup(){ Serial.begin(9600); // start serial communications //**************Start Transiever (NRF24L01) config************** Mirf.csnPin = 9; Mirf.cePin = 8; Mirf.spi = &MirfHardwareSpi; Mirf.init(); Mirf.setRADDR((byte *)"clie1"); Mirf.payload = 4 * sizeof(byte); Mirf.config(); //**************End Transiever (NRF24L01) config**************
Serial.println("Beginning ... "); // Print some stuff to serial } void loop(){ val0 = analogRead(pot1pinX); // set val0 to read analog pin 0 val1 = analogRead(pot2pinY);// set val1 to read analog pin 1 //**************convert pot to PWM values************** val0 = map(val0, 0, 1023, 0, 179); val1 = map(val1, 0, 1023, 0, 254); //Serial.println(val1); //**************convert pot to PWM values************** //**************put values in array?************** byte vals[2]; vals[0] =val0; vals[1] =val1; //**************finish puting values in array?************** //**************Start Transmit package************** Mirf.setTADDR((byte *)"reci1"); // set name of Reciever Mirf.send(vals); // data to send //**************put values in array?************** //**************Start For loop to print array to local serial************** // int i; // for (i = 0; i < 2; i = i + 1) // { // Serial.println(vals[i], DEC); // } //**************End For loop to print array to local serial************** while(Mirf.isSending()){ } delay(10); }
|
|
|
|
|
89
|
Using Arduino / Networking, Protocols, and Devices / Re: Need help transmitting 2x thumbstick data
|
on: October 09, 2011, 08:22:42 am
|
in motorForword: val1 = map(val1, 120, 0, 0, 254); in motorReverse: val1 = map(val1, 124, 254, 0, 254); seems to fix the vals from 0-255 each way. now i just need to refresh on exit? of the function so when i let go fo the sticks it picks up on center "0" so they dont get stuck. if i move it say 3/4 up and let go it stays about that speed but if i move it back to center it will slow to stop (mostly). i need a bigger deadzone in the center to.
|
|
|
|
|
90
|
Using Arduino / Networking, Protocols, and Devices / Re: Need help transmitting 2x thumbstick data
|
on: October 09, 2011, 07:42:38 am
|
|
I think i have an idea what is going on let's see if i can explain it LOL. as it is now when the sticks are centerd they read 89ish for the left/right stick and F/R 124ish. So if there at thos ranges nothing happens then as i move the sticks the values change and trip the IF's and does what there programed to so and take the current value and apply it. several probs are this.. FWD on stick one starts at like 120 and starts to drop to 0 , REV starts at like 124 and increase to 255. I think just remaping 120-0 and 124-255 and using the new map will fix that. the second thing is if i quickly let go of the sticks they pop to center and the values dont change so they stay in the last VAL state i need to re read the new state i think in the subs.
|
|
|
|
|