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

use on ESp32dev #15

Open
Hatzumi187 opened this issue Jul 16, 2023 · 13 comments
Open

use on ESp32dev #15

Hatzumi187 opened this issue Jul 16, 2023 · 13 comments

Comments

@Hatzumi187
Copy link

Hatzumi187 commented Jul 16, 2023

Hello andrew, thank you for this code.
i am totally new here and hope this is the right way. i only have a M5 stack fire without shield for the motors, so i loaded your code on a ESP32dev board and adjusted the pin's before. It looks like it runs and I like it a lot, better than the other "Egg" solutions. My problem is the SD card is not recognized in the Micro-SD adapter module to uplode or save files. Is there a solution to this? Please help me.

thank you for your effort
regardless see paypal ;-)

@andrei-tatar
Copy link
Owner

@Hatzumi187 thanks for your donation.
Not really sure why the SD card would not be recognized. Try formatting it using FAT32 (if it's not already). I used an old 512MiB card I had laying around.

@Hatzumi187
Copy link
Author

Hatzumi187 commented Jul 17, 2023 via email

@andrei-tatar
Copy link
Owner

@Hatzumi187 there is also a fork here that says

I just modded it to a) work on a plain ordinary esp32 b) slow down the pen hammering on the egg otherwise

https://github.com/rysmario/wifi-egg-duino
The above fork also doesn't change any SD pins, only the ones for the stepper motors.

Which pins are used in your sketch for the SD card?

The pins for the SD card I think are pretty much the same on all ESP32 boards, aren't they? For this code version, the usage is here, in the M5Stack lib:
https://github.com/m5stack/M5Stack/blob/7ebd4c63e3ad488c2e43d42896f7a3f8324583e8/src/M5Stack.cpp#L29

SD and SPI come bundled with Arduino for ESP32, you don't need to do anything extra and the M5 lib doesn't seem to change the default pins.

Would it work with an "M5Stack Core2 & stepper motor driver module"?

I don't see why not. Might need some pins changed for the stepper motor driver. I just built my own stepper motor driver and chose the pins I wanted to use.

@Hatzumi187
Copy link
Author

Hatzumi187 commented Jul 17, 2023 via email

@Hatzumi187
Copy link
Author

Hatzumi187 commented Jul 17, 2023 via email

@Hatzumi187
Copy link
Author

Do you have any idea why the printing is not correct for me? The pen motor moves left and right against the wall when printing. I have already tried to set the "Steps per rotation" down but then the print image is much too small and the proportions are no longer correct. How can I set the print field to 3200x800 mm? This is how I tested it in Inkscape directly on another Egg device.
I use a
-A4988 driver
-Nema17 42A02C

@andrei-tatar
Copy link
Owner

@Hatzumi187 You might need to change the number of steps per revolution according to your driver setup (number of microsteps) and the motors. I don't remember what kind of motors I used.

@Hatzumi187
Copy link
Author

Hatzumi187 commented Jul 19, 2023

I tried it with all possible steps from 200 - 3200, unfortunately no good result. As soon as I print something it is totally squeezed. As if the X and Y ratios are not correct and as soon as I increase the steps too much the pen crashes with the servo against the left wall. I have built my shield according to these instructions [Link](url)

`#ifndef PRINTER_H
#define PRINTER_H

#include <AccelStepper.h>
#include <MultiStepper.h>
#include <Preferences.h>
#include <FS.h>

typedef std::function<void()> PrinterHandler;

#define PIN_ROT_DIR 26
#define PIN_ROT_STEP 12
#define PIN_ROT_RES 13

#define PIN_PEN_DIR 25
#define PIN_PEN_STEP 14
#define PIN_PEN_RES 13

#define PIN_SERVO 27
#define SERVO_CHA 2
#define SERVO_MIN (65536 / 30)
#define SERVO_MAX (2 * SERVO_MIN)

#define VSPI_SS 5
#define VSPI_SCLK 18
#define VSPI_MISO 19
#define VSPI_MOSI 23

struct MotionParameters
{
uint8_t penUpPercent, penDownPercent;
uint16_t drawingSpeed, travelSpeed;
uint16_t penMoveDelay;
uint16_t stepsPerRotation;
bool reverseRotation, reversePen;
};

class Printer
{
public:
Printer();
void begin();

void penUp();
void penDown();
void enableMotors();
void disableMotors();
void getParameters(MotionParameters &params);
void setParameters(const MotionParameters &params);

void print(File file);
void stop();
void pause();
void continuePrint();

bool isPaused() { return waiting; }
String getWaitingFor() { return waitingFor; }
bool isPrinting() { return printTaskHandle ? true : false; }
const ulong getPrintedLines() { return printedLines; }
const char *printingFileName() { return printing->name(); }

void onProgressChanged(PrinterHandler handler) { onProgress = handler; }
void onStatusChanged(PrinterHandler handler) { onStatus = handler; }

void printTask();

private:
void applyParameters();
void moveTo(long x, long y);

bool waiting;
File *printing;

ulong printedLines;
PrinterHandler onProgress, onStatus;
String waitingFor;
AccelStepper mRotation, mPen;
MultiStepper multiStepper;

int32_t posX, posY;
uint16_t penUpValue, penDownValue,penCurrValue;
bool _isPenUp, _isMoving;
Preferences preferences;
MotionParameters parameters;
TaskHandle_t printTaskHandle = NULL;

};

#endif
`
Do you perhaps see a fault with me?
In the drawing you can see that 3 connections go from the ESP32 to the A4988 driver.
Are these two maybe wrong
#define PIN_ROT_RES 13 & #define PIN_PEN_RES 13
or are there problems with the Accelstepper library with my setup?
I've been trying for days and can't seem to get it to work.
Please help. I don't want to have to use a UNO with cable and Inkscape on the computer.
With kind regards

@andrei-tatar
Copy link
Owner

@Hatzumi187 If I remember correctly, I think you need to "reslice" the svg after you change the number of steps.
For code simplicity, the actual motor movement is saved in the "egg" file.

@Hatzumi187
Copy link
Author

Thank you very much for your software! It works now. With one of the drivers (A4988) the M2 contact was not given and therefore this strange behavior. Now I'm just trying to figure out how to center an imported SVG file on the ping pong ball. In the Hello World test print, the O is not quite round, but this is certainly still due to the alignment of the pen. Has actually been improved on the client Ordenr in the M5 version, since the date was I think newer? If so, can I just copy this into the ESP version?
I am glad that it now works.

Greetings

@Hatzumi187
Copy link
Author

ok, i try to reslice again. Maybe it's then on the right position.

@Hatzumi187
Copy link
Author

Hello Andrei, is it possible, as with inkscape, to fill the graphic /svg file, i.e. not just the border?

@andrei-tatar
Copy link
Owner

@Hatzumi187 I didn't add a fill method to the slicer logic.

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

2 participants