-
Notifications
You must be signed in to change notification settings - Fork 1k
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
SoftSPI #24
Comments
Definitely possible. If you have an ethernet module and an RF24 chip, do you have any use for the UART? On 328s etc, the UART can operate in master SPI mode, giving you a second SPI BUS and I'm sure there is another way to do the same with hardware driven SPI on arm devices. Any of that feasable, or would you require the software solution? |
UART=Serial? |
It is a built-in feature of the UART, the only limitation being that it cannot operate in slave mode. I just pushed a library I made to run RF24 chips this way. I haven't used it in a while, and can't remember much for details atm, but assume it would still work. Pin 4 (XCK) is the sck pin, and cs/ce are optional. On MEGA, the xck pin requires soldering onto or connecting to an unused pin on the chip if I remember, but it can be done the same way, or driven manually. |
Great! Funny that you just happened to have this around ;) |
I think you just need to replace the reference to Spi.h with this lib name in the config file and the sketch. It should be miso (master IN) would be rx and mosi (master out) would be tx. Think that's it. If you think it might work with these pins being used etc. it should be easy to include in a branch for testing. |
👍 FYI: This is the first usecase: http://forum.mysensors.org/topic/446/scene-controller-preview/2 |
In your sketch: Pin Differences:
Download RF24/w SPI_UART from Updates Branch I just put it in as a user define - edit RF24_config.h and comment *Edit to add: Side note - I did some testing/play with UART vs SPI, and the UART actually performed smoother at very high rates when compared to the SPI hardware. |
Uses the SPI_UART library at https://github.com/TMRh20/Sketches
Forgot to sync the commit... should be good now. |
Hope I can try later tonight. |
- Added softSPI support for https://github.com/greiman/DigitalIO library - Updated SPI_UART code to allow use at the same time as the SPI library
FYI, since the UART idea may not work, I added support for the softspi lib from https://github.com/greiman/DigitalIO. I also updated the SPI_UART library to allow its use along with the SPI library, since I realized it would not work at the same time as the ethernet SPI, so it would need to be re-installed to work with these changes. I haven't had a chance to fully test it all. |
DigitalIO would be great and add full flexibility without modifying the hardware. So if you would consider it I'd be very grateful.. Was banging my head last night with all this. I still cannot understand why the Display/touch/SD shield won't work together with the NRF-module. It should if everyone followed the specification I guess. |
I don't understand that myself, since the SPI spec is pretty simple. Unless the Arduino is being used as a slave device for the touchscreen, but I don't think that is likely. The changes are included for digitalIO, just reinstall and edit the Out of curiosity, what library does it use, and what kind of screen is it? |
Great! Travelling this weekend so I cannot hack anything :( I'm using this screen: With the UTFT/Touch libraries: |
Well, from the looks of the shield, the only thing connected to SPI is the SD card, which is using the standard SPI pins on the Mega. The TFT library has no SD functionality, so I assume you are using either the standard SD lib or SDFat? Both of these libraries do work well with the RF24 lib last I checked, so should work in theory if you have it all hooked up correct. (using different cs/ce pins, but the same miso,mosi, sck pins) If not, I would assume a hardware issue. I can't really see it being software related, but anything is possible. Not sure what you are using for a power supply, but would assume the SD + Screen uses quite a bit, so it could be the standard nrf24l01 power issues, which could be ruled out using a 3.3v battery to power it etc. |
Tried moving CS/CE yesterday. RF24 works fine using the new pins until I add the shield. Are there any pins on ATMega I should avoid. Used 9/10. I'm not currently using the SD card reader and nothing getting initialized in the sketch. Could it help to add SD library and initialize it? Isn't the touch-function using SPI? |
I can't remember off-hand if you need the SD card initialized, but it seems like a good possibility. I don't find any reference to SPI or SD functions anywhere in the touch or tft libs, and there is a schematic here that shows the connections of the shield. Its totally driven by digital I/O as far as I can tell. |
- Revert SPI to default lib by default. Configure via RF24_config.h #24 - Corrected CRC status reporting per https://github.com/evorios by checking AA register
Fix compile errors when trying to use any of the three libraries together - should allow softspi and uartspi to play nicely with the std SPI library now
Ok, so I've had a chance to look more at these issues, n here's what I got: To test it out:
Note: Pins are listed as follows and can be modified in the RF24_config.h file w5100 ethernet module
|
Great, Will try this when I'm back home. Thanks for helping out with this issue! |
Yiha! The display/rf24 works together with SoftSPI! Thanks! |
Hahaha, after all that... softspi. I think the issues have been otherwise addressed as far as they can be, so closing the issue. Feel free to re-open or add comments if you have further info or issues. The changes have been merged into the master branch. |
Not sure if this is still open... |
@chriskelman It sounds like something is wrong. See here for current info on using softspi. |
Much appreciated. I will have one last attempt to make this work! I Have spent a week so far trying to get anything to run on SPI - if I have an SD (+- ethernet) card installed. |
@chriskelman Have you tried running all the devices on the same bus and just using CS/SS to toggle the slave you're talking to, just as SPI was intended to work. SoftSPI in my opinion should only be used if one of the SPI slaves tends to lock or mess up the bus. |
Yes, that is what I was expecting/hoping to be able to do. I have managed to run an ethernet card (W5100) + its inbuilt SD card on the SPI bus. However, if I install the ether shield or just the micro SD card module, I can get nothing else to operate on this bus. My application requires multiple Arduino sensor modules (with local 'mission critical' data storage on an SD card) plus an RF mesh link to a Pi web server, so the nRF24 seems an obvious choice. So far, everything is working well - until I include the SD card... Any suggestions on how to use the hardware SPI bus for SD + nRF24 would be gratefully accepted, but it seems from my experience (and reading what others have said) that the SD card device hogs the SPI bus. So that is why I started investigating the S-SPI software - so far no success but I will try installing the updated files suggested by TMRh20. I have been using a generic SD module similar to Thanks for your interest! From: Avamander [email protected] @chriskelmanhttps://github.com/chriskelman Have you tried running all the devices on the same bus and just using CS/SS to toggle the slave you're talking to, just as SPI was intended to work. SoftSPI in my opinion should only be used if one of the SPI slaves tends to lock or mess up the bus. Reply to this email directly or view it on GitHubhttps://github.com//issues/24#issuecomment-196018188. |
@chriskelman: I figured out, this is due to the SN74LVC125A level shifter, which is used on the catalex-boards. It is capable of allowing multiple devices on one bus, but the manufacturer decided to solder the neccessary pins direct to ground. And now it blocks the bus. I see 2 ways to work around: I tried the second method, but until now (and I tried a long time) it doesn't work. I really don't know why ... but if you're able to get it running, please post here how you've done it. Kind regards! |
OK, thanks for the encouragement. It seems there is a conflict with other header files as I now get errors for re-defining variables such as: Any suggestions? |
The errors indicate conflict between the digitalIO/softspi library and the This one seems kind of ugly. Some pf the w5100 and some other devices hog Unfortunately the obvious softspi conflicts with SD lib. The sdfat lib at github.com/greiman supports its own softspi, and may work Rf24 also supports using the serial port as separate spi bus per the docs., All in all it seems like a bunch of ugly conflicts, but there are Sent from my iPod On 2016-03-15, at 7:25 PM, chriskelman [email protected] wrote: OK, thanks for the encouragement. It seems there is a conflict with other header files as I now get errors Any suggestions? — |
I trialled SdFat.h - it does provide an alternative SPI pin-set for the SD card which seems to work well, however - it has conflicts with the RF24 libraries. |
You can always just modify the SD library's conflicting function's name. |
You mean - in effect just exclude it from the 'include' list? |
Rf24 should be compatible with sdfat. Im sure ive tested it with rf audio Sent from my iPod On 2016-03-16, at 3:23 AM, chriskelman [email protected] wrote: You mean - in effect just exclude it from the 'include' list? — |
@chriskelman No, I meant you modify the SD card or whatever library created the redeclaration errors and make sure they use unique names. |
You were correct TMRH20 - I had forgotten to re-comment soft SPI in RF24... thus creating obvious conflicts.
|
Hey chriskelman! Correct me if I'm wrong. You're using the catalex sd module on soft spi and the rf24 on the standard spi? If so, would you please send me your pinout (which pin of the catalex goes to which pin on the arduino). Best regards! |
I am working with a Mega so pins for standard SPI are as normal. The S_SPI pins are user-configurable as I understand - but I set them to: nRF24 module pins: Best of luck! |
Thanks a lot, this helps so much ! |
hey I am working on a project with rf24 sharing SPI pins with touch screen shield (Adafruit 1947). Since Adafruit use all the SPI pins on UNO (9-13 are all used). I tried to use SOFT-SPI for RF24. All I did is follow above-mentioned instruction by TMRh20:
Note: Pins are listed as follows and can be modified in the RF24_config.h file |
Change the softspi pins to match the rf24 5,6,7 instead of 13,12,11 |
oh my god! It works finally. I have been struggling with this for 5 or 6 months. I cannot believe this will work with both devices on one UNO. Thank you so so very much! |
It works!I use it on UNO and NANO an it works fine with SPI_UART and SOFT_SPI. But if we use the RF24 library with MEGA 2560, it doesn't work properly (with normal SPI). There are many error and SOFT_SPI and SPI_UART dosn't work. Thank you for your help tmrh20. |
How if I use nRF24 to be a network with RF24Network.h library? Are they works? |
I thnik it will work but I don't try it...
2017-04-27 11:10 GMT+03:00 demascr <[email protected]>:
… How if I use nRF24 to be a network with RF24Network.h library? Are they
works?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#24 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AXUvBlm7KTBIMvDsx0qRa_yimxspxJhdks5r0E1kgaJpZM4Cp5WY>
.
|
Hi there Will be using three rf modules but only one with soft spi configured. Do I have to make seperate libraries with soft spi enabled? |
Hi!
I think it's nt possible to use three nrf24l01 with different SPI protocol.
2017-06-05 9:16 GMT+03:00 scallas <[email protected]>:
… Hi there
Just want to know if its possible to configure the Soft SPi from within
arduino sketch(IDE)?
Will be using three rf modules but only one with soft spi configured. Do I
have to make seperate libraries with soft spi enabled?
Cheers
S
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#24 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AXUvBkwFNMvbdFreGssZpk33VBR-CUOWks5sA51bgaJpZM4Cp5WY>
.
|
Its possible. At the moment I must either have two different libraries or change the rf25_config.h to use softspi or not. |
Hello, I have been trying to get my UNO to work with the USB Host Shield by Circuitsathome to read in information from a USB joystick and send the data wirelessly with the nrf24l01+ to another UNO with another nrf24l01+ and display the info via the serial monitor. I can use the nrf24l01+ modules and the USB host shield successfully as separate projects, but if I try to put them on the same SPI bus (with different CS pins), they do not work. I have tried the Soft SPI method described above but the transmitter does not transmit. I have seen this guy do it successfully with an xbox controller but he did not explain how: https://www.youtube.com/watch?v=tjH-t8bMipI Any help would be greatly appreciated. Below is the code I used (I am just trying to get the modules to work by sending Hello World with the USB host shield attached). On the transmitter (on top of the USB host shield and using soft SPI) the pins are set to SCK: 6, MOSI: 4, MISO: 5, CSN: 3, CE: 2. On the receiver (using regular SPI) the pins are SCK: 13, MISO: 12, MOSI: 11, CSN: 3, CE: 2. Transmitter: `#include <DigitalIO.h> USB Usb; const byte address[6] = "00001"; int joyX = 512; // min: 0 | max: 1023 | center: 512 RF24 radio(2, 3); void setup()
} void loop()
} void JoystickEvents::OnGamePadChanged(const GamePadEventData *evt) ` `#include <SPI.h> RF24 radio(2,3); const byte address[6] = "00001"; void setup(){ void loop(){ |
I'm looking for the same video code, to make a similar project, but I can not make the two work. USB shield and NRF24 :( |
I'm having serious problems combining RF24 with w5100 ethernet module (which hogs SPI interface) and a touch screen I've been working on. Would it be possible to add support for soft SPI in your fork?
Found this PR to maniacbug..
https://github.com/maniacbug/RF24/pull/34/files
A little explaination:
http://shanes.net/how-to-use-an-nrf24l01-rf24-with-an-arduino-ethernet-shield/
The text was updated successfully, but these errors were encountered: