jrlLAB / ElectroLab

API to control the ElectroLab
GNU General Public License v3.0
1 stars 0 forks source link

Python script initializes Arduino code (3D_Printer_controller.ino) line by line #9

Open Inkyu-Oh opened 2 years ago

Inkyu-Oh commented 2 years ago

During my testing with Oliver last week, any Python command with negative values as below didn't work such as... motor = controller.Motor() motor.send(b'<X,1000,-2000>')

I have been suspicious about this binary string can't hold negative integers, but now I guess there is another reason.

Whenever Python command was executed line by line, Nikita's Arduino code was initialized with every single Python command. However, Nikita’s code first executes homing (if not commentized) and set the (0,0) position, and then track the number (I guess 0 to 20,000 is admissible tracking numbers, and we can add or subtract any positive or negative intergers so that these tracking numbers are within this admissible range). That’s why we couldn’t execute for example “motor.send(b'<X,1000,+2000>')” and then “motor.send(b'<X,1000,-2000>')” in Python. The head will first go right, but as Arduino code initializes again, the tracking number becomes zero then we can not make -2000 with the second Python command.

Therefore, Python controller module should be fixed so that it doesn’t initialize Arduino code with every Python command line. I am quite sure about this reasoning. When I decommentize homing() in Aduino code, and run some python scripts, homing was executed with every python line commands. This means that python makes Arduino code run from the beginning everytime.

oliverrdz commented 1 year ago

Part of this hopefully is solved now, after @nikitalukhanin change to the arduino code and the API that seems to be working (22f6d12). I still need to implement the homing function in Python.