Need some help with the math

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
mpetrasinovic
Posts: 106
Joined: Sat Feb 22, 2020 10:19 am
Location: Belgrade, Serbia
Contact:

Re: Need some help with the math

Post by mpetrasinovic »

Again, glad to help :D

I didn't even know that B-code exists but the wire-bending capability for the Path workbench would be a really good thing to have.
User avatar
sliptonic
Veteran
Posts: 3459
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Need some help with the math

Post by sliptonic »

UPDATE.

I finally had time to wire up a stepper motor to drive the wire extruder and get Lenny configured to drive it. I did my first bending tests yesterday with some success. Good news is it bent a wire! Bad news, is there's some issues to resolve.

Here's the sample wire I'm bending. It's just a sketch so all segments are on the same plane. The first segment processed is the short 5mm one at the bottom. Selecting the sketch and running my attached macro will produce the b-code and Lenny's gcode in the report window. The b-code looks like this:

Code: Select all

Length   Rotation   Angle
======   ========   ======
 5.000      0.00    90.000
25.000    180.00    48.000
40.000    180.00    81.000
20.000      0.00     0.000
So far, so good. But the bent wire is wrong. I'll post again as I work it out.
bendtest.png
bendtest.png (32.18 KiB) Viewed 914 times
bentwire.jpg
bentwire.jpg (84.7 KiB) Viewed 914 times
Attachments
bendingcode.FCMacro
(3.61 KiB) Downloaded 28 times
bendtest.FCStd
(4.49 KiB) Downloaded 71 times
chrisb
Veteran
Posts: 54273
Joined: Tue Mar 17, 2015 9:14 am

Re: Need some help with the math

Post by chrisb »

Well, it works, congratulations! The rest is fine tuning.

If I look at the first 90° bend it seems that Lenny is still a bit hesitant about bending. Taking that into account it seems that the angle of the subsequent bends should rather be 180°-angle. And Lenny seems to a bit stubborn, thinking something like "I just turned 180° and now again? No, sir, if he really wanted this he wouldn't have turned the first time!"
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
sliptonic
Veteran
Posts: 3459
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Need some help with the math

Post by sliptonic »

chrisb wrote: Tue May 19, 2020 11:03 pm Well, it works, congratulations! The rest is fine tuning.

If I look at the first 90° bend it seems that Lenny is still a bit hesitant about bending.
Exactly. I think the bending algorithm is about right. There's some spring-back in the wire and he isn't tuned very accurately but that's fine tuning.
Taking that into account it seems that the angle of the subsequent bends should rather be 180°-angle. And Lenny seems to a bit stubborn, thinking something like "I just turned 180° and now again? No, sir, if he really wanted this he wouldn't have turned the first time!"
That was my first thought too..and part of the problem I think. flipping it to 180 degrees - angle improves it but the last segment is still inverted.
IMG_20200519_182453.jpg
IMG_20200519_182453.jpg (64.34 KiB) Viewed 901 times
User avatar
sliptonic
Veteran
Posts: 3459
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Need some help with the math

Post by sliptonic »

chrisb wrote: Tue May 19, 2020 11:03 pm And Lenny seems to a bit stubborn, thinking something like "I just turned 180° and now again? No, sir, if he really wanted this he wouldn't have turned the first time!"
Actually, You were pretty close on this one too. The b-code produced by the algorithm gives the rotation angle between bends incrementally. But Lenny's C joint is in absolute coordinates so when commanded to go to 180 degrees the second time, he said, "I'm already there" and didn't move. Easy fix and he's producing something like correct bends now. :D

Now to fine tune....
chrisb
Veteran
Posts: 54273
Joined: Tue Mar 17, 2015 9:14 am

Re: Need some help with the math

Post by chrisb »

It becomes so simple once you know the reason.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
mpetrasinovic
Posts: 106
Joined: Sat Feb 22, 2020 10:19 am
Location: Belgrade, Serbia
Contact:

Re: Need some help with the math

Post by mpetrasinovic »

I did not saw this posts until now. Glad to see the wire, is it working now?
User avatar
sliptonic
Veteran
Posts: 3459
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Need some help with the math

Post by sliptonic »

I posted the first of a series of videos about this project. This is just the introduction so not much content yet.
I've been able to do some very basic bends. I still have some issues to work out and I want to merge the b-code generating logic into master as a python module.

I'm not sure what this will look like in the Path module yet so stay tuned.

phpBB [video]
User avatar
mpetrasinovic
Posts: 106
Joined: Sat Feb 22, 2020 10:19 am
Location: Belgrade, Serbia
Contact:

Re: Need some help with the math

Post by mpetrasinovic »

sliptonic wrote: Mon Jun 01, 2020 4:41 pm I posted the first of a series of videos about this project. This is just the introduction so not much content yet.
Looking good. I am willing to help if you run into some new math/mechanics problem.
User avatar
sliptonic
Veteran
Posts: 3459
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Need some help with the math

Post by sliptonic »

phpBB [video]

mpetrasinovic wrote: Mon Jun 01, 2020 7:09 pm Looking good. I am willing to help if you run into some new math/mechanics problem.
Thanks! I may take you up on that. I'm going to get serious testing and bending now that the bender is ready.
Post Reply