-
-
Notifications
You must be signed in to change notification settings - Fork 654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add feature to have no DIO connection #34
Conversation
I had a quick glance over the code, it looks ok. However, I'm afraid that polling SPI on every loop will be too much overhead. I think that now it even polls the SPI registers up to three times in a single loop, which doesn't really add anything, once should be enough. Ideally, LMIC should keep track of what DIO pins it expects an event on, so the HAL can only poll SPI when an event is pending that cannot be read through a pin (this would help even when all pins are connected, since then there is no need to poll any pins if no event is pending. This helps because digitalRead() isn't exactly very fast either). This probably requires invasive changes to the code, so that needs more thought. Not sure if there is a good intermediate step for this, though. |
@matthijskooijman, thanks having time to look into. I agree this is not the ideal solution but for those who don't have enough GPIO pins, and on ESP8266 as soon as your using SPI, it's really limited, so 3 pins for IRQ is just too much. In this case pooling is working fine. In any case, in the code I made go into reading IRQs using SPI only once per loop (look below, i=NUM_DIO make exit the for loop) because as soon you get in, we're reading all IRQs register (as original code) and we exit without getting other IRQ until next loop (because we've just done all the job). And if one fire before we ended, it will be managed on next loop.
By the way current implementation pool input with digital read 3 times a loop (3 lines) so I think we're not so , would be interesting looking time used to read SPI IRQ register, I'll take a look on this ASAP. But for sure idea will be doing nothing until we're fired by a real IRQ line and associated code vector, but this will be more tricky to implement because depending on target it's not the same and for example a ATMega328 as just 2 reals IRQ hardware lines. |
I just changed DIO implemention on
|
@matthijskooijman
I can't test DIO on ESP8266 because the board I have have no DIO connection to GPIO pins. Do you think 47µs could impact LoraWAN stack timings, because seems to works fine on my side even on Zero ? |
I think 47us is significant and ideally it would be optimized further, but for now it seems fair enough. I am curious how much it takes on an AVR chip, and how much longer when the SPI speed is lowered to 1Mhz (as proposed on another PR). Do you have an AVR handy? If not, perhaps you could add your time-printing code to this PR in a separate commit (or even a completely different branch in your repo), then I can try running it as well. The approach of setting a flag on initializaton sounds like a sane approach to me. I haven't looked at the code yet and this will probably be a few weeks until I'll find the time, but thanks already for your work! |
Oh, and for your actual question, I think there is at least 1280us of leeway in the the timing of the RX windows (see the "Timing" section of the README), so 47us shouldn't hurt the LoRaWAN reception by itself. |
So, I've done some testing, here the results
That's interesting, as you can see the impact of DIO/NO DIO is "just" twice the time on 328p ;-) From my point of view, doing OR with 3 diodes and using only one input line is the best approach, only one pin to check on DIO loop and no need to talk with SPI if not needed, and cherry on the cake, only one GPIO used!
And now, of course attach an hardware interrupt to this DIO line and we go to 0 in loop ;-) |
Thank you for those figures ! Keep in mind that lot of atmega328 are used battery powered at 3.3V/8 MHz, so more overhead :) |
Very very cool 👯 . Getting the error FAILURE, radio.c 692 Before everything was working. I connected the SPI and SS. And used LMIC_UNUSED_PIN. I will look at it later |
@gizmocuz @zoutepopcorn |
Hi @matthijskooijman But may be I'm doing wrong, I'm not super confident with git, branch and all git command line stuff (I'm mainly doing PR and commits with Git GUI from my Windows Machine) especially when I got a repo forked that need to be synced with master remote (you one). |
@hallard, I haven't had time to look closely at your PR yet, and probably won't have time for it this week. Your understanding of git is correct, if you have another PR dependent on this one, this one's commits will be included. I haven't found any way yet to "hide" the redundant commits from such a PR. However, you could just submit it anyway, so we can at least review the code. |
@hallard @matthijskooijman This worked great on my two ESP8266's+RFM95's: one perfboard gateway running things4u's gw software while the other smaller custom board, acting as client with arduino-lmic's ABP example on TTN. So thanks @hallard, you saved my board since I did run out of GPIO's to do what I wanted to do in my project 👍 I'm a bit concerned about the node id's my gateways sees though, not sure they should be random given that I'm sending those from the very same node (pretty sure it's noone else on indoors reach on my same SF and channel): My perfboard gateway does use DIO0 and DIO1, so happy to run some benchmarks if you show me how you did that @hallard ;) EDIT: Those nodes are indeed other devices (including 3 packets from mine) :-! Seems that the gateway's HOPping mechanisms do not work so well, so fixing it to a specific SF and channel allows it to see devices, cool! Also, I would be super happy to see this merged ;) |
hi @hallard |
hi @hallard, |
Hi karlTGA thx |
The error is happening at compile time or when the program is running?
|
Hello Hallard, thx |
NSS is to tell device "I select you, you need to answer to me" and it's active LOW. It's used when you have multiple SPÏ slave on same SPI bus, you select the one you're talking to. According the datasheet pulling to low with R3 (is it soldered?) should does the trick and select always. Another option, I saw RST pin of the RFM95 is connected to RST of the Wemos, could you try to cut the RST trace going to RFM95 to see or add a small delay on startup to let RFM95 going out of reset? |
I understand and you may be right, but according to documentation "A transfer is always started by the NSS pin going low and the frame ends when NSS goes high. Perhaps this is not relevant, but in any case I get an error if the nss pin is connected to ground with a 100K Ohm resistor. Who would you possibly try to do that for you? Maybe I'm doing something wrong ... |
I've checked it again. With recommended wiring, nss pin config: LMIC_UNUSED_PIN, but error: Maybe the address is wrong? "ASSERT(v == 0x12 );" |
If this contribution is optional and users have tested it with success for 3 years, why was it not merged yet ? |
To be honest, I just haven't looked in enough detail yet. Also, I've been a bit hesitant to make changes to this Arduino-specific version (initially because there was some upstream development, later because I considered restarting from a less Arduino-specific repository, but that never got finished). In the meanwhile, it seems that the MCCI fork of this library has done a lot more development, so I suspect that that might a better starting point for developments like these... I should probably put up a notice somewhere and maybe make this official, but I wanted to have a closer look at the MCCI version first and I have not found the time for that yet... |
Hi, Is this radio_has_irq only for Arduino board? Thanks a lot. |
This repository is now deprecated, see #297 for some more background. I'm grateful for your contribution, but it will no longer be merged. I'm recommending people to use the MCCI version of LMIC instead. If this PR addresses an issue that also exists in that version, I would encourage you to resubmit your contribution there, so it might benefit other users. I'm sorry for the inconvenience... |
Software feature to remove needing DIO connections if needed in case you're restricted in GPIO available, you can avoid using any GPIO connection.
To activate this feature, you just need to declare 3 .dio to LMIC_UNUSED_PIN as follow for example to WeMos Lora Shield