Acties:
  • 0 Henk 'm!

  • WeeDzi
  • Registratie: Juli 2009
  • Laatst online: 21:35
HI ik ben een joystick controller aan het maken op basis van een Teensy 2.0. eigenlijk zijn het mn pedalen van mn logitech controller maar ik wilde ze graag zonder het stuur gebruiken. tevens heb ik een uitbreiding met een loadcell gemaakt. en nu wilde ik dat allemaal via de teensy laten registreren.

de load cell is heb ik werkend gekregen maar op een of andere manier krijg ik de andere 2 potmeters van de pedalen niet werkend. ik doe iets vast triviaals fout maar kan het niet vinden.

///////////////////////////////////////////////////////////////////////
// SIMPLEST LOAD CELL BRAKE PEDAL FOR RACING SIMULATION
// by JS Stoezel
// js.stoezel@gmail.com
///////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////
// INCLUDES
///////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////
// Get this library from this Git repository
// https://github.com/aguegu/ardulibs/tree/master/hx711
#include "HX711.h"
///////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////
// MACROS
///////////////////////////////////////////////////////////////////////
// How many samples to take at initialization of the library to zero
// out the offset of the load cell.
#define BRAKE_PEDAL_LOAD_BEAM_CELL_TARE_REPS 10

// Sanity check for the load cell readings. This will typically be to
// prevent from loading negative values if/when the load cell is pulled
// in the wrong direction
#define BRAKE_PEDAL_LOAD_BEAM_CELL_MAX_VAL 2000000

// This setting links the maximum effort applied to the pedal to the
// maximum value sent to the joystick interface.
// The joystick interface expects a value ranging from 0 t0 1023. Adjust
// this number to your liking, so the joystick will read 1023 at the maximum
// force you feel comfortable applying to the brake pedal (without braking it).
// The hardware I am using is 3D printed and I do not recommend this value
// Be set any lower than 1100. Any lower value will require more force to
// be applied to the pedal, and may damage the 3D printed parts.
#define BRAKE_PEDAL_LOAD_BEAM_CELL_SCALING 1100


///////////////////////////////////////////////////////////////////////
// LOCAL VARIABLES
///////////////////////////////////////////////////////////////////////
HX711 brake_pedal;
///////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////
// FUNCTIONS
///////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////
void setup()
///////////////////////////////////////////////////////////////////////
{
// Zero the pedal offset. This is is to compensate for the own weight
// of the pedal. It is important not to apply any force to the pedal
// While this is happening
brake_pedal.begin(1 /* DAT */, 0 /* CLK */, 128 /* GAIN */);
brake_pedal.tare(BRAKE_PEDAL_LOAD_BEAM_CELL_TARE_REPS);

// Joystick.useManualSend(true);
} // setup

///////////////////////////////////////////////////////////////////////
void loop()
///////////////////////////////////////////////////////////////////////
{
int32_t brake_value ;

brake_value = brake_pedal.get_value(1);

if((brake_value > BRAKE_PEDAL_LOAD_BEAM_CELL_MAX_VAL) ||
(brake_value < 0))
{
brake_value = 0;
}

brake_value /= BRAKE_PEDAL_LOAD_BEAM_CELL_SCALING;

Joystick.X(brake_value);
Joystick.Y(analogRead(A2));
Joystick.Z(analogRead(A3));

Joystick.send_now();
} // loop


ik krijg geen compiling error en zoals gezegd werkt de loadcell wel, wat doe ik fout

edit
oja ik kwam erachter dat ik waarschijnlijk een counterfit bordje heb en er lijkt wel random input rond de z as maar hij reageert niet op een beweging van het pedaal....