TouchDRO Supports new Chinese DRO Scales

Monday, February 4, 2019
TouchDRO "Black" Adapter Support All of The Shown Digital Readout Scales Now 

A few weeks ago, I finally found some time to experiment with the new Shahe Digital Linear Scales 5403-xxx and 5404-xxx. Electrically these scales are compatible with other 3V capacitive DRO scales such as iGaging DigiMag, EZ-View DRO and iGaging Absolute DRO. This means that adding support for the new scales is a matter of updating the firmware of the TouchDRO adapter for iGaging and Shahe DRO scales. After cursory check of scale protocol, I was expecting this to be a relatively easy addition to the existing firmware since they use the familiar BIN6 protocol. In practice, supporting Shahe "Remote DRO" scales ended up requiring a complete rewrite of large portion of the firmware. While at it, I decided to invest some more time into adding several other improvements that have been on my "to do" list for some time now. After several weeks of testing and debugging, the new firmware is ready to be released. In addition to the added protocol support, the updated firmware includes a few major performance and stability tweaks that will make capacitive DRO scales behave much more reliable in a shop environment.

Supported Protocols

Obviously, the biggest change in this version is a support for the new scales. The board now supports three capacitive scale protocols:

  • iGaging 21-bit protocol that is used by the iGaging EZ-View, older DigiMag "Remote DRO" scales and their generic/rebranded counterparts, including AccuRemote and Shars
  • Modified Digimatic SPC protocol used by iGaging Absolute DRO Plus scales
  • BIN6 protocol used by the new Shahe 5403 and 5404 remote digital readout scales

Supporting the new scales went well beyond the ability to parse the protocol and convert the data bits to some normalized units. To operate with best stability and reliability, each scale type has to have data and clock lines set up slightly differently. For instance, iGaging EZ-View scales work best with the clock line in Push/Pull mode and data line floating. Absolute scales won't even send the position if both lines are not pulled up to Vcc. In contrast, the new Shahe scales go nuts if the data line is pulled up, but need the clock input pin pulled up. Making things even more complicated is the fact that 21-bit scales need to be read on the falling edge of the clock signal, Shahe scales need to be read at the raising edge, and the absolute scales need to be read a few microseconds after the raising edge.

All this required multi-stage initialization routine that manipulates the clock line, reads the input, tries to guess what the scale type is, adjusts the data line to the state appropriate for the given scale and check that the data stream matches the expected pattern. Once the scale type is determined, the firmware applies optimal pull up/down resistors configuration and interrupt edge for each axis. It then disables any unused lines and starts processing position updates and sending them to the application.

Improved Tachometer Accuracy

Stable Tachometer Reading With 0.3Hz Input

Second major improvement in the new firmware is a new tachometer implementation that can handle very low RPMs without sacrificing high-RPM performance. Up to this point, TouchDRO firmware had a relatively naive implementation of tachometer. The processor counted the number of incoming pulses for a second and multiplied the result by 60 to get pulses per minute. This approach works pretty good for higher pulses per minute (PPM), especially with fine encoder disks at the cost of choppy low PPM performance.

Handling low RPM tachometer input is simple in theory. The algorithm is roughly as follows:

  • Get the number of milliseconds between pulses
  • Average a few values for stability
  • Divide the number of milliseconds in a minute by the averaged value

The problem is that this approach requires two division operations, one to get the average and another to get the PPM. MSP430 lacks division hardware so division is extremely slow. I spent several months before this update experimenting with various tricks and was able to design a solution using in-memory lookup tables and bit shifting operations that completely avoid software division. The result is a tachometer implementation that can handle low-PPM input faster than the old version could with far superior accuracy. It also eliminates a small drift that was present in the old version. I.e. as the number of pulses per second increase the tachometer timing could drift up to 2-3% due to the computational overhead. While this irrelevant for any day-to-day usage scenario, it bugged me a bit; so, in the new implementation, I got it to within 0.4% over the 20 PPM to 10,000 PPM range.

