Im trying to read the value from my Mitutoyo digital micrometer 543-390B Datasheet. The micrometer is using a smartbox to communicate with PC, the box is using P87C51SBPN microchip P87C51SBPN Datasheet. I tried to find out to what pin the micrometer is connected to and it is connected to the pins 2,3,4 and 39. I used the connection apporach from link and also the python code from here link code. When i run the code nothing happens no error either any data from the micrometer. Again this is the code im using

import time
import pigpio


# The callback implements the Mitutoyo SPC protocol
# 13 4-bit nibbles, least significant bit first.

def cbf(gpio, level, tick):
   global in_data, bit, nibble, nibbles, data_level
   if gpio == REQ:
      nibble = 0
      bit = 0
      nibbles = [0]*13
      in_data = True
   elif gpio == DATA:
      data_level = level
   else: # CLK
      if in_data:
         nibbles[nibble] |= (data_level << bit)
         bit += 1
         if bit > 3:
            bit = 0
            nibble += 1
            if nibble > 12:
               in_data = False

pi = pigpio.pi()
if not pi.connected:

in_data = False
bit = 0
nibble = 0
nibbles = [0]*13
data_level = pi.read(DATA)

pi.set_mode(REQ, pigpio.OUTPUT)
pi.write(REQ, 1)
pi.set_pull_up_down(CLK, pigpio.PUD_UP)
pi.set_pull_up_down(DATA, pigpio.PUD_UP)
cb1 = pi.callback(REQ, pigpio.FALLING_EDGE, cbf)
cb2 = pi.callback(CLK, pigpio.FALLING_EDGE, cbf)
cb3 = pi.callback(DATA, pigpio.EITHER_EDGE, cbf)




Can someone help me with this problem? Thank you

  • I suggest you use piscope to check the correct signals are present. – joan May 23 '20 at 15:40
  • Thank you for your help i used the piscope to see if there is any signal and it shows signals. When i swicht the REQ from pin GPIO 4 to ground i get the following result imgur.com/a/htZaeFJ. The python code is not reading any values from the micrometer still. How can i read the value from piscope or make the python code print the values? – touseef osmani May 24 '20 at 20:17
  • It looks like there may be valid data. You need to zoom in on the signals. – joan May 25 '20 at 10:20
  • When i zoom in i get the following result: imgur.com/EynAwG9 imgur.com/Fck6Wfc. How can i convert this data in to readble vales? – touseef osmani May 25 '20 at 12:19
  • Have you swapped the clock and data lines? Your set up has SDA as the clock and SCL as the data. You need to add debug statements to your code and more closely inspect what is going on. – joan May 25 '20 at 12:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.