Starting my build

Building a delta throttle? Make a thread here to share your progress and ask questions.

Re: Starting my build

Postby oijando » Tue Mar 10, 2015 5:25 pm

Well, tried to get started on this over the weekend and found that I don't have the #26 drill bit and no hardware place nearby even has one for sale. So off to get a $2 bit shipped for $5 :P
oijando
 
Posts: 23
Joined: Tue Jan 06, 2015 4:20 pm

Re: Starting my build

Postby zdayton » Tue Mar 10, 2015 8:35 pm

Based on the quality of your prints I doubt you will actually need it. It seems like the holes came out pretty perfect already. Try pressing in a few inserts. If they go in without getting gummed up with plastic on the inside, and you can screw into them, then you are fine without drilling.

The drill is for people with crappy printers, like me :)
zdayton
Site Admin
 
Posts: 81
Joined: Wed Dec 24, 2014 6:20 am

Re: Starting my build

Postby oijando » Thu Mar 12, 2015 2:58 pm

They do look pretty clean, but I was lucky and found an ebay seller not too far away who was selling what I needed for a couple bucks shipped. It should be here today, so tomorrow I am going to spend the day building, finishing and gluing so I can start flying with this bad mamma jamma!
oijando
 
Posts: 23
Joined: Tue Jan 06, 2015 4:20 pm

Re: Starting my build

Postby oijando » Fri Mar 13, 2015 8:46 pm

building was a success. But im getting an error on upload. This is my first time working with Arduino so did I do something glaringly wrong?

Image
oijando
 
Posts: 23
Joined: Tue Jan 06, 2015 4:20 pm

Re: Starting my build

Postby zdayton » Fri Mar 13, 2015 8:55 pm

I will get you more detailed instructions when I get home, but before you can compile the code there are some files you need to copy in to the correct location. It should all be in the instructions. Also make sure you have the promicro selected in the device list. I will be home in a few hours so if you are still having trouble I will post better help :)
zdayton
Site Admin
 
Posts: 81
Joined: Wed Dec 24, 2014 6:20 am

Re: Starting my build

Postby oijando » Sat Mar 14, 2015 4:10 pm

I tried to follow the instructions but the part where I had to copy the cpp and header files was a bit different on my machine. I'm running windows 7 and I figure that is probably where my problem lies. I didn't have any more time to mess with it yesterday, so I figured that I would leave a post here to make sure I hadn't forgotten something obvious. When I get a chance to work on it again, I'll post specifics of what I saw on my machine in case anyone else has trouble.
oijando
 
Posts: 23
Joined: Tue Jan 06, 2015 4:20 pm

Re: Starting my build

Postby zdayton » Sun Mar 15, 2015 12:45 am

Hmm ok. What version of the arduino IDE are you using? I am on 1.06 if it is a version issue.

Next, did you go to https://learn.sparkfun.com/tutorials/pr ... okup-guide and follow those instructions? Specifically the part where you download the promicro addon files and copy them into Documents\Arduino\Hardware? Can you select the promicro from the drop down board menu?

Finally the error you are getting is caused by not being able to find HID.cpp, USBAPI.h, and USBCore.cpp. Where did you copy those to? For me it was C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino. I don't think there should be a difference for windows 7, except if you are 32 bit, in which case they would just be in Program Files.
zdayton
Site Admin
 
Posts: 81
Joined: Wed Dec 24, 2014 6:20 am

Re: Starting my build

Postby oijando » Mon Mar 16, 2015 7:19 am

I got that error when running version 1.6.1 of the IDE, and yes I followed the instructions to install the Micro addon to the IDE.

I figured that I just needed to copy the files to the right location, so I searched my pc for the hid.cpp file to see how many places Arduino installed those files. After trying a couple locations, I found that the files needed to be in my user directory: C:\Users\USERNAME\Documents\Arduino\hardware\sparkfun\avr\cores\arduino in order to get past those initial errors. However, once I put the files in that directory, I received a different error:

Code: Select all
C:\Users\Chad\Documents\Arduino\hardware\sparkfun\avr\cores\arduino\HID.cpp:19:22: fatal error: Platform.h: No such file or directory
 #include "Platform.h"
                      ^
compilation terminated.
Error compiling.


A quick Google search brought up results that looked like if I revert to 1.0.6, the platform.h error should go away, so I uninstalled 1.6.1 and gave it a try.

After some trial and error, I was able to get it to compile by using these addon files: https://cdn.sparkfun.com/assets/learn_tutorials/1/2/1/SF32u4_boards-pre-1.6.zip and unzipping them into C:\Users\USERNAME\Documents\Arduino\hardware\sparkfun. From here on out, your instructions matched... the HID.cpp, USBAPI.h, and USBCore.cpp files needed to be copied to: C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino.

VICTORY!

On my throttle, I added a thumb hat and two buttons to the handle, so I edited the code to the following to add the extra inputs:
Code: Select all
JoyState_t joySt;

const bool DEBUG = false;  // set to true to debug the raw values

float xZero, yZero, zZero;
float xValue, yValue, zValue;

//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;

 
 // trigonometric constants
float sqrt3 = sqrt(3.0);
float pi = 3.141592653;    // PI
float sin120 = sqrt3/2.0;   
float cos120 = -0.5;       
float tan60 = sqrt3;
float sin30 = 0.5;
float tan30 = 1/sqrt3;



void setup(){
 
    pinMode(A0, INPUT);
    pinMode(A1, INPUT);
        pinMode(A2, INPUT);
        pinMode(2,  INPUT);
        pinMode(3,  INPUT);
        pinMode(4,  INPUT);
        pinMode(5,  INPUT);
        pinMode(6,  INPUT);
        pinMode(7,  INPUT);
        pinMode(8,  INPUT);       
        pinMode(9,  INPUT);
        digitalWrite(2,HIGH);
        digitalWrite(3,HIGH);
        digitalWrite(4,HIGH);
        digitalWrite(5,HIGH);
        digitalWrite(6,HIGH);       
        digitalWrite(7,HIGH);
        digitalWrite(8,HIGH);       
        digitalWrite(9,HIGH);

    if(DEBUG) {
       Serial.begin(9600);
    }

        getForwardKinematic();
   // calculate neutral position
   xZero = 0;
   yZero = 0;
        zZero = zValue;

   joySt.xAxis = 0;
   joySt.yAxis = 0;
        joySt.zAxis = 0;
}

//The delta kinematic math
//You shouldn't need to change anything here.
void getForwardKinematic()
{
   //p1 is the bottom joint, p2 is the top right, p3 is the top left
    int p1ADC = analogRead(A0);
    int p2ADC = analogRead(A1);
    int p3ADC = analogRead(A2);

 
    //get the angle of each joint in radians
    float theta1 = (p1ADC-60) * 0.003475;
    float theta2 = (p2ADC-60) * 0.003475;
    float theta3 = (p3ADC-60) * 0.003475;
   
    float t = base_rad-handle_rad;
    float y1 = -(t + pivot_lng*cos(theta1));
    float z1 = pivot_lng*sin(theta1);
 
    float y2 = (t + pivot_lng*cos(theta2))*sin30;
    float x2 = y2*tan60;
    float z2 = pivot_lng*sin(theta2);
 
    float y3 = (t + pivot_lng*cos(theta3))*sin30;
    float x3 = -y3*tan60;
    float z3 = pivot_lng*sin(theta3);
 
    float dnm = (y2-y1)*x3-(y3-y1)*x2;
 
    float w1 = y1*y1 + z1*z1;
    float w2 = x2*x2 + y2*y2 + z2*z2;
    float w3 = x3*x3 + y3*y3 + z3*z3;
     
    // x = (a1*z + b1)/dnm
    float a1 = (z2-z1)*(y3-y1)-(z3-z1)*(y2-y1);
    float b1 = -((w2-w1)*(y3-y1)-(w3-w1)*(y2-y1))/2.0;
 
    // y = (a2*z + b2)/dnm;
    float a2 = -(z2-z1)*x3+(z3-z1)*x2;
    float b2 = ((w2-w1)*x3 - (w3-w1)*x2)/2.0;
 
    // a*z^2 + b*z + c = 0
    float a = a1*a1 + a2*a2 + dnm*dnm;
    float b = 2*(a1*b1 + a2*(b2-y1*dnm) - z1*dnm*dnm);
    float c = (b2-y1*dnm)*(b2-y1*dnm) + b1*b1 + dnm*dnm*(z1*z1 - pushrod_lng*pushrod_lng);
 
    // discriminant
    float d = b*b - 4.0*a*c;
   
    zValue = 0.5*(-b+sqrt(d))/a;
    xValue = (a1*zValue + b1)/dnm;
    yValue = (a2*zValue + b2)/dnm;
   
    if(DEBUG) {
      Serial.print("T1: ");
      Serial.println(theta1);
      Serial.print("T2: ");
      Serial.println(theta2);
      Serial.print("T3: ");
      Serial.println(theta3);
      Serial.print("Z1: ");
      Serial.println(z1);
      Serial.print("Z2: ");
      Serial.println(z2);
      Serial.print("Z3: ");
      Serial.println(z3);
      Serial.print("DNM: ");
      Serial.println(dnm);

    }
}

