jxtafreak2025
Newbie

Hi
Need suggestion for this problem.
## Functional description
For the drivetrain of a prototype vehicle you are asked to implement the part that determines the requested torque based on the user input. The user does this by pressing the throttle pedal.
There are multiple options regarding the throttle pedal, but for now the engineers seem to have selected one that produces two analog output signals, which are connected to a microcontroller.
The relation between the analog signals (redundant for safety reasons) and the pedal angle (min = 0 degrees, max = 30 degrees) are as follows:
- `adc1 = 0.5 + 0.1 * angle`
- `adc2 = 1.0 + 0.08 * angle`
Where adc1 and adc2 are voltages and the angle is in degrees. These analog inputs require some basic low pass filtering (moving average).
This pedal angle corresponds to an amount of torque that the motors must provide. This torque is not only dependent on the pedal angle, it’s also dependent on the current speed of the vehicle.
In case something goes wrong, in our prototype an LED should light up on the dashboard to indicate something is wrong (in a real production vehicle an error message will be shown on the instrument cluster).
Below is pseudo code
Need suggestion for this problem.
## Functional description
For the drivetrain of a prototype vehicle you are asked to implement the part that determines the requested torque based on the user input. The user does this by pressing the throttle pedal.
There are multiple options regarding the throttle pedal, but for now the engineers seem to have selected one that produces two analog output signals, which are connected to a microcontroller.
The relation between the analog signals (redundant for safety reasons) and the pedal angle (min = 0 degrees, max = 30 degrees) are as follows:
- `adc1 = 0.5 + 0.1 * angle`
- `adc2 = 1.0 + 0.08 * angle`
Where adc1 and adc2 are voltages and the angle is in degrees. These analog inputs require some basic low pass filtering (moving average).
This pedal angle corresponds to an amount of torque that the motors must provide. This torque is not only dependent on the pedal angle, it’s also dependent on the current speed of the vehicle.
In case something goes wrong, in our prototype an LED should light up on the dashboard to indicate something is wrong (in a real production vehicle an error message will be shown on the instrument cluster).
Below is pseudo code
Code:
int analg_Pin = A3; // potentiometer wiper (middle terminal) connected to analog pin 3
// outside leads to ground and +5V
int value = 0; // variable to store the value read
void setup() {
Serial.begin(9600); // setup serial
}
void loop() {
value = analgRead(analg_Pin); // read the input pin
Serial.println(val); // debug value
}
Last edited by a moderator: