Thanks. Found it.
We are away for the weekend, so I’ll test early next week…
Thanks. Found it.
We are away for the weekend, so I’ll test early next week…
Ransomhall is going to mail me a few of his nordic breakout boards so i will be also conducting some tests. I guess i will use that oportunity to add a few cents to the implementation so if you could also find some time we could make it better.
Ok, started testing last night.
Had to change the SPI port settings for my Hydra. The image in the datasheet of the nrf24L01 for the comms show that the data is valid on the rising edge of the clock. The code sets up the SPI port for falling edge. This seems to work fine on the USBizi based boards, but not the faster Hydra.
Code changed from:
_spiPort = new SPI(new SPI.Configuration(chipSelectPin, false, 100, 100, false,false, 2000, spi));
To
_spiPort = new SPI(new SPI.Configuration(chipSelectPin, false, 100, 100, false,true, 2000, spi));
Also, what is the minimum code to send and receive data?
On sending board(Panda) I have this:
public void Run()
{
const byte channel = 1;
_myAddress = new byte[] { 0xe7, 0xe7, 0xe7, 0xe7, 0xe7 };
// here we attatch event listener
_module.OnDataReceived += OnReceive;
_module.OnTransmitFailed += OnSendFailure;
_module.OnTransmitSuccess += OnSendSuccess;
// we nned to call Initialize() and Configure() befeore we start using the module
_module.Initialize(_spi, _chipSelectPin, _chipEnablePin, _interruptPin);
_module.Configure(_myAddress, channel);
// to start receiveing we need to call Enable(), call Disable() to stop/pause
byte[] address = _module.GetAddress(0, 5);
_module.Enable();
while (true)
{
_module.SendTo(new byte[] { 0xe7, 0xe7, 0xe7, 0xe7, 0xe7 }, new byte[] { 1, 2, 3, 4, 5, 6, 7 });
System.Threading.Thread.Sleep(1000);
}
}
On the receiver(Gadgeteer) I just have this:
GTM.Gralin.Nordic n = new GTM.Gralin.Nordic(3);
// This method is run when the mainboard is powered up or reset.
void ProgramStarted()
{
// Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
n.Api.Configure(new byte[] { 0xe7, 0xe7, 0xe7, 0xe7, 0xe7 }, 1);
byte[] address=n.Api.GetAddress(0, 5);
Debug.Print(address.ToString());
n.Api.Enable();
n.Api.OnDataReceived += new Gralin.NETMF.Nordic.NRF24L01Plus.OnDataRecievedHandler(Api_OnDataReceived);
Debug.Print("Program Started");
}
I just get send failures.
On another note, why is there a InFieldUpdate project as part of the sample?
@ Errol, one thing i see is that you are initializing both sides (sender and receiver) with the same address. You should set different addresses for both and send data from one to another using the oposite adddress. Also please see listing in previous posts in this thread regarding problem, maybe those can help you.
Regarding the rising edge i must admit it rings a bell but i was a year ago and I don’t know why this was not fixed. Does the rising edge work for USBizi as well?
The in-field update example was added for some community member that wanted to know if it possible to use Nordic module for firmware transportation. It’s described somewhere in this forum. I guess it shouldn’t be included in the main solution.
Hello guys,
I would like to start testing these Modules with my Spider… unfortunately i forgot to bring with me Eric’s Gadgeteer Modules, so now I’m stuck at using a bread board … which is no big deal…
Could someone please tell how would i connect the Nordic From Itead to the spider and hydra, i have the extender module of course… Please consider me as a newbie…
I check the codeplex but i didn’t see a schematics for a gadgeteer…
I have four modules and one with the extender range… so ideal i would be testing one to one communication and report back once i get it working, and obviously i’ll send the source project to Gralin so he can add to the Codeplex, next it would testing the mesh networking using all five nodes…within range of course. and finally conduct a one way range testing and let you know the results.
thanks guys…
here is what i have so far…
please tell me if i got it wrong?
@ Jay Jay, Yes so far so good Look at the schematics attatched to this post
http://www.tinyclr.com/forum/23/5460/#/4/msg63775
The top left is your extender and top right is your module. You already know how to connect module VCC and GND to extender pins 1 and 10.
Thanks Gralin, very helpful as always… Sorry i missed that reply, even thought I’ve read this post over and over…
i will connect the goodies and get back to you guys…
Thanks.
ok an update…
i have the extender connected, please verify the snapshot below and let me if it’s all good, next i need to plug the second module to a PANDA…
i can’t figure out where to plug the following Nordic Pins:
3 - CE
4- CSN
Where will they go on a panda…?
here is what i have so far:
Nordic >>>>>>>>>>> Panda
1 GND >>>>>>>>>>> GND
2 VCC >>>>>>>>>>> 3v3
3 CE >>>>>>>>>>> ?? i think CAN1 TD 7
4 CSN >>>>>>>>>>> ??
5 SCK >>>>>>>>>>> SCK 13
6 MOSI >>>>>>>>>> MOSI 11
7 MISO >>>>>>>>>> MISO 12
8 IRQ >>>>>>>>>>> ??
Could someone take a look at the image below and let me know if i have the extender is correctly connected and help connect the rest of the PANDA pins…
Thanks.
Jay.
@ Jay Jay, sorry i forgot to anwer your last post. Did you figure out how to connect the wires to Panda? If not let me know and i will see what you are doing wrong (right now the images are not working on forum so i don’t see how did you connect everything).
@ Errol, I have updated the repo with the rising clock edge you mentioned (thanks). Also i have tested the gadgeteer driver with ransomhalls breakout board and everything works. Hydra code looks like this:
public partial class Program
{
void ProgramStarted()
{
nordic.Configure(Encoding.UTF8.GetBytes("HYDRA"), 10);
nordic.DataReceived += data => Debug.Print("<- " + new string(Encoding.UTF8.GetChars(data)));
nordic.TransmitFailed += () => Debug.Print("Send failed");
nordic.TransmitSuccess += () => Debug.Print("Send ok");
nordic.Enable();
joystick.JoystickPressed += OnJoystickPress;
Debug.Print("Program Started");
}
private void OnJoystickPress(Joystick sender, Joystick.JoystickState state)
{
nordic.SendTo(Encoding.UTF8.GetBytes("DOMIN"), Encoding.UTF8.GetBytes("Hi Domino!"));
}
}
And Domino code looks like this:
public class Program
{
private static NRF24L01Plus _module;
public static void Main()
{
const Cpu.Pin chipSelectPin = (Cpu.Pin) FEZ_Pin.Digital.UEXT5;
const Cpu.Pin interruptPin = (Cpu.Pin) FEZ_Pin.Interrupt.UEXT10;
const Cpu.Pin chipEnablePin = (Cpu.Pin) FEZ_Pin.Digital.UEXT6;
const SPI.SPI_module spi = SPI.SPI_module.SPI2;
var address = Encoding.UTF8.GetBytes("DOMIN");
_module = new NRF24L01Plus();
_module.Initialize(spi, chipSelectPin, chipEnablePin, interruptPin);
_module.Configure(address, 10);
_module.OnDataReceived += OnReceive;
_module.OnTransmitFailed += () => Debug.Print("Send failed");
_module.OnTransmitSuccess += () => Debug.Print("Send ok");
_module.Enable();
Debug.Print("Waiting for data...");
Thread.Sleep(Timeout.Infinite);
}
private static void OnReceive(byte[] data)
{
_module.SendTo(Encoding.UTF8.GetBytes("HYDRA"), Encoding.UTF8.GetBytes("HELLO"));
}
}
Thanks.
I’m also testing again. Got a Tamiya Universal Plate yesterday to mount all my Gadgeteer stuff on. Tried to work wither everything hanging loose, but that didn’t work so well…
It’s a mess, but it’s my mess…
What is that thing on the breadboard?
It is a monocrome linear image sensor. Like used in a scanner, exept that it has an ADC built in, outputs the data is a quasi SPI format. Want to see at some point if I can make a module out of it…
Ok, update on my struggles:
Decided that my module has a dry joint in the RF section. Removed the chip. Replaced the chip. After that the chip had no comms over SPI. Removed chip, ripped a track of the PCB. Solder pasted a new PCB to assemble. Found that my wife had knocked over my parts box, letting some parts fall out of their envelopes. Now I can’t see which part is 8.2nH and which is 3.9nH. Have to order new parts. Will take 6-7 working days…
@ Gralin
Thank you for your help. i still couldn’t figure out how to connect the Panda, i checked out WIKI and it says that i will have to do some modification but it didn’t say where and what…
here is what i have so far:
i can’t figure out where to plug the following Nordic Pins to the PANDA:
3 - CE >> Where should that go on the panda…?
4- CSN >> Where should that go on the panda…?
here is what i have so far:
Nordic >>>>>>>>>>> Panda
1 GND >>>>>>>>>>> GND
2 VCC >>>>>>>>>>> 3v3
3 CE >>>>>>>>>>> ?? i think CAN1 TD 7
4 CSN >>>>>>>>>>> ??
5 SCK >>>>>>>>>>> SCK 13
6 MOSI >>>>>>>>>> MOSI 11
7 MISO >>>>>>>>>> MISO 12
8 IRQ >>>>>>>>>>> ??
So in my Panda i’m missing 3,4,8.
also would you please confirm that the extender is connected correctly ? thanks
please take a look at the snap shot below:
@ Jay Jay
Good so far. The pins you are missing can be connected wherever you like (GPIO). Take a look at the Initialize method signature:
public void Initialize(SPI.SPI_module spi, Cpu.Pin chipSelectPin, Cpu.Pin chipEnablePin, Cpu.Pin interruptPin)
First argument specifies which SPI pins you are using (MISO, MOSI, SCK). Three other arguments are the pins you are missing.
Edit: “wherever” is not quite true, because the interrupt pin needs to support interrupts
ok finally got the panda wired, here is how:
1 GND >>>>>>>>>>> GND
2 VCC >>>>>>>>>>> 3v3
3 CE >>>>>>>>>>> SDA 2
4 CSN >>>>>>>>>>> SCL 3
5 SCK >>>>>>>>>>> SCK 13
6 MOSI >>>>>>>>>> MOSI 11
7 MISO >>>>>>>>>> MISO 12
8 IRQ >>>>>>>>>>> UEXT 10
i had to solder 8 IRQ to UEXT 10 because i couldn’t find any GPIO broken out…
Now to the code…
here is the updated image.
Successssssss at last …
i will clean up the solution and post it here for all others to try…
my setup consists of:
Next i will test the range of the standard Nordic module and the extra long range i have from ITEADSTUDIO… i’ll let you know my findings.
thank you Gralin and everyone else for your help, and for making this a reality.
Jay.
OK some range results.
From regular module to another inside the house (Cement Walls) the range was limited maybe about 10m …
From one Long range to a regular module, the range improved but not by much… obviously to have a better range one would need both sides to use the long range…unfortunately i only have one long range module Grrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr…
I’m gonna order another one… and it’ll be a long month before i get it… dang…
here is the code:
For the Panda… see above picture for wiring:
Note: don’t forget to add a reference to GTM.Gralin.Nordic Dll
....using Gralin.NETMF.Nordic;
public class Program
{
private static NRF24L01Plus _module;
public static OutputPort led = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.LED, false);
public static void Main()
{
const Cpu.Pin chipSelectPin = (Cpu.Pin)FEZ_Pin.Digital.Di3;
const Cpu.Pin interruptPin = (Cpu.Pin)FEZ_Pin.Interrupt.UEXT10;
const Cpu.Pin chipEnablePin = (Cpu.Pin)FEZ_Pin.Digital.Di2;
const SPI.SPI_module spi = SPI.SPI_module.SPI1;
var address = Encoding.UTF8.GetBytes("PANDA");
_module = new NRF24L01Plus();
_module.Initialize(spi, chipSelectPin, chipEnablePin, interruptPin);
_module.Configure(address, 10);
_module.OnDataReceived += OnReceive;
_module.OnTransmitFailed += () => Debug.Print("Send failed");
_module.OnTransmitSuccess += () => Debug.Print("Send ok");
_module.Enable();
// example of reading your own address
var myAddress = _module.GetAddress(AddressSlot.Zero, 5);
Debug.Print("I am " + new string(Encoding.UTF8.GetChars(myAddress)));
Debug.Print("Waiting for data...");
_module.SendTo(Encoding.UTF8.GetBytes("SPIDE"), Encoding.UTF8.GetBytes("HELLO Spider"));
Thread.Sleep(Timeout.Infinite);
}
private static void OnReceive(byte[] data)
{
try
{
Debug.Print("<- " + new string(Encoding.UTF8.GetChars(data)));
Thread.Sleep(500);
_module.SendTo(Encoding.UTF8.GetBytes("SPIDE"), Encoding.UTF8.GetBytes("Hello Spider |" + (!led.Read()).ToString()));
}
catch (Exception)
{
}
led.Write(!led.Read());
}
}
and for the Spider (See picture above for wiring the Extender Module). as far as the designer goes, i only have the button and the DPClient Power added and that’s it…
NOTE: DO NOT add the extender in the Designer…
don’t forget to add a reference to GTM.Gralin.Nordic Dll
...using Gralin.NETMF.Nordic;
public partial class Program
{
GTM.Gralin.Nordic nordic = new GTM.Gralin.Nordic(6);//Extender Module Plugged into Socket 6
void ProgramStarted()
{
nordic.Configure(Encoding.UTF8.GetBytes("SPIDE"), 10);
nordic.DataReceived += new NRF24L01Plus.OnDataRecievedHandler(NordicDataReceived);
nordic.TransmitFailed += () => Debug.Print("Send failed");
nordic.TransmitSuccess += () => Debug.Print("Send ok");
nordic.Enable();
button.ButtonPressed += ButtonButtonPressed;
// example of reading your own address
var myAddress = nordic.Api.GetAddress(AddressSlot.Zero, 5);
Debug.Print("I am " + new string(Encoding.UTF8.GetChars(myAddress)));
Debug.Print("Program Started");
}
void NordicDataReceived(byte[] data)
{
try
{
//Panda sends a string like this: "Hello Spider |true" where true/false represents the state of the LED on the Panda
string result = new string(Encoding.UTF8.GetChars(data));
//split the results to get the Panda LED state.
string[] test = result.Split('|');
if (test.Length > 1)
{
//let turn the Spider Debug LED on or Off, based on what the LED of the Panda is set to.
Mainboard.SetDebugLED(test[1].ToUpper().Equals("TRUE"));
}
Debug.Print("<- " + result);
Thread.Sleep(500);
nordic.SendTo(Encoding.UTF8.GetBytes("PANDA"), Encoding.UTF8.GetBytes("Hi PANDA!"));
}
catch (Exception)
{
}
}
void ButtonButtonPressed(Button sender, Button.ButtonState state)
{
try
{
nordic.SendTo(Encoding.UTF8.GetBytes("PANDA"), Encoding.UTF8.GetBytes("Hi PANDA!"));
}
catch (Exception)
{
}
}
}
compile and and load on both boards… press the button on the spider if the Mainboard LED isn’t blinking.
Cheers,
Jay.
Hi Gralin,
is there a way to change the data rate using the API… in order to use the long range (1KM) module i will need to set the data rate to 250Kpbs… and i didn’t see an API for that, i see it in the source code but not trough the API.
thanks…
@ Jay Jay
You can set this option with the Execute() command. I think it should be like this:
var regValue = Execute(Commands.R_REGISTER, Registers.RF_SETUP, new byte[1])[1];
regValue |= 1 << Bits.RF_DR_LOW;
Execute(Commands.W_REGISTER, Registers.RF_SETUP, new[] {regValue});
I don’t like the syntax of this method but it will work. What you need to do is set the Bits.RF_DR_LOW bit to 1 in the register Registers.RF_SETUP. In this snippet i read the register and write it with the bit set.