Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,15 @@ Methods
* **enable**: _bool_ enables/disables suction
* **.grip(enable)**
* **enable**: _bool_ enables/disables gripper
* **.wait(ms)**
* **ms**: _integer_ milliseconds to wait before the next command
* **wait**: _bool_ waits until command has been executed to return to process
* **.set_io_mode(address, mode, wait=False)**
* **address**: _integer_ EIO port number
* **mode**: _str_ I/O mode (Dummy, PWM, DO, DI, ADC)
* **wait**: _bool_ waits until command has been executed to return to process
* **.set_pwm_output(address, frequency, duty_cycle, wait=False)**
* **address**: _integer_ EIO port number
* **frequency**: _float_ pulse frequency
* **duty_cycle**: _float_ pulse duty cycle (0 to 100)
* **wait**: _bool_ waits until command has been executed to return to process
34 changes: 34 additions & 0 deletions pydobot/dobot.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
MODE_PTP_MOVL_INC = 0x07
MODE_PTP_MOVJ_XYZ_INC = 0x08
MODE_PTP_JUMP_MOVL_XYZ = 0x09
IO_MODES = {'Dummy': 1, 'PWM': 2, 'DO': 3, 'DI': 4, 'ADC': 5}

STEP_PER_CIRCLE = 360.0 / 1.8 * 10.0 * 16.0
MM_PER_CIRCLE = 3.1415926535898 * 36.0
Expand Down Expand Up @@ -235,6 +236,30 @@ def _set_end_effector_laser(self, power=255, enable=False):
msg.params.extend(bytearray([power]))
return self._send_command(msg)

def _set_wait_cmd(self, ms):
msg = Message()
msg.id = 110
msg.ctrl = 0x03
msg.params = bytearray(struct.pack('I', ms))
return self._send_command(msg)

def _set_io_multiplexing(self, address, mode):
msg = Message()
msg.id = 130
msg.ctrl = 0x03
msg.params = bytearray(struct.pack('B', address))
msg.params.extend(bytearray(struct.pack('B', mode)))
return self._send_command(msg)

def _set_io_pwm(self, address, f, d):
msg = Message()
msg.id = 132
msg.ctrl = 0x03
msg.params = bytearray(struct.pack('B', address))
msg.params.extend(bytearray(struct.pack('f', f)))
msg.params.extend(bytearray(struct.pack('f', d)))
return self._send_command(msg)

def _set_queued_cmd_start_exec(self):
msg = Message()
msg.id = 240
Expand Down Expand Up @@ -493,6 +518,15 @@ def engrave(self, image, pixel_size, low=0.0, high=40.0, velocity=5, acceleratio

self.wait_for_cmd(self.laze(0, False))

def wait(self, ms):
self._set_wait_cmd(ms)

def set_io_mode(self, address, mode):
self._set_io_multiplexing(address, IO_MODES[mode])

def set_pwm_output(self, address, frequency, duty_cycle):
self._set_io_pwm(address, frequency, duty_cycle)


if __name__ == '__main__':
d = Dobot()
Expand Down