void loop(){

  getForwardKinematic();
 
  int btn1 = !digitalRead(2);
  int btn2 = !digitalRead(3);
  int btn3 = !digitalRead(4);
  int btn4 = !digitalRead(5);
  int btn5 = !digitalRead(6);
  int btn6 = !digitalRead(7);
  int btn7 = !digitalRead(8);
  int btn8 = !digitalRead(9); 
 
 
 //subtract zero position
xValue -= xZero;
yValue -= yZero;
zValue -= zZero;

//x Value deadzone
  if(xValue < -1*deadzone)
  {
     xValue = xValue + deadzone;
  }
  else if(xValue > deadzone)
  {
        xValue = xValue - deadzone;
  }
  else
  {
        xValue = 0;
  }
 
//y Value deadzone
  if(yValue < -1*deadzone)
  {
     yValue = yValue + deadzone;
  }
  else if(yValue > deadzone)
  {
        yValue = yValue - deadzone;
  }
  else
  {
        yValue = 0;
  }
 
 
 //z Value deadzone
  if(zValue < -1*deadzone)
  {
     zValue = zValue + deadzone;
  }
  else if(zValue > deadzone)
  {
        zValue = zValue - deadzone;
  }
  else
  {
        zValue = 0;
  }

//apply gain
  int xVal = xValue*gain;
  int yVal = yValue*gain;
  int zVal = zValue*gain;
 
//constrain outputs to +- 100
  xVal = constrain(xVal,-100,100);
  yVal = constrain(yVal,-100,100);
  zVal = constrain(zVal,-100,100);
 
//map outputs to 8 bit values
  joySt.xAxis = map(xVal, -100, 100, 0, 255);
  joySt.yAxis = map(yVal, -100, 100, 0, 255);
  joySt.zAxis = map(zVal, -100, 100, 0, 255);
 
  joySt.buttons = btn1 | (btn2<<1) | (btn3 <<2) | (btn4 <<3) | (btn5 <<4) | (btn6 <<5) | (btn7 <<8) | (btn8 <<9);

  if(DEBUG) {
   Serial.print("X: ");
   Serial.println(xVal);
   Serial.print("Y: ");
   Serial.println(yVal);
   Serial.print("Z: ");
   Serial.println(zVal);
      Serial.print("B1: ");
      Serial.println(btn1);
      Serial.print("B2: ");
      Serial.println(btn2);
      Serial.print("B3: ");
      Serial.println(btn3);
      Serial.print("B4: ");
      Serial.println(btn4);
      Serial.print("B5: ");
      Serial.println(btn5);
      Serial.print("B6: ");
      Serial.println(btn6);
      Serial.print("B7: ");
      Serial.println(btn7);
      Serial.print("B8: ");
      Serial.println(btn8);



     
  }

  // Send to USB
  Joystick.setState(&joySt);
 
  if(DEBUG)
    delay(1000);
}


I fired up Star Citizen to test the throttle and it worked like a dream! The only problem I have is a mechanical one...The arms on my throttle are still tight and don't appear to be loosening up, so I am going to switch the balls back into the stock Traxxas ball ends and purchase some threaded studs and standoffs for the easy fix, since I have to rely on the library's work schedule to get more parts printed.

Thanks for the help, and I'll update the thread once I get my new arms on. With the changes coming to strafe in the Star Citizen 1.1 this week, this throttle should really shine!
oijando
 
Posts: 23
Joined: Tue Jan 06, 2015 4:20 pm

Re: Starting my build

Postby jeruw » Mon Mar 16, 2015 3:40 pm

Awesome! When you have a moment let's see some pics!

Glad you found the software issue. I'd read a thread in the discussion board that suggested we needed to use 1.0.6 instead of 1.6 Arduino IDE and was able to find the pre-1.6 addons so I managed to avoid the issues you had getting things compiled. I should have posted that in here earlier.

I'd love to see how you placed and installed your buttons, particularly the hat switch. I can't think of a good place for it for myself. Did you get the same hat as from the BOM?

I'm loving my throttle in ED. They released a new combat fighter last week that's extremely maneuverable and it's a blast to fly with this thing.
jeruw
 
Posts: 80
Joined: Tue Feb 17, 2015 3:10 pm

Re: Starting my build

Postby oijando » Mon Mar 16, 2015 7:40 pm

Progress photos!

Lower arms glued:
Image

Parts prepped and ready for construction:
Image

Threaded inserts installed:
Image

Lower arms ready to install on base:
Image

Base complete! Getting those arms mounted on the potentiometers was a paaain!
Image

Time to start the wiring! This shouldn't take long...
Image

3 Hours later... that took way longer that I had hoped :)
Image

Compiler errors, yay!
Image

Victory!!
Image

I have some new parts coming in tomorrow to replace the 3d printed arms that will solve my stiff ball socket problem. *cough* Once I have it working smoothly, I will post with some more feedback.

Right now, I have my buttons and hat switch wired but not glued in place since I wasn't positive where I wanted them. I am pretty happy with the location of them for now but they are a bit harsh to use. I'd like to put some caps on them to make them easier on the fingertips to activate. Ideally, I'd like to mold a new handle that fits my large hands better but this works for a first prototype.
oijando
 
Posts: 23
Joined: Tue Jan 06, 2015 4:20 pm

PreviousNext

Return to Build progress and showcase

Who is online

Users browsing this forum: No registered users and 1 guest

cron