Need code for force sensor Project.

Hello,
I need help I'm a beginner in programming and I want to messure force with a force sensor KM26z-500N from me-systeme. I also bought a messure amplifier. I solded it together and wrote a little code:

int analogPin = 0;
int val = 0;

void setup()   {
Serial.begin(9600);
}

void loop() {
val = analogRead(analogPin);
Serial.print(val);
delay(500);
}

Now the Serial Monitor print the number 295 and it's raise if I press the force sensor.
I want that I can calibrate the force sensor and that it show me the force in kg. And I don't know how to do that.

Moderator edit: CODE TAGS

First you need to subtract the zero reading of 295 and then you need to calibrate it.
Get some known weights and see the readings, then work out what reading increase you get per weight.

That is a very expensive sensor, as I don't speak German the data sheet is not helpfull.

I translated it and put the data of the test protocol inside it's marked as "Bold".

Material: Stainless Steel
Dimensions mm x mm: ø25.4 x 49
Force application: M6 thread

mechanical data
Nominal force (Full Scale): 500N
Use force (Full Scale): 150%
Breaking load(Full Scale): 300
Measuring path(Full Scale): 0.08mm

electrical data
Rated load(Full Scale): 1,0017 mV/V
Zero signal: -0,0215 mV/V
max. Supply voltage V 10
Input resistance: 361.97 Ohm
Output resistance: 350Ohm
Insulation resistance: >2 109

Accuracy
Accuracy class: 1%
rel. Linearity deviation(Full Scale): 0.1%
rel. Hysteresis (2)(Full Scale): 0.05% (0.2%)
Temperature coefficient of the zero signal (Full Scale/K): 0.02%
Temperature coefficient of the characteristic value (Reading/K): 0.02%
Creep error (30 min)(Full Scale): 0,01%

Temperature / Environment
Nominal temperature range: -10°C ... +70°C
Service temperature range: -10°C ... +85°C
Storage temperature range: -10°C ... +85°C
Protection class: IP67

Abbreviations: RD: Actual ("Reading"); FS: full scale ("Full Scale");

  1. The exact nominal sensitivity is reported in the test report.
    to measuring range 50N: 0,5 ... 1,0 mV / V
    Installation note: sensor in the assembly of attachment parts on the assembly side
    Hold / conduct no torque through the sensor.
    ME-measurement systems

The measuring amplifier GSV-14L is designed for use in battery-powered devices.
The amplifier operates from a supply voltage of 3.4V. The
Output is between 0.2V and 3V.
For the signed measure the zero point is shifted to 1.5V.
With an input sensitivity of ± 1 mV / V (or ± 2 mV / V), the output signal
e.g. scaled to ± 1.25V.
The dimensions are 13 mm x 37 mm x 5 mm. All contacts are available in increments
2.54mm arranged.
About fixed resistors is zero leave (1206) and gain
(Input sensitivity, 0805)) to adjust. In addition, a series resistor
be added to the bridge supply (0805).
This allows a fine tuning of scaling to perform, for example, all sensors of a
Scale series of the same output signal (standard signal calibration).
The amplifier has a digital input shutdown.
This input is not connected or connected to ground when the
Measurement amplifier should be permanently switched on.
If the energy consumption on a microprocessor or a modem controlled
be, then the input shutdown via a high value resistor (100kOhm is
... 1MOhm) connected to the voltage source and a digital output of a
Modem or a microprocessor to turn on low-potential drawn.
The output error signals with low level to a low voltage supply.

Reduce Zero Balancing ((zero / zero increase)
With the help of fixed resistors Rp and Rp + (1206), the zero point
be adjusted.
Setting the scaling / sensitivity (signal increase)
By soldering a resistor Rg (0805), the strengthening of
Circuit can be increased. This is parallel to already integrated
Gain resistor soldered to it.
For the reinforcement applies: G = 1 + (100k / Rges). Rges = (272Ohm + Rg) / (Rg * 272Ohm)
(Signal attenuate)
The signal can be attenuated when a fixed resistor Rs (0805) in
Series to the sensor is connected

Shield Shield connection of the sensor
-US Negative sensor supply

  • Positive Us sensor supply
  • Ud positive differential input
    -Ud Negative differential input
    UB Supply voltage 3.4 to 10 volts (optional 4-18 volts)
    GND Ground
    SHDN shutdown of the amplifier with a high signal
    error error indication falls below the min
    Supply voltage / Output Low
    Ua analog output 0.2 ... 3.0 V

Accuracy (linearity): 0.1%
Measuring range (FS) 1): ± 2 (optional ± 3.5, ± 1, ± 0.5) mV / V
Resolution: 10000 parts
DMS full bridge entrance: 88 ... 5000 Ohm
Bridge supply voltage: 5V
CMRR: 95 - 110dB
Input Impedance:> 20MOhm, 300pF

Low Pass Filter
RC filter, Bessel, 3rd order: 1kHz (optional 10Hz)

outputs
Analog output (1): 0.2 ... 3 V
Output Resistance: 60Ohm
Zero point of the analogue output: 0.2 ... 2.9 V
Bridge supply voltage: 2.8V
Current rating: 35mA

supply
Supply voltage: 3.4 ... 10V DC
Current consumption at 350Ω: <10mA

temperature Range
Nominal temperature range: -10 ... + 85 ° C
Storage temperature range: -40 ... + 85 ° C
Drift of the zero point: <0.05% FS / 10 ° C
Drift of sensitivity: <0.02% FS / 10 ° C

dimensions
W x H x L: 27 x 13 x 5 / mm x mm x mm
Weight: 2g

protection
IP40

Thanks for the translation. It is not clear from it however the number of volts per Newton the sensor gives, so I suggest you should just calibrate it.

Hello Grumpy_Mike,

do you can give me a code pls.

Sorry you will have to write it yourself. We can help you if you run into trouble but we don't write code to order here. If you want to pay some one to write it then post in the Gigs and colaberation section.