3

I have an Arduino MEGA hooked up with a NRF24L01, and working nicely, talking with another Arduino Uno. It works as described, power supply to 3.3V, and SPI lines (MISO,MOSI,CLK) connected directly to the Arduino;

However, when I hook up a level converter in the end (5V to 3V, bidirectional) (making the NRF module in the middle, like in a T connection), the module stops working, and I don't know why. How does the level converter module is interfering in the connection? Is there any way I can prevent this and use it?

I intend in adding in the future, modules that talk in 3.3V SPI;

This is the level converter I'm using:

JY-MCU 5V-3V four channel convert module
(source: at-the.space)

I suspect it is because of the pullups (5 think that these 10kΩ resistors are pull-ups, but I'm a noob in that part), but I really don't know if that is the problem, as the seller advertises it as being compatible with SPI, I2C, and UART. I have successfully used these for a UART.

I have checked Slaving multiple Arduinos via SPI and tried using an external 5V supply, and a 3.3V supply, but no dice.. However, the 3V side has no connections to it; But, being bi-directional, I don't think there is a problem with this...

I found that 74HCT245D works very well for this, but I'd like to know why with the level converter from JY-MCU this won't work.

Providing the library and connections just in case (the module works without the level converter):

9
  • making the NRF module in the middle, like in a T connection - what do you mean by that? Can you post a schematic of what you have done, exactly?
    – Nick Gammon
    Feb 17, 2016 at 4:17
  • How is ground connected? Arduino, converter, module? Feb 17, 2016 at 10:21
  • @NickGammon Sorry, i have added the connection for arduino, thanks.
    – RalphFox
    Feb 17, 2016 at 13:32
  • @MikaelPatel Added the connection, please check it, thank you.
    – RalphFox
    Feb 17, 2016 at 13:33
  • 1
    You have put the NRF24 on the wrong size of the converter. Feb 17, 2016 at 14:09

2 Answers 2

1

More than probably your level shifter is not fast enough. A level shifter uses a mosfet to copy signals from one voltage level to the other, but each mosfet has a latency or, if you prefer, a rise time. Your board probably doesn't use a fast switching mosfet and so the SPI protocol (which is a quite fast one) is not copied correctly.

On top of that you actually don't need a level switcher for the nRF24 modules: the power pin must be limited to 3.3V, but the signal pins are 5V tolerant. This means you only need a 3.3V voltage source and all the remaining connections can go directly (and safely) into your Arduino board.

UPDATE: the speed concept still applies, it doesn't matter which side of the connection you are using. A mosfet has a little capacitance which slows down the signal transmission: higher the capacitance, slower the maximum data rate. The cheap chinese level shifter is not designed for high speed communication, while the Texas Instrument device is clearly designed for high speed. If you look at the SN74HCT245 datasheet you'll notice the switching speed is reported for 50pF capacitance and ranges from 8ns to 16ns: that's the time needed to build enough charge in the switching circuit. enter image description here

6
  • For other devices, you could increase the SPI clock divider to get slower SPI signals. Or voltage divider resistors (which might be faster).
    – Paul
    Apr 3, 2016 at 21:28
  • @Paul voltage divider resistors are definitely slower than the level shifter, consider a generic mosfet as a voltage divider in the order of the milliohms: an equivalent voltage divider will be very close to a short. The SPi clock divider is definitely a good advice though, even if not always applicable. Apr 3, 2016 at 21:34
  • Ah, I always consider resistors to be "instant". But that'd be my mistake (: lowering SPI clock should be applicable in almost every scenario though? But yeah, don't try to fix it in software. ...especially if it lowers your speed (:
    – Paul
    Apr 3, 2016 at 21:40
  • @RobertoLoGiacco Sorry for the late reply, i'm on another timezone it seems;As stated in the question, i am not using the level switcher on the nRF24, i was going to use the level switcher to add non 5v tolerant modules(3.3v) to the same SPI line; Sorry if i was not clear enough. I fail to see how the slow level shifting is hitting the nRF24 as the wireless module is on the 5.5v; could you explain please? I solved by using a 74HCT245D; but the question still stands, "why i am not able to use the level shifter?" Thanks for your reply.
    – RalphFox
    Apr 4, 2016 at 13:40
  • 5 minute limit to edit... by 10 seconds, damm :/ ; the question would be "why i am not able to put the level shifter on the same bus the nRF24 is?"
    – RalphFox
    Apr 4, 2016 at 13:47
0

AVR's like all digital have their limits. In this case you're dealing with source resistances that need to charge multiple gate capacitances through series resistances (wires and metal contact connections. Specifically an Absolute MAX 40mA/pin, some milliohms in your copper wire and PCB traces, and pico to nano Farad capacitances, plus depending on how High Speed the SPI is (the spec does not list an upper limit), you will be also contending with frequency limiting parasitics. At MHz frequencies, your wire and PCB traces will have higher resistances due to "skin" effect, where the electrons migrate to the surface of the wire when transferring. Depending on frequency of the wire, adding just a single gate could degredate rise/fall times enough to corrupt data, as the SPI library (whichever you choose) and the SPI peripheral within the AVR probably won't be as sophisticated as a PC based one. The AVR & the SPI library lacks sophistication in that neither has provisions to detect and compensate for extra gate capacitance on the bus line, nor could they compensate for china jumper wires which are quite small (9x40ga) wiring. There are many factors which could corrupt your SPI project that are coming into play to limit performance. You should probably do some internet research on high speed bus anatomy if you intend on pushing the SPI bus on the arduino to it's limits.

I think the gate capacitances are combining with source resistance and skin effect and your 40mA/pin is not in fact 40mA per pin but more like 10-20mA is hitting all gate capacitances when skin effect is considered (it effectively raises the resistance of the wire sufficiently to then be a factor). If connecting the JY-MCU converter AND running SPI at minimum speed corrects communication, then the extra gate capacitances are the factor you should change to higher performance versions. There's the 74AS series with gate times down to 1.7nS and fMAX up to 40MHz!

Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.