Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AxiDraw SE/A1 with Brushless Servo Upgrade is not supported to control pen up/down #1

Open
melaniehuang opened this issue Oct 26, 2023 · 10 comments

Comments

@melaniehuang
Copy link

axi.moveTo() works great however the axi.penUp() and penDown() shows no response.

My hypothesis is that the SE/A1 with Brushless Servo upgrade requires a different configuration. See equivalent config additions here that were added to the Python library:

https://axidraw.com/doc/py_api/#api-changelog

v 3.8 (2023-01)
Added new [penlift](https://axidraw.com/doc/py_api/#penlift) option, to enable brushless servo option.
@jmpinit
Copy link
Owner

jmpinit commented Oct 26, 2023

Thanks for trying it out!

I don't have a Brushless Servo Upgrade Kit to test with, but if you would be so kind as to help me test a solution then I think we can get it working.

I've made a test sketch here: https://editor.p5js.org/jmpinit/sketches/GsWZ7_OKC
It's the servo-out example from this branch I just made: jmpinit.brushless-servo

If you click the sketch you should be able to connect the AxiDraw. Then if you click at different Y heights it should tell the AxiDraw to set the servo to different positions. It might only move a little bit but that's okay for the purposes of the test, as long as it moves at all. If that works then I should be able to add support for the brushless servo upgrade, but I'll ask your help again for testing it if you don't mind.

Notes for myself:

The brushless servo is connected to the third header from the bottom (as explained in the installation instructions). This is labeled "B2" and corresponds to pin RP5, so the pin index for the S2 command is 5.

@melaniehuang
Copy link
Author

@jmpinit Thanks for looking into this!
I can confirm it works with the top quarter of the sketch canvas.

const dutyCycle = constrain(map(mouseY, 0, height, 0, 0.25), 0, 2);

I changed the mapping so I could test with more fidelity and its working great!

@benoitwimart
Copy link

benoitwimart commented Feb 1, 2024

Hi,
I have the A3 model with a brushless servo kit.
The script https://editor.p5js.org/jmpinit/sketches/GsWZ7_OKC with this sketch https://raw.githubusercontent.com/jmpinit/p5.axidraw/main/examples/mouse-control/sketch.js works for movement, but the pencil doesn't move when I click, and it stays stuck at the top maximum position.
Note: I am still a bit lost with npm, packages, and other things.

@jmpinit
Copy link
Owner

jmpinit commented Feb 1, 2024

@benoitwimart does your brushless servo kit work correctly with the software from Evil Mad Scientist? Maybe it's running an older version of the firmware? Could you let me know what firmware version is installed? One way to do this is to use the AxiDraw CLI: https://axidraw.com/doc/cli_api/#version

@benoitwimart
Copy link

It's run with Inkscape and Saxi (with a fork for brushless), I think it's the last firmware (but I will check).

@benoitwimart
Copy link

I have this :

Your AxiDraw has firmware version 2.8.1.
Your firmware is up to date; no updates are available.

In Chrome (not Firefox)
https://editor.p5js.org/jmpinit/sketches/GsWZ7_OKC is OK but I need to setup Pen in inkscape after few click (maybe out of range ?)

Mouse-control sketch paste in this works for XY but not Z.
(good news: webpack is running on my folder :)

@jmpinit
Copy link
Owner

jmpinit commented Feb 5, 2024

@benoitwimart do you mean that the linked sketch does make the pen move, but only in Chrome and not in Firefox?

It would definitely be out of range with the default, because it is set to the maximum possible. You could try using the range that @melaniehuang found to work for the dutyCycle (0 to 0.25).

Just in case because you mentioned webpack - it should only be necessary to setup the JS build (yarn, webpack, etc.) if you are making changes to the source code of the library. If you just want to use it in a sketch then you can just include the p5.axidraw.js file from the latest release in your sketch. Or if you want to use this branch you could copy the p5.axidraw.js file that is part of the sketch linked above.

Someday maybe I'll get a brushless servo upgrade and then I can add proper support. For anyone else reading this - PRs are also welcome if you happen to have one and want to do it 🙏 .

@benoitwimart
Copy link

Firefox (Mac OS) can't connect to Axidraw with your extension (it's work with Saxi).
Chrome (Mac OS) is OK for me.

Yes, webpack is running so I can build the code to do some tests.
axi.penDown(); and axi.penUp(); is not support for brushless ? just dutyCycle ?

I make a short message on ems-chat discord :) Windell Oskay help me to hack Saxi for my brushless servo.

@benoitwimart
Copy link

For me it's OK with
axi.servoOut(5, 0.9); to axi.servoOut(5, 2.0);

@jmpinit
Copy link
Owner

jmpinit commented Feb 9, 2024

Great! To answer your question above - yes penDown and penUp do not support the brushless servo upgrade kit for now. The brushless servo is connected differently than the regular servo motor. The EBB control board in the AxiDraw provides a "Set Pen State" command which controls the regular servo motor, and that's what penUp and penDown are using currently in this library. The brushless servo gets connected to a spare servo port on the control board, so it must be controlled with a different command called "General RC Servo Output", which can emit the servo control signal on any available IO port.

I'll make it so that penUp and penDown issue both commands, use a best guess for the duty cycle value, and provide some way to adjust it.

One small note - a duty cycle value greater than 1 is not valid and should trigger an error. Melanie wasn't hitting that because her map statement would not produce a value greater than 1. Maybe you are in the same situation but I thought I'd mention it just for completeness / clarity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants