0

Below is a reference to a logical level bi-directional converter (aka level shifter) I purchased on Ebay. I've soldered the 12 pins (6 for each piece) to the level shifter so that it fits on my bread board.

http://www.ebay.com/itm/121868205078?_trksid=p2057872.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

This may sound trivial, but I'd like to troubleshoot the level shifter with communication both ways (Rx and Tx) to make sure it's working properly. I've got a constant 4.85v (5V) going to the HV pin, and a constant regulated 3.24V (3.3V) going to the LV pin, along with ground to both GND pins. Right now, I'm using pin0 (Rx) and pin1 (Tx) on the Arduino Mega 2560.

void setup() {
  Serial.begin(9600);
}

void loop() {
  delay(1000);
  Serial.println("Test");
}  

How can I test this level shifter without any fancy components? How could I write a program to toggle an LED both on LV1 and HV1 pins, by modifying the program above? Please note, that even though the Arduino runs on 5V, I am not using the Arduino as my HV power source.

EDIT (per comment 3 by @Paul):

Test:

  • Burn blank sketch into Arduino
  • Connect 5V (Arduino 5V) to HV pin
  • Connect GND (Arduino GND) to GND pin on same side as HV pin
  • Connect 3.3V to LV pin
  • Connect GND (from 3.3V power source) to GND pin on same side as LV pin
  • Connect Arduino Tx pin to channel 1 (HV1)
  • Connect Arduino Rx pin to channel 2 (HV2)
  • Short channel 1 to channel 2 with jumper wire

When all of this is connected, and I open the Serial Monitor on Arduino IDE, anything I type will echo back exactly what I typed. And when I disconnect one of these jumpers, it doesn't echo back. So it seems to work.

  • 1
    Try to perform a "loop-back test" simply send a character over the Tx line through the converter (and back through the converter) into the Rx line. And check if you receive back what you send. – Paul May 2 '16 at 10:08
  • 1
    an 0 Ohm resistor ;) Basically anything that is conductive, a wire preferably. The bits will then travel from output Tx -> HV1 (high) -> shifter LV1 (to low) -> wire -> shifter LV2 (to high) ->HV2 -> input Rx if that succeeds, you can safely assume it's working for UART and that it's bi-directional. – Paul May 2 '16 at 14:25
  • 1
    A 0 Ohm's resistor is a resistor that has "no resistance". Which is basically a (short) wire. Check this "tutorial" (instructables.com/id/Loopback-Test-For-Arduino-Uno/?ALLSTEPS) – Paul May 2 '16 at 14:33
  • 1
    I'm sorry, UART or USART is the "low level hardware" behind the hardware serial port (Rx and Tx pins). So yes, we're on the same line (: – Paul May 2 '16 at 15:47
  • 1
    if the signal goes from Tx to HV1 to LV1 to jumper to LV2 to HV2 to rx, you can safely assume that the component works. You might want to check the voltages, if they really are around 5V and around 3.3V. But yes, you've tested/proven that this component will work for serial communication. – Paul May 31 '16 at 9:59
2

You don't need to write any program.

First, note that this is (or at least purports to be) an I2C level shifter. This means that it does not actively pull up anything; it only actively pulls down. You are supposed to provide pull-ups somewhere in your circuit.

To test it, pull up HV1 and LV1 with 10K resistors to HV and LV respectively; measure the voltage on both sides to verify you are pulling to ~5V and ~3.3V respectively.

Ground HV1, check that LV1 is low.

Ground LV1, check that HV1 is low.

Ta-dah!

  • The pull-ups are already on the board, as far as I can see. Though, I'm not entirely sure if you can use an I2C level shifter for UART. – Gerben May 2 '16 at 8:25
  • @Gerben the resistors, are used for the (bi-directional) voltage conversion. I've got a similiar board (sparkfun.com/products/12009) which works for uart, logic and spi (haven't tried I2C but it should be fine). – Paul May 2 '16 at 10:12
  • @JayEye - When you say "pull up HV1 and LV1 with 10K resisters" do I put a 10K ohm resister between the HV1 pin and some something else, and another 10K ohm resister between the LV1 pin and something else? Do I need a "something else" or am I just measuring the voltage drop where the "something else" is on the low voltage side and high voltage side of channel 1? – MacGyver May 2 '16 at 13:36
  • 1
    at the risk of angering the moderators, I'll point to actual products: adafruit.com/products/1875 for general-puprose shifting, and adafruit.com/products/757 for I2C level shifting. Read the documentation they provide, they'll explain everything you need to know. I am not affiliated with Adafruit; I just find them convenient, as we are both in NYC and even the cheapest shipping results in two-day delivery!! – JayEye May 2 '16 at 19:52
  • 1
    No, "pull up" means that it's connected through a resistor to "postive" so that, if no device is driving it low, it will be defaulted to postive. You might want to check some tutorials on it. But, it's not required for communication with Rx/Tx lines. – Paul May 31 '16 at 10:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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