Faster Position Update Rate

Another area where I've improved the firmware is the position refresh rate. Previous version refreshed all four axis positions at 10Hz. This results in maximum delay of 100 ms in the worst case scenario, which should result in no perceivable lag. There is a decent amount of research done on this subject suggesting that an average human can perceive a delay of about 150 ms between "subject simulated motor input and the resulting visual stimulus". This concept is called "horizon of simultaneity" and in plain english means that if, for example, you flip a switch and it takes less than 150 ms for the light to come on, you will not notice any delay.

But why leave well enough alone? In the new firmware I decided to bump the refresh rate to 20Hz and implement a smarter position refresh logic. First, the controller won't send position to the app for disconnected scales. Second, and more importantly, the firmware uses dynamic refresh rate for active scales. In other words, after a data stream from a scale is received the firmware checks if the position has changed. If it has, the controller will send it to the app up to 20 times per second, or 2x faster than the old version. On the other hand, if the scale hasn't moved, the controller will drop the refresh rate to 4Hz. The good news is that even if you are somehow able to move four axes at the same time, all four will refresh at full 20 Hz.

Smaller Tweaks

There are two smaller tweaks that will be useful with the next version of the TouchDRO app. First, once per second the controller sends a small message to the app that contains the information about which scales are active and what protocol they use. This will make it possible for the app to load better defaults during the initial setup and prevent issues where the users don't set correct scale resolution.

Second, probe status is handled slightly different in the new firmware. Previously, once the probe was activated, the board would send its status to the app at the same cadence as the rest of the axes. New firmware does it a bit better: the moment probe is activated, the processor takes a snapshot of scale positions, sends the position to the app, and sends the probe status immediately after the position readout. As long as the probe is activated, the board will keep sending the "probe is on" message to the TouchDRO app every 50 milliseconds. Once the probe is deactivated, the board will send the "probe is off" message to the app for one more second and stop. This does two things:

  • Reduces the lag between the time probe is activated and the app has a chance to handle the message
  • Saves a bit of bandwidth by not blasting probe status while it's off

Summary

As you can see, besides the obvious benefit of having support for the new Shahe Linear Digital Readout scales, the new firmware has a number of other enhancements. Probably the most noticeable will be the effect of improved scale detection logic since each scales input will be optimized for best stability. More stable tachometer reading will not make a huge difference for many users, but those who need high precision, low RPM tachometer on their mill or lathe this will definitely be a nice the improvement. Faster and smarter position refresh logic and probe status reporting won't be something that most people will notice and is will mostly help make other features in the new TouchDRO version more responsive. Overall the new firmware version will improve stability, accuracy and responsiveness of a do-it-yourself DRO setup that uses the supported capacitive scales.

29 comments :

  1. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. Please contact Al at Blu-DRO. He is pretty good about addressing hist customer's issues. Also, this issue has nothing to do with the current post, so you are more likely to get help on the Help and Support forum (link on the top of the page).

      Delete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Is the new firmware available for the MSP430 launchpad? I need a new scale for the lathe.

    ReplyDelete
  4. I'm really looking forward to seeing this, Yuriy. It's good to see you back on it.

    ReplyDelete
  5. Good evening, I wanted to know the power supply voltage of the TouchDRO BlueTooth Adapter, and if the positive and the central one.
    Thank you

    ReplyDelete
  6. Good evening
    I have 2 scales like the gray ones in the picture, I tried to connect the scale to the touch dro with a mini-b to micro-b adapter, but it does not read.

    ReplyDelete
    Replies
    1. This firmware comes on the pre-made boards only right now. The first batch of boards with V2.0 firmware shipped out last Saturday, so I think you are either using a board with the old firmware, of a DIY board. Neither will read the new scales.

      Delete
    2. You sent it to me on January 28, 2019.
      How can I upgrade the firmware to V2

      Delete
    3. I can reprogram it for you if you want to send it back to me.

      Delete
  7. I have a Sieg sx2p milling machine that I equip with new digital scales shahe. They will be connected to the Msp 430 "Igaging" controller.
    The milling machine has a tachymeter output. Is it possible to connect it to the controller?

    Thank you and congratulations for all your work!
    Bests regards.
    Guiu

    ReplyDelete
    Replies
    1. I don't think there is a direct way. I haven't had a chance to play with SX2, but on SX4 there is no techometer sensor on the spindle. The machine uses signal from the motor driver to infer the RPM. I asked SIEG if they have any documentation on the pinout, so I can just tap into the pulse, but they didn't respond.

      Delete

    2. On this site you will find, I believe, all possible information
      https://macpod.net/misc/sx2_tachometer/sx2_tachometer.php

      Best regads Guiu

      Delete
  8. Yuriy,
    I have a question on the tach. I bought my board from Al and once I got the tach working it has an error of 3%. The motor speed is 1764 rpm and the tach readout is 1710 rpm. This is with 20 ppr (I've tried less ppr but it seems to make no difference on the percentage it is off). My question is can the updated software you are talking about make a difference in what I'm experiencing or is it not worth it. And can the newer software be installed on my board. Just so you know I'm the dunderhead who could not get the tach working until I used shielded wire and grounded the shield to the board (and by the way, that blog about bonding was very informative and I thank you for posting it). Please let me know your opinion
    Regards
    Mike

    ReplyDelete
    Replies
    1. Mike,
      I can re-flash your board with the new firmware. New firmware has a bit more accurate timing, but why do you care about the 3% error in the tach?

      Delete
    2. I would just like it to be a little more accurate. What would be the error percent with the new firmware?

      Delete
  9. Will the touch probe have functionality/indication within the app?

    ReplyDelete
    Replies
    1. Yes, it will. I don't want to spill the beans too much, but there will be three different functions that rely on probe input: edge finding, tool height compensation and data capture.

      Delete
    2. Awesome. Given the improvements in the new firmware, will probe functionality be implemented in the app itself, or will it require a new/reprogrammed board?

      Delete
  10. Hi,

    Just a question, do you ever plan to release the new firmware for us DIY users? If so do you have a time frame in mind?

    Thank you

    ReplyDelete
    Replies
    1. Yes, but in slightly different form. I'm trying to find some sort of balance between keeping the project free and covering my costs and labor (it's basically a half-time job now that takes 20-25 hours per week), so to nudge people to buy the boards, paying customers will be getting things faster and with more features. In this case "more features" means that free version will be a separate firmware for Shahe scales that won't be able to mix-and-match the scales. I don't know what the time frame is. Right now I'm pushing really hard to get the new version of the app out, so that is my main priority.

      Delete

    2. I will be ready to pay. You have to reward your work. The price must be reasonable.
      Guiu

      Delete
  11. Hi! I've followed your project for some time now and I've pretty much concluded that I'm a dumbass for not getting around to order scales and a card yet..

    Btw, have you tested (or heard of someone who has tested) your app on android-x86 ,prime0S or similar? The reason for asking is that i reasently got an "old" laptop with a touch screen that would be great to run this sort of application on. Big screen etc..

    ReplyDelete
    Replies
    1. I don't know about android-x86 specifically, but the app runs very well on my PixelBook (Chrome OS with Android sub-system and i5 CPU). I know that a few years back someone got it to run on Raspberry Pi running Android.
      I'm not using anything hardware-specific or low level (besides USB, which I would love to get rid of), so I don't see why not. If you already have the laptop, you can try installing the app from the Play Store and see if anything looks fishy. You can even use a second "device", paid them and use terminal to push some fake stings to the app (the board uses ASCII protocol to send the data. There is a blog post from few years back that details the protocol).

      Delete
  12. Christer Bruno-LundhFebruary 24, 2019 at 5:27 AM

    Hi.

    I got mine the 13th of december.
    But I have the Shahe 5403.

    How do I update the firmware? Send it to you? Or can i get a programmer and update myself?

    Regards
    Christer

    ReplyDelete