Teensy LC with I2C LCD

alexv5

Member
Hello everyone.

First off all I would to to apologige for such a long writing, but I like to explain every delail on my projects so people can understand why I did the things I did.

I have an Teensy LC that reads 4 sensors and then shows the sensors values in an I2C 20x4 LCD.

The Teensy is powered by 5V in the 5V pin, with the USB line cutted. The LCD is powered by 5V from another power regulator, but grounds are the same.

I had 10K pull-up resistors on the SDA and SCL lines trough 3.3V, everything worked fine on my breadboard.

This is for an agriculture machine and the LCD needs to be apart 6 meters from the Teensy. I only then realised that I2C has distance limitations.

With the 6 meter cable the LCD dind´t work, or random number would appear. I the replaced the 10K pull-up resistor by 1K pull-up resistors, and the systems worked, I even rolled the cable trying to create interferences but the system kept working.

Now is where thing get odd:
I have done all this prototyping with my workbench power supply, an MLINK APS3005S-3D. Once everything was validated, I installed the system in the machine and the 12V power comes from the tractor 12V plug.

For my surprise, the LCD doesn´t show the information, but the Teensy keeps running. For some reason the LCD powered up but it didn´t show information, not even in the previous setup (I suspect that the I2C adapter on the LCD is broken now)

After replacing the LCD I can only get the information if I connect the I2C lines with an 0.1m cable.

Why does it work with the workbench power suply and not with 12V from the tractor? I also tried an laptop power supply regulator that uses the same connector as the tractor, but without sucess.

I can't buy I2C extender at the moment so if this doesn't works I will have to try CAN Bus communication and add an Arduino Nano to run the LCD.

Thank you for your time.
Alex
 
If a tractor is anything like a car, it is a very NOISY electrical environment.
It is likely that large voltage spikes are interfering with the comms. It is quite likely to kill any not protected electronics.
I suspect that you did not have any spike (electrical) protection on either end of your cable.
 
Vehicle supplies are very noisy and spikey - normally you'd have filtering / clamping circuitry to tame this.
https://www.avrfreaks.net/forum/automotive-power-suppy-filtering

I2C is indeed limited range - its designed for use local to the processor PCB. 6m of cable might have 200pF or more of capacitance,
giving a time constant of 2µs with a 10k pull up resistor, (so 0.5µs with 2k2).

Try 2k2 pullups and 100kB/s for the I2C, that might be workable. Use twisted pair like CAT5 for SCL and SDA, each paired with ground on
its own pair. The other pairs can carry power and more ground. This should reduce the chance of interference and crosstalk at least.
 
First I'd look at grounding. If grounds from Teensy and that display touch the metal chassis at different places, you could be seeing terrible ground loop problems. You probably want just 1 connection from the electronics of the machine's ground or metal frame.

Next, as an experiment to learn more, I'd rig up the Teensy to run from AA batteries rather than the 12 volt system. If it works when installed on the machine but running from its own battery, then you can focus your effort on cleaning up the incoming 12V power.

Otherwise, start looking at how any other non-power wires connect to the whole system (any wires to sensors or other stuff), and if all of those seem to be fine then as a last resort start trying to look at the spooky black magic of electro-magnetic coupling. But focus on grounding first, then power, then other wires and leave the non-wire coupling for last. Avoid the temptation of go down that dark path before you've dealt with all the ways things are actually connected by wires or metal surfaces.
 
Thank you all for the suggestions.

It seems to be a power problem.

I have a toggle switch that cuts the 12V to the 5V regulator to the LCD and the 12V to the 5V regulator for the Teensy. If I power the system with the toggle switch in the off position and then switch it on, the LCD doesn´t show information. If I leave the switch in the on positon and then plug the connector to the power socket, the system works fine.

It seems to me that the reason might be noise from the toggle switch. Attached is a picoscope measurement in the two terminals of the switch. I have tried adding a capacitor to the 5V LCD supply but it's the same.

I tried adding a delay before the lcd.init() but it didn´t help either. If I power the LCD with the same 5V that I power the Teensy it works, but I don´t have any extra wires on the cable, so I can´t do that.

The only way it works if I turn the switch ON (the LCD powers up but no information), then I toggle the switch OFF and ON very quickly and the LCD starts to show information.

Any toughts on how can I solve this?

Capturar.jpg
Capturar2.jpg
 
First I'd look at grounding. If grounds from Teensy and that display touch the metal chassis at different places, you could be seeing terrible ground loop problems. You probably want just 1 connection from the electronics of the machine's ground or metal frame.

Next, as an experiment to learn more, I'd rig up the Teensy to run from AA batteries rather than the 12 volt system. If it works when installed on the machine but running from its own battery, then you can focus your effort on cleaning up the incoming 12V power.

Otherwise, start looking at how any other non-power wires connect to the whole system (any wires to sensors or other stuff), and if all of those seem to be fine then as a last resort start trying to look at the spooky black magic of electro-magnetic coupling. But focus on grounding first, then power, then other wires and leave the non-wire coupling for last. Avoid the temptation of go down that dark path before you've dealt with all the ways things are actually connected by wires or metal surfaces.

Paul do you think this has to do with the fact that the 5V for the LCD isn´t the same 5V that power the Teensy? The grounds are the same.

I tried to power the LCD with the 5V that also powers the Teensy and it works, but I need to have separeted voltage regulators for them, because the LCD is on the tractor and the Teensy is on the machine.

Thank you.
 
I tried adding a delay before the lcd.init() but it didn´t help either.

How long was the delay you tried?

Before going farther, please try again with a really long delay, like delay(30000), as the very first line in your setup() code. 30 seconds can seem like forever to wait while staring at lifeless hardware, so when you test maybe go get a cup of coffee or watch a youtube video or something.

Please give a really long delay at least 1 try before we dive deeper into guesswork on less likely causes of this problem.
 
I have found the problem (at least it's working).

The problem was the toggle switch, it was brand new and had continuity in it's terminals, and a low resistance.

I tried another type of toggle switch and it's working perfectly.

I still don't understand why, but at least I can go in to the weekend with my mind cleared :)

Thank you for all the help.
 
Back
Top