- Wed Sep 26, 2018 1:53 pm
#78405
Before completing the hardware side with the wire that will trigger the payload drop, here the Micropython payload module software side. The servo has superglued tiny plastic cubes D, R and P. The O cube will be superglued to drop payload. I had to remove the original wooden cubes with holes with the plastic cubes in order to reduce friction of the moving wire:
I did play with payload module while I developed it. Before last change I left webrepl_client.py wireless session to the ESP-01s for copying the modified module (I had to turn off PWM for the following file copy to succeed, by "payload.pwm0.duty(0)" command before leaving).
This is the last version of the module:
Code: Select all$ cat payload.py
import machine
pwm0 = machine.PWM(machine.Pin(0), freq=50)
def lock():
pwm0.duty(50)
def drop():
pwm0.duty(100)
drop()
$
Now copy new version to ESP-01s module:
Code: Select all$ ./webrepl_cli.py payload.py 192.168.4.1:
Password:
op:put, host:192.168.4.1, port:8266, passwd:abcd.
payload.py -> /payload.py
Remote WebREPL version: (1, 9, 4)
Sent 134 of 134 bytes
$
Since the "payload" module was imported already in previous session, it had to reloaded. Reloading a module is no standard MicroPython functionality for now. I had added reload() to ESP module boot.py, used the function from this posting:
https://forum.micropython.org/viewtopic.php?f=2&t=413&sid=eb3d9fae5b4c51c661ec513e2983c6c8&start=30#p7609Finally I tried the new module:
Code: Select all$ ./webrepl_client.py 192.168.4.1
Password:
WebREPL connected
>>> reload(payload)
<module 'payload'>
>>>
The final payload.drop() got executed, and now te O cube can be inserted between R and P cube, followed by payload.lock().
Last edited by HermannSW on Thu Oct 04, 2018 9:16 am, edited 2 times in total.