0

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

REQ=4
CLK=3
DATA=2

# 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:
               print(nibbles)
               in_data = False

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

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)

time.sleep(300)

cb1.cancel()
cb2.cancel()
cb3.cancel()

pi.stop()

Can someone help me with this problem? Thank you

5
  • I suggest you use piscope to check the correct signals are present.
    – joan
    Commented May 23, 2020 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? Commented May 24, 2020 at 20:17
  • It looks like there may be valid data. You need to zoom in on the signals.
    – joan
    Commented May 25, 2020 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? Commented May 25, 2020 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
    Commented May 25, 2020 at 12:34

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.