Digital input filtering advice

Hi,

I have recently built myself a DRO (Digital readout) for my mill and lathe using a ESP32 "cheap yellow display" which is working well but I do have some issues with occasional interference I am looking for advice on resolving.
see: GitHub - alanesq/DRO: Super cheap Digital Readout (DRO) for lathes, milling machines etc. (cheap yellow display)

Rather unsurprisingly considering the environment, I am finding that some times when turning the motors of these machines on or off or even running my vacuum cleaner close can interfere with the readings from the digital calipers.

I understand the outputs of the calipers can also be taken to ground to simulate pressing of the control buttons which I suspect may be behind the issue as when it happens the calipers tend to jump 5mm in their reading which seems more like some kind of function being triggered rather than random changes, so I am guessing I need some kind of RC filter on digital io pins of the caliper to block the rfi (BTW-I have tried pull-up resistors on them), or is there something I can do to suppress interference on the earth/neutral lines?

BTW - The wire I am using is shielded with the shroud connected to GND at the esp32 end although I have also tried twisted pair.

I have tried diode clamps on the input data pins of caliper and I have ruled out power supply issues (by using a battery to power it), I have tried installing a mains filter on the lathe, tried installing a snubber on the switch and even covering the caliper in a metal shield but all have no effect. This is now getting to the limit of my knowledge :wink:

Oddly, I find that switching my lathe via its main switch which switches both the live and neutral line can sometime do this even when the live wire is disconnected via another switch which I suspect may be a clue?

You can try different power supplies with their filtering mechanisms for the ESP32, calipers, and other components.

Have a read of my decoupling tutorial:-
Decoupling

As I see that you do not mention this technique at all, and is often the answer to picked up interference from motors and the like.

1 Like

Thanks for the replies.
I have tried powering the caliper from its own battery but it still happens so I am pretty sure the issue is on the data lines and not a power / decoupling issue.

Hi, @alanesq
Welcome to the forum.

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum
Rather than post a link to your basic information, it is better to post your code and schematic in a post.

@alanesq Fritzy...

Is the lead to the calipers shielded?
What is the LED and why is there no current limit resistor?
What is the use of the 200R in the gnd circuit?

I would add a 0.1uF capacitor in parallel with the 10uF capacitor to get better high frequency bypassing?

Can you please post some images of your project?

Thanks.. Tom.. :grinning: :+1: :coffee: :australia:

Thanks Tom,
The link is to the documentation about my project on Github including all code, circuit diagram etc..
I will add a 0.1uF capacitor to the power feed as suggested but as I have tried it powered by its own battery and it still happens I am pretty sure power is not the issue.
Yes, the lead is shielded, the image you have posted is just an example of how the calipers are connected to an Arduino, not specifically the circuit I have used. I use a couple of transistors to level shift between the 3.3v of the esp32 and the 1.6v of the caliper but the issue sometimes happens even if the caliper just has a wire attached but not connected to anything so I am pretty sure it is RFI causing the problem.

Can you please post the actual circuit you have used?
What is the purpose of the 200R in the gnd circuit?
What is the LED, specs, colour?

Thanks.. Tom.. :grinning: :+1: :coffee: :australia:

As I say, the issue happens even if a wire is attached to the caliper data pins with nothing on the other end so I don't think the circuit I am using is important, but you can see the PCB I created here:

I just use a couple of transistors to level shift the signal.
The 200R to gnd in the circuit you have posted is I believe a way to convert the voltage to 1.5v for the caliper.

Hi,
Sorry, that diagram means nothing.

A proper annotated schematic will make a big difference and some pictures of your project.
We need to see signal flow and power distribution.

Thanks.. Tom... :grinning: :+1: :coffee: :australia:

1 Like

Most often these issues are caused by inappropriate witring configurations - especially not keeping digital, power and analog grounds seperate to a star point.

Forget it!
Admin - please delete this thread

Did you actually understand that link I sent you. It is not a matter of the capacitors helping with the power but with reducing interference pick up. This interference can happen even with an internal battery.

Admins do not regularly read all the posts. If you want them to do something then you have to "flag" them using the icon that looks like a flag.

If this circuit ever works, it is guaranteed to be unreliable. You don't have a common ground between the Arduino and the caliper.

Remove the 200 Ohm resistor and use logic level shifters to establish proper voltage levels for communications.

Capture

2 Likes

Just to explain, the circuit being discussed is one I found here:

It is not one I used, I just included this diagram it in the explanation of my project because it shows the pinout of the caliper etc.

I first tried to use a level shifter board but it did not seem to work with the 1.6v so I used transistors instead as below:

Hi,
Your level shifter circuit will also invert the digital signal.

A HIGH from the caliper will cause the BJT to conduct and so the CYD output will go LOW, and vice versa.
What values were the two resistors?

Tom... :grinning: :+1: :coffee: :australia:

I have accounted for the inverting of signal, it reads data from three calipers no problem, the only issue is that some things on the mains can cause the calipers reading to suddenly jump up or down exactly 5mm, which is odd.
I have even been testing the wiring to my shed this morning as I thought there may be some issue but its all ok as far as I can tell.
I have tried several values of resistors, putting diodes to clamp the voltage, all sorts of capacitor combinations but nothing seems to make any difference.
I have tried clicking a piezo lighter near the caliper and this can have the same effect. It only seems to happen when something is connected to the data pins of the calipers (acting as an antenna?)

At the moment I am using 10k pull-up resistors, 10k on the caliper input pin and 600ohm on the esp32 pin but I have tried several values including no resistor at all etc.

I guess maybe putting opto isolators on the caliper outputs to isolate them may be an option although I suspect the outputs wont be able to drive one directly?

The NPN level shifting circuit shown in post #17 should work fine if the resistor values are chosen correctly. There is no need for any resistor on the collector, or even a power supply connection, if you use INPUT_PULLUP on the digital pin. Use a reasonably high gain transistor like 2N3904.

Capture

Yes, I can confirm it does indeed work- thanks
but the thing I am hoping for some help/advice is how can I either prevent my electrical appliances causing the interference or protect the calipers from the interference.
I suspect the interference is RF as it seems to happen even if just a length of wire is attached to the data pins of the caliper.

Things I have tried so far:
Clamping the caliper data pins with diodes, attaching various capacitors to the power in of the caliper (and even the data pins)
Wrapping the caliper in tin foil as a shield
Using a zero crossing solid state relay on the offending motor (i.e. the lathe)
Putting a snubber circuit across the power switch of the offending motor
Connecting the offending device with a mains filter
Very short wires connecting the caliper to the interface
both shielded cable and twisted pair
Powering the lathe via a very long extension sourced well away from the DRO
I have checked good continuity on both earth and neutral lines to the garage
I have powered the calipers via their own battery
I have looked at the power and data pins of the caliper on my oscilloscope but I do not see anything out of the ordinary
I have tried powering the caliper under voltage and over voltage

BTW - The worst offender is the shop vacuum which can send the calipers crazy

From what I see this issue occurs as soon as anything is connected to the caliper data pins and it makes little or no difference what this is so I am guessing the attached wire is acting as an antenna and I need some way to block this at the data pin?

I am out of ideas...

Try shielded cable. You need three connections to the Arduino: data, clock and ground.

I have tried powering the caliper under voltage and over voltage

That does not sound good. Just use the battery power as intended, although at this point, consider that overvoltage may have damaged the caliper.

As I say, I have already tried both shielded and twisted pair (the shielded I connected the outer to GND at the ESP32 end, no connection at the caliper end), I also tried no connection to it).

I have several of these calipers so it is not just one of them (i.e. the one I over voltaged).

I have recorded a video showing the issue in case this helps: https://youtu.be/w0Ttp7oQlok
In the video I am turning the lathe on and off which is out of shot, the caliper I show the LCD reading is the bottom one on the DRO display and you can see both the top and bottom calipers jump exactly 5mm when I turn the lathe on/off