I am trying to use a Mitutoyo Digimatic dial indicator as a threading dial to automatically stop a lathe at a user-defined set point. When threading into the headstock, one must be prepared to withdraw the cutter and stop the lathe in a coordinated manner as the end of the thread is reached, that is, if one wants to produce a thread that tapers to end on a shoulder, not a thread ending in a groove. Anyone who has done that knows how easily it is to get mesmerized by the process and mess up.
Digimatic code is similar to standard SPI code. There are four wires plus ground. Data are read on the rising edge of the clock. The device sends 13 hexadecimal digits, i.e., 52 bits of data.
Since I don't need to read and store all of the data nor control the indicator from the MCU, I had planned only to key on a particular value for the set point. For example, a value of all zeros would indicate the set point. Rather than do that, however, I have tentatively decided to stop on a change in sign. In this particular example, if the stop point is set to be zero, values leading up to that point will be negative. At the stop point, data will change to positive. The sign in Digimatic code is the 5th hexadecimal digit, which is read from LSB to MSB. A "0" is positive and an "8" is negative. Thus, in theory, all I will need to do is look at bit 20 and wait for it to change from high to low, i.e., 0001 (d'8) to 0000 (d'0).
I want to keep the code as simple as possible. I have not completely ruled out hardware SPI, such as with the PIC 16F88, but since I do not need bi-directional communication, that seems like overkill. Moreover, I am a real novice at coding.
QUESTIONS:
1) Does the approach of "monitoring" just that one bit make sense? Is error detection needed, e.g., two consecutive "positive" readings?
2) Would you recommend using an interrupt or polling, based on the CLK from the indicator?
3) What is the disadvantage to using polling?
Thanks. John
Digimatic code is similar to standard SPI code. There are four wires plus ground. Data are read on the rising edge of the clock. The device sends 13 hexadecimal digits, i.e., 52 bits of data.
Since I don't need to read and store all of the data nor control the indicator from the MCU, I had planned only to key on a particular value for the set point. For example, a value of all zeros would indicate the set point. Rather than do that, however, I have tentatively decided to stop on a change in sign. In this particular example, if the stop point is set to be zero, values leading up to that point will be negative. At the stop point, data will change to positive. The sign in Digimatic code is the 5th hexadecimal digit, which is read from LSB to MSB. A "0" is positive and an "8" is negative. Thus, in theory, all I will need to do is look at bit 20 and wait for it to change from high to low, i.e., 0001 (d'8) to 0000 (d'0).
I want to keep the code as simple as possible. I have not completely ruled out hardware SPI, such as with the PIC 16F88, but since I do not need bi-directional communication, that seems like overkill. Moreover, I am a real novice at coding.
QUESTIONS:
1) Does the approach of "monitoring" just that one bit make sense? Is error detection needed, e.g., two consecutive "positive" readings?
2) Would you recommend using an interrupt or polling, based on the CLK from the indicator?
3) What is the disadvantage to using polling?
Thanks. John