DO Bits Not Stable in Python


#1

I’m using the Dobot GUI feedback python code and am checking for bits 3,4,5,6 to be set at different times in the MG400 LUA script. I’ve added the check for each bit separately, but all the bits turn on at random times along with the correct LUA script times. Attached is my code to sort out the bits. I know the digital_output_bits are uint64, so stripping for each bit should be straight forward. DO_6 is used to signal the end of the LUA script and goes on and off, Wait(100) in between, and only once in the script, yet in thread2 (get_measurement), it prints when other bits go on / off at random times which should not be happening. Can you help sort this out? Thanks.


#2

Can anyone help here? Why are my DO & DI bits changing in my GUI when there’s no change to the DO bit in the robot script? I using DO4 to toggle a DAQ setup in my GUI and DO6 never changes state (Verified with scope on output pin). I only have a print statement for DO6, which when the GUI is running DO6 toggles twice with each DO4 bit change (ON then OFF, 400mS toggle time). Somehow the original MG400 python code for the thread isn’t decoding the bits properly, or?? GUI code for thread No change to the dobot_api.py code and everything else is working fine. i.e. no issues with DO4 triggering at random times! Thanks.

def feed_back(self):
hasRead = 0
while True:
#print(“self.global_state(connect)”, self.global_state[“connect”])
if not self.global_state[“connect”]:
break
data = bytes()
while hasRead < 1440:
temp = self.client_feed.socket_dobot.recv(1440 - hasRead)
if len(temp) > 0:
hasRead += len(temp)
data += temp
hasRead = 0

        a = np.frombuffer(data, dtype=MyType)
        if hex((a['test_value'][0])) == '0x123456789abcdef':
            # Refresh Properties
            self.label_feed_speed = (a["speed_scaling"][0])
            self.label_robot_mode = (LABEL_ROBOT_MODE[a["robot_mode"][0]])
            self.label_di_input = bin(a["digital_input_bits"][0])[2:].rjust(64, '0')
            self.label_do_output = bin(a["digital_output_bits"][0])[2:].rjust(64, '0')

        # ****************************************************************************
            self.feedbk_cnt += 1
            self.di_input = (int(self.label_di_input) & int(60))
            self.do_output = (int(self.label_do_output) & int(63))
            self.PressCk = bool(self.do_output & 1)  # check for preesure output ont
            self.VacCk = bool(self.do_output & 2)  # check for preesure output ont
            self.trig_meas = bool(self.di_input & 4)  # check for bit set to take measurement
            #self.DO_4 = bool(self.label_do_output & 2048)
            self.DO_4 = bool(self.di_input & 8)  # Trigger ELoad to run LIST
            self.DO_5 = bool(self.di_input & 16)  # Bit set when running MG400 script
            self.DO_6 = bool(self.di_input & 32) # Bit set indicates end of script
        # ****************************************************************************
            # Refresh coordinate points
            
            self.set_feed_jointJ(LABEL_JOINT, a["q_actual"])
                
            self.set_feed_jointC(LABEL_COORD, a["tool_vector_actual"])

            # check alarms
            if a["robot_mode"] == 9:
                self.display_error_info()
        
        time.sleep(0.005)