Code breakdown and explaination

Code breakdown and explaination

Postby chunks » Sat Jan 10, 2015 3:47 am

I am planning on building a delta throttle based off of your work, however I am fairly new to Arduino and coding of this nature, I am planning on using the code you have released but I would like to better understand how it all works, I've been reading up on forward kinematics and trying to wrap my head around the maths (I shined in English and History when at high school...). I was wondering if you wouldn't mind doing a detailed breakdown and explanation of your code? I understand this could be a lot of work and understand if its not possible for you to do so but it would be greatly appreciated if you could.
chunks
 
Posts: 2
Joined: Sat Jan 10, 2015 3:36 am

Re: Code breakdown and explaination

Postby zdayton » Mon Jan 12, 2015 7:09 am

There is a really good explanation of delta kinematics on the Trossen robotics forum, which I used as a starting point for my code:
http://forums.trossenrobotics.com/tutor ... tics-3276/

I probably can't break down the whole thing, but some stuff you could conceivably need to change:
Code: Select all
//Geometry
float handle_rad = 1.75;     // end effector
float base_rad = 1.75;     // base
float pushrod_lng = 3.5;
float pivot_lng = 2.25;

//Configuration
float deadzone = 0.1;  // smaller values will be set to 0
int gain = 150;


This is some configuration stuff. You might want to tweak the deadzone to your liking.

Code: Select all
        pinMode(2,  INPUT);
        pinMode(3,  INPUT);
        pinMode(4,  INPUT);
        digitalWrite(2,HIGH);
        digitalWrite(3,HIGH);
        digitalWrite(4,HIGH);


Setting up the digital IO. If you add more than three buttons, you will need to configure the additional IO pins the same as these.

Code: Select all
   xZero = 0;
   yZero = 0;
        zZero = zValue;


Setting the zero point. The X and Y zero points will always be the center, but the Z zero will be whatever the current Z position is when you first plug it in.

Let me know if you have questions on something specific.
zdayton
Site Admin
 
Posts: 81
Joined: Wed Dec 24, 2014 6:20 am

Re: Code breakdown and explaination

Postby chunks » Mon Jan 12, 2015 9:29 am

Are the lengths on the armatures fixed? ie. If I were to make either of the arms shorter/longer would adjustments need to be made within the code?
chunks
 
Posts: 2
Joined: Sat Jan 10, 2015 3:36 am

Re: Code breakdown and explaination

Postby zdayton » Wed Jan 14, 2015 9:46 pm

You would want to change the values up at the top in the geometry section, pushrod_lng and pivotarm_lng. You will also want to increase or decrease the gain accordingly. If you make the device smaller, increase the gain, if you make it larger, decrease the gain.
zdayton
Site Admin
 
Posts: 81
Joined: Wed Dec 24, 2014 6:20 am

Re: Code breakdown and explaination

Postby jeruw » Wed Mar 11, 2015 10:29 pm

My push rod length measured from ball center to center is 3.25 and my link arm is coming out around 2.2. I'm updating those values in the code, but it's not entirely clear to me if I need to mess with the *_rad values, and how much I should adjust gain. When I first plugged things in my Z axis didn't seem to be working correctly, it wouldn't register a change unless it was pushed very far down. Also, my X and Y are not at 0 when at rest. This may be something I need to adjust because my socket for the D shaft is not fixed to my pivot, I had to eyeball it to line it up.
jeruw
 
Posts: 80
Joined: Tue Feb 17, 2015 3:10 pm

Re: Code breakdown and explaination

Postby jeruw » Thu Mar 12, 2015 7:01 pm

Ok, I've got this hooked up and working in ED. Holy crap. What a tremendous difference! Combat flight feels so much better. The ship feels significantly more maneuverable.

I have some drift along the x axis though, even with a dead zone. I'll need to keep tweaking things to see what to do about it.

I also don't really know what to do with the Z axis. I tried clamping the throttle to my desk so I could pull up more effectively but I couldn't get much out of it. I can really only effectively do a negative z-axis move. Any thoughts on what settings I might adjust?
jeruw
 
Posts: 80
Joined: Tue Feb 17, 2015 3:10 pm

Re: Code breakdown and explaination

Postby zdayton » Thu Mar 12, 2015 7:44 pm

The way the code is set up, the z axis zero point is wherever the z axis is when you first plug it in. What I do is this: rest my hand on the handle, not actively pressing down or up just resting my hand on the handle so the springs balance against the weight of my hand, then plug it in.

Also, I recommend sticking it down with some double sided tape, or maybe glue a nice rubbery material to the base to hold it in place. Or just use clamps like you have.
zdayton
Site Admin
 
Posts: 81
Joined: Wed Dec 24, 2014 6:20 am

Re: Code breakdown and explaination

Postby jeruw » Thu Mar 12, 2015 8:11 pm

zdayton wrote:The way the code is set up, the z axis zero point is wherever the z axis is when you first plug it in. What I do is this: rest my hand on the handle, not actively pressing down or up just resting my hand on the handle so the springs balance against the weight of my hand, then plug it in.

Also, I recommend sticking it down with some double sided tape, or maybe glue a nice rubbery material to the base to hold it in place. Or just use clamps like you have.



That makes sense. I think I saw a comment from you about that in your reddit post too. I'll give that a try tonight. I also saw some comment about adding a button to toggle the control to lock at 0,0,0. Did you make any progress on the code for that? I'd love to be able to lock it out for some actions. I absolutely loved flying with this thing in combat last night, but I did get myself blown up by a station trying to leave. Oops.
jeruw
 
Posts: 80
Joined: Tue Feb 17, 2015 3:10 pm

Re: Code breakdown and explaination

Postby jeruw » Thu Mar 19, 2015 8:45 pm

I think I may have some code to track a button's state to act as a toggle for disabling flight control and locking all axis to zero. I haven't tested it in flight yet but I'll try tonight.

I pushed the code to a fork on GitHub. You can review it here:

https://github.com/jerdavis/DeltaThrott ... 22ebd1e826
jeruw
 
Posts: 80
Joined: Tue Feb 17, 2015 3:10 pm

Re: Code breakdown and explaination

Postby zdayton » Thu Mar 19, 2015 10:25 pm

Just a couple problems to fix.
1. you are treating the toggle button like a normal button and pushing it through to windows. Don't know if that was what you wanted. (That's what the joy_st.buttons line does) .
2. And most importantly, your need a rising edge trigger for your toggle button, otherwise it will toggle continuously every iteration of the loop. This is pseudo code but you want something like:
If (togglebutton == 1 and togglebuttonlast == 0)
Toggle state
Togglebuttonlast = togglebutton
zdayton
Site Admin
 
Posts: 81
Joined: Wed Dec 24, 2014 6:20 am

Next

Return to Discussion

Who is online

Users browsing this forum: No registered users and 0 guests

cron