Diy Touchdro using esp32

jirvin_4505

Registered
Registered
Joined
Jun 21, 2019
Messages
8
Hi been following for a while. managed to get the arduino version working a few years ago with capacitance scales

keen to update to glass scales in the lathe and mill.

I initially keen to buy Yuris board however the low aud and a desire to do diy had me exploring diy ESP32 options

found a webpage with links to github

now I’m at edge of my understanding on how to convert a GitHub into a compiled sketch through arduinoIDE

any suggestions on where I should start looking for advice

searching on variations of convert GitHub into arduino doesnt seem to be answering the question

cheers jeff
sunny qld Australia
 
Last edited:
This is the webpage I’ve been referencing


……
Edit…. (wont let me post the weblink.?). We link now posted
 
Last edited:
This is the webpage I’ve been referencing
……
wont let me post the weblink.?
Probably need to increase your post count, before they let you post links.

On a Linux like platform, typically one does the following: (don't type the <-- or anything after the <--, those are just my comments)
Code:
$ cd Arduino <-- navigate to the Arduino folder (directory)
$ git clone nameofremoterepo.git  <-- creates a folder in Arduino and downloads the source files.  You may need to install git.
$ arduino           <-- launches arduino ide

In arduino, select your processor. Open the project you downloaded.
Press verify, to ensure proper building. Iterate as necessary to get proper build.
Press upload, which does a rebuild, and flashes your chip
 
Thanks for the answer
a few more hours of searching …searching… I have found that I had set up the GitHub on computer successfully but there was a missing include statement giving a compile error

have now done a successful compile and upload (I feel young again.. well 66 and not over the hill)

getting some hardware tomorrow to test

will report back

cheers jeff
 
Jeff,
if you can wait a week, I will have the current TouchDRO ESP32 firmware posted to the downloads section (along with the circuit schematic).

Regards
Yuriy
 
I started updating the site with new info. Here is the page about building a DIY DRO with ESP32.
The design and firmware is identical to the DIY TouchDRO Kit. I will post the firmware soon (hopefully this weekend). Still need to tweak a few things.
That said, this built is probably ideal for people who are very good with soldering or masochists (or some combination of the two). I tried building it on a prototyping board, gave up and just ordered a few PCBs. The main problem is that input pins on ESP32 are not designed to be interfaced with the outside world. The old DIY circuit used MSP430, which has Schmitt triggers built in. For ESP32 to get good stability those need to be added as external ICs (all this stuff is explained on the page I linked above).
For glass scales you might get away with a simple resistor divider circuit, but I wouldn't trust that in a noisy shop.

I will let you (y'all) know when the firmware is posted.

Regards
Yuriy
 
Update….
I have the simple esp32 board adaptor working with glass and magnetic scales


(Still working on layout of yuriy schematics - thanks for posting them)

The glass scale worked of the direct 3.5v pins of the esp32

However the magnetic scale needed to have 5v to work

I used a level shifter as described by yuriy

using-quadrature-encoders

Took some troubleshooting as this doesn’t show the LV 3.5v connection bring used?

I had to connect both the LV and HV voltages to get it all working

Cheers Jeff
 
Last edited:
Jeff,
I looked over your Arduino sketch - it will work mostly OK, except the probe and tachometer.
When the probe triggers, you need to grab the encoder values as soon as possible. With your algorithm the probe will be very inaccurate. Since the table will be moving, any delta in time will result in delta in position. It might be small, but let's say you are moving the axis at 5mm per second. I don't see where "reportPeriod" so I don't know what your refresh rate it, but let's say you get around 50Hz, at 5mm per second that is 0.1mm in the worst case scenario before you grab the position for the probe.
Tachometer code (the way you have it written) is very dangerous. You are doing stuff in the ISR and there is no limit on how fast you can handle pulses. With a high-resolution disk and some noise on the line you can swamp the CPU and crash the chip. ESP has hardware for this stuff that will count pulses off the main CPU. A "standard" approach is to have some threshold after which you switch the counter to sampling mode (i.e. don't run it continuous when high pulse rate is detected).
In general, this sort of thing is usually done with multiple threads. ESP32 has two CPU cores and all the hardware to run a preemptive RTOS. This will give you much better control over timing than a "busy loop", lower the current draw (which is a concern, since you are using the on-board V-Regulator), etc.

As far as the circuit - connecting anything to ESP32 without protection is a bad idea, and running glass scales from 3.5V supply is even worse idea. DRO is a precision measurement instrument, so it has to be accurate and reliable. Your code doesn't have any error correction (besides the very basic state machine in the Arduino encoder library), and the circuit doesn't have any protection agains noise, voltage spikes etc. On top of that, 3.5V is below the spec for 5V scales, so they will be more flaky and susceptible to noise. Chinese scales output notoriously noisy signal. In my Glass/Magnetic scales adapter I use chips that can comfortably handle input from -4V to 8V (for 5V nominal scales) and have built in series current limiting resistors. That is probably a bare minimum I'd want in a DRO. Even the DIY circuit I posted for ESP32 is a compromise (AM26LV32IDR doesn't come in TH package, so it's not a good DIY option). It can take one unlucky motor start that creates a decent voltage drop in a ground loop to burn out the input pins.
If you use a mosfet voltage shifter or a resistor divider, you will mitigate the spikes (but not the noise). It's OK to use those with my pre-made boards because there are Schmitt triggers before ESP32 that will deal with line noise to some degree. In reality the cost of the 74HC14 Schmitt triggers is not that high (a few USD with shipping). If the DRO glitches in the middle of a job and looses it's position, the cost of scrapped meta (and the effort you already put into it) will probably be higher.

Hope this helps
Yuriy
 
Awesome yuriy
i didn’t write the sketch …. thanks for your detailed analysis

it was found while looking for a way to add dro to my lathe (after you had mentioned esp32) and (thankfully) now that you have published your diy esp32 it is the way forward for me. Waiting and watching for diy release in November

any update on why/how your published diagram of adding level shifters doesnt show connection to 3v line?

again thanks for your awesome work

cheers jeff
 
Last edited:
Back
Top