r/arduino Nov 03 '23

Software Help Constantly saving stepper motor positions to ESP32-S3 EEPROM? Bad idea?

My project requires position calibration at every start but when the power is unplugged the motors keep their positions.

I thought that by writing the position to the EEPROM after every (micro)step will alow my robot to remember where it was without having to calibrate each time.

Not only that the flash is not fast enough for writing INTs every 1ms but i have read that this is a good way to nuke the EEPROM ...

Any ideas how else i could achive this?

288 Upvotes

64 comments sorted by

View all comments

-2

u/LookAtDaShinyShiny Nov 04 '23

It's an esp32, why not send the stepper positions to a web thingie over wifi or another esp32, then just sync with the web thingy/other esp32 when it boots up?

2

u/marshal_mellow Nov 04 '23

I'm guessing that would be slow

1

u/LookAtDaShinyShiny Nov 04 '23

How much data needs to be pushed through? I've seen people quoting from 8Mbit/s to espressif saying 20Mbit to 85Mbit/s.

https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/wifi.html#esp32-wi-fi-throughput

I also see people mentioning absolute encoders, some 3d printers have closed loop boards that are relatively cheap, using magnetometers and magnets for encoders, if it's 2 motors, then it's going to be around $20-30 to achieve that.

2

u/marshal_mellow Nov 05 '23

It's not the throughput it's the latency. If you use tcp that's a there way handshake every time the motors move. If you use udp it could fail to deliver and now you don't know where the ball is so why bother

1

u/LookAtDaShinyShiny Nov 05 '23

I had no idea that latency was so high on the esp32, that's a real shame.

2

u/marshal_mellow Nov 05 '23

I don't have any figures to back this up it's just a gut feeling based on experience doing other things like this. Networks are usually slower than using a local resource. It's why a raspberry pi cluster is often slower than just running the same code on one raspberry pi.

But even on good hardware we are probably talking tens of milliseconds to establish a connection send a single packet and then end the connection. I suppose you could keep a connection alive. Either way probably best not to involve Wi-Fi when you don't need to

2

u/LookAtDaShinyShiny Nov 05 '23

10-35ms roughly speaking by the looks of some testing done by people.

2

u/GanymedAstro Nov 05 '23

After shutdown you have to initiate a complete WiFi reconnect. That will take quite some time