diff --git a/low-voltage-system/torque-encoder-functionality.md b/low-voltage-system/torque-encoder-functionality.md new file mode 100644 index 0000000000000000000000000000000000000000..67fb0136f17bce2d19d46e3acabc5e208c5747b9 --- /dev/null +++ b/low-voltage-system/torque-encoder-functionality.md @@ -0,0 +1,80 @@ +Although at first it might seem like very simple PCB, the Torque Encoder packs a lot of functionality. + +Its main job is to acquire the signals from the pedals´s sensors and to make sure those signals are not compromised and that they comply with all the rules present in the FS Rules. For more information refer to [Formula Student Rules implied with the Torque Encoder](/Torque encoder fs rules 2017 v1.1). + +Besides acquiring signals from the pedals, the TE also monitors the AIR line and is responsible by sending the analog signal of the brake pedal to the BSPD (Brake System Plausibility Device). + +In this explanation about the functionality, the thought process behind the code is also explained. + +To begin with, the Torque Encoder adquires 5 different analog signals: +* 2 signals from the brake pedal pressure sensors +* 1 signal form the brake pedal potentiometer +* 2 signals from the accelerator pedal potentiometers + +The way it is as of December 2017, the ADC is acquiring the signals at its longest time, meaning that the measurements don´t get better than this. Still, the time it takes to sample the signals is very low, meaning that we have a lot of values very fast. This is the reason why the value used of each sensor is an average of 16 readings, which are stored in a buffer. This buffer has round logic, meaning that once a new reading is available, the oldest one in the buffer is substituted. + +To save on processing, each ADC interruption only adds the new values to each corresponding buffer, while the averages are only performed once we get to the *check phase*. + +As mentioned above, we can devise the code into two phases: +* The Acquiring Phase +* The Check Phase + +The Acquiring Phase is pretty simple and it´s pretty much what was described above. +The Check Phase in the other hand is much more complex and is described here next. + +Since the Check Phase is performed at a much lower rate when compared to the Acquiring Phase, the averages of the values in the buffers are only done here, and it is the first thing that is performed. + +Once the averaged values are calculated, the signals check starts. +The first check is to see if any of the sensors is plausible or not. The cause of this plausibility can be a lot of things: +* The sensor is broken +* The sensor was disconnected +* The wiring is damaged, making a short circuit + +To understand this plausibility check, the notion of sensor threshold must be thought: +* The ADC converts an analog signal into a number within a certain range (in this case a 12 bit ADC gives a number between 0 and 4095) +* A sensor has two thresholds, an upper and a lower one +* A sensor is compromised if the signal is below the lower threshold or above the upper threshold +* In this case is said that the threshold was overshot + +So the first check the TE does is to check if any the thresholds of each sensor was overshot. If so a status bit in set to the corresponding sensor, flagging where something went wrong. + +By the rules, the accelerator pedal must have both sensors functioning correctly and at least one pressure sensor from the brake pedal also working. + +Once again, to save on unnecessary processing, the Torque Encoder only does further checks if the previous conditions are met. + +Otherwise, it returns the brake at its maximum value (meaning full brake) and zero for the accelerator value. + +This is called sensor integrity check. + +If the following is true then the TE proceeds with further checks: +* Both accelerator pedal potentiometers functioning correctly +* At least one brake pedal pressure sensor functioning correctly + +This next stage of checks can be called Phase 2. + +To begin phase 2, new averages are calculated based on the previous averages, but this time, the thresholds are taken into consideration and the averages are also given in a percentage multiplied by 100, meaning the maximum value is 10000. This is so because the values sent by CAN can only be integers with 16 bits. So to contain information about the two first decimal values, the average (0-100%) is multiplied by 100. +Other thing to note is the inclusion of the thresholds in the calculations. The thresholds are used to mark the range of values that the sensors could return once mounted on the car. This is so because the potentiometers are mechanically locked to a certain range of movement, meaning that not all values of the potentiometer a attainable. This is a very powerful and convenient way to detect if a sensor is fine or not and it is what the phase 1 of checks performs. +So the calculation of the final percentile averaged sensor value is given by: + +$`Final Avegare = \frac{Average - Lower Threshold}{Upper Threshold - Lower Threshold} * 10000`$ + +With this all the averages calculated the final checks are done. +The first one is to check if the values from both accelerator pedal sensors are implausible or not. As it is described in [Formula Student Rules implied with the Torque Encoder](/Torque encoder fs rules 2017 v1.1): +> Implausibility is defined as a deviation of more than ten percentage points pedal travel between any of the used APPSs or any failure according to T 10.3. + +Meaning that is the values of both sensors deviate more than 10% from each sensor then they are implausible. If that implausibility holds for more than 100 ms then the power to the motors must be shut down, or, in other words, the value of the accelerator pedal position must be 0. + +The detecting of the implausibility is pretty straight forward: if the absolute value of the difference between the two accelerator signals is greater than 1000 (10% * 100), than the sensors are implausible. If so, a flag is set by means of a status bit, and this triggers the tracking of the time the flag is set. If a flag holds for more than 100 ms than a override to the value of the accelerator sent by CAN is done, by changing this number to 0. When this happens, another flag by way of a bit is set indicating so. +If the flag is set but doesn't hold for that period of time, then the timer is stopped and reset. If an implausibility is detected again the process repeats itself. +The way the time is tracked can be seen by examining the code but it is not explained here at least for now. + +The next check done by the Torque Encoder is to see if the values of the brake pedal and the accelerator comply with [APPS / Brake Pedal Plausibility Check](/Torque-Encoder-FS-Rules-2017-v1.1#2-apps-brake-pedal-plausibility-check). The check itself is once again pretty straight forward: +1. Check if the value of the accelerator is higher than 25% and, at the same time, the brake is actuated. +2. If so, an implausibility flag is set by a status bit. +3. If the flag is set, check if the accelerator is lower than 5%. If so then reset the flag. Otherwise the flag stays set +If the flag is set, the value of the accelerator sent by CAN must be 0. + +This concludes all checks related to the pedal sensors. + +Another kind of surveillance done by the Torque Encoder is to monitor the AIR line. The AIR line is said to be fine if the line is closed. If at any point the line opens, then the AIR line is said to be cut. At this point something went wrong. The Torque Encoder monitors this line by checking if the line has opened before or after it. This is done with an octocoupler. If the value sent by the octocoupler is 5V, or 1 in digital form, then the AIR before the TE is fine. If the value is 0 then the line opened before the TE. In this case a flag indicating so is set. + diff --git a/low-voltage-system/torque-encoder-pcb.md b/low-voltage-system/torque-encoder-pcb.md new file mode 100644 index 0000000000000000000000000000000000000000..ade9f620823b0b6dbf1ea307baa346c0128c0508 --- /dev/null +++ b/low-voltage-system/torque-encoder-pcb.md @@ -0,0 +1,158 @@ +# Torque Encoder + +## Short description +This module acquires signals from the pedals sensors, which are: 2 accelerator pedal potenciometers, 1 brake pedal potenciometer and 2 brake pedal pressure sensors. Besides acquiring signals from pedals, the Torque Encoder monitors the AIR line. The Torque Encoder also makes sure that the signals from all the sensors connected to him comply with all FS rules. In particular it guarentees that T11.6.4 is +followed. + + +## Rules + ++ ### T 6.1. Brake System - General ++ **T 6.1.3** +“Brake-by-wire” systems are prohibited. + ++ **T 6.1.10** +The first 90% of the brake pedal travel may be used to regenerate brake energy without actuating the hydraulic brake system. The remaining brake pedal travel must directly actuate the hydraulic brake system, but brake energy regeneration may remain active. + ++ ### T 6.2. Brake Over-Travel Switch (BOTS) + ++ **T 6.2.1** +A brake pedal over-travel switch must be installed on the vehicle as part of the shutdown circuit, as in EV6 or CV4.1. This switch must be installed so that in the event of a failure in one or both of the brake circuits the brake pedal over travel will result in the shutdown circuit being opened. This must function for all possible brake pedal and brake balance settings. + ++ **T 6.2.2** +Repeated actuation of the switch must not close the shutdown circuit, and it must be designed so that the driver cannot reset it. + ++ **T 6.2.3.** +The brake over travel switch must be a mechanical single pole, single throw switch, commonly known as a two-position switch, push-pull or flip type. + ++ ### T 6.3. Brake Light + ++ **T 6.3.1.** +The vehicle must be equipped with one brake light that is illuminated if and only if the electric brake system is actuated, see EV2.2.2. + + ++ **T 6.3.2.** +The brake light must meet the following requirements: a red light with a black background; rectangular, triangular or near round shape; minimum shining surface of 15cm2 with even luminous intensity; clearly visible from the rear in very bright sunlight; when LED lights are used without a diffuser, they may not be more than 20mm apart and if a single line of LEDs is used, the minimum length is 150mm. + + ++ **T 6.3.3.** +In side view the brake light must be orientated vertical or near vertical and mounted between the wheel center line and driver’s shoulder level. Viewed from the back it should be positioned approximately at the vehicle’s centerline. + ++ ### T 11.6 Brake System Plausibility Device (BSPD) ++ **T 11.6.4.** +Standalone is defined as there is no additional functionality implemented on all required Printed Circuit Boards (PCBs). The interfaces must be reduced to the minimum necessary signals,i.e. power supply, required sensors and the shutdown circuit. Supply and sensor signals must not be routed through any other devices before entering the BSPD. + + ++ ### T 11.8 Accelerator Pedal Position Sensor (APPS) + ++ **T 11.8.2.** +The APPS must be actuated by a foot pedal. + ++ **T 11.8.3.** +Pedal travel is defined as percentage of travel from fully released position to a fully applied position where 0% is fully released and 100% is fully applied. + ++ **T 11.8.4.** +The foot pedal must return to the 0% position when not actuated. The foot pedal must have a positive stop preventing the mounted sensors from being damaged or overstressed. Two springs must be used to return the foot pedal to the 0% position and each spring must work when the other is disconnected. Springs in the APPS are not accepted as return springs. + ++ **T 11.8.5.** +At least two separate sensors must be used as APPSs. Separate is defined as not sharing supply or signal lines. + ++ **T 11.8.6.** +If analog sensors are used, they must have different transfer functions, each having a positive slope sense with either different gradients and/or offsets to the other(s). A short circuit between the signal lines must always result in an implausibility according to T11.8.9. + ++ **T 11.8.7.** +The APPS signals are SCSs, see T11.9. + ++ **T 11.8.8.** +If an implausibility occurs between the values of the APPSs and persists for more than 100ms the power to the motor(s) must be immediately shut down completely. It is not necessary to completely deactivate the tractive system, the motor controller(s) shutting down the power to the motor(s) is sufficient. + ++ **T 11.8.9.** +Implausibility is defined as a deviation of more than ten percentage points pedal travel between any of the used APPSs or any failure according to T11.9. + ++ **T 11.8.10.** +If three sensors are used, then in the case of an APPS implausibility, any two sensors that are plausible may be used to define the torque target and the 3rd APPS may be ignored. + ++ **T 11.8.11.** +It must be possible to seperately disconnect each APPS signal wire to check all functionalities. + ++ **T 11.8.12.** +A fully released accelerator pedal must result in a wheel torque of ≤0Nm. + +## Requirements + + +## Interactions +~ NÃO SEI O QUE ESCREVER AQUI ~ +* Module name (CAN) <- Another module + +## IO +### PPROG1 +* 1 - MCLR +* 2 - VCC +* 3 - GND +* 4 - PGD +* 5 - PGC + +### PSupply +* 1 - 24V +* 2 - GND +* 3 - 24V +* 4 - GND +* 5 - CAN2H +* 6 - CAN2L +* 7 - CAN2H +* 8 - CAN2L + +### T&BPS&BPr +* 1 - 4.5V +* 2 - TPS1 +* 3 - 0.5V +* 4 - 4.5V +* 5 - TPS2 +* 6 - 0.5V +* 7 - 4.5V +* 8 - BPS1 +* 9 - 0.5V +* 10 - 5V +* 11 - BPr1 +* 12 - GND +* 13 - 5V +* 14 - GND +* 15 - BPr2 +* 16 - + + +### AIR_LINE +* 1 - VCC +* 2 - GND +* 3 - AIR_OUT +* 4 - AIR_OUT + +## Hardware Specifications +* Power +* CAN +* ~NÃO SEI O QUE ESCREVER AQUI~ + + +## Description of functionality + +### AIR Detection +AIR signal (AIR_OUT) passes through a circuit where its state is monitored. The input of this circuit is the AIR_OUT signal and the output of this circuit is the AIR_DET which is the signal that contais information about the state of the AIR line. The fundamental component of this circuit is the optocoupler. The optocoupler has two parts: a led that emites light and a photosensitive device which detects light from the LED. Connected to the led of the optocoupler is the AIR_OUT signal. If through the led passes current aprox. over 10mA then the photosensitive device of the optocoupler starts to conduct current and the output (AIR_DET) is approximately 0V. On the contrary, if through the led passes current aprox. below 10mA then the photosensitive device stops conducting (turns off), and so the AIR_DET is approximately 5V. +The AIR_DET signal is an input of the microcontoller (PIC). + +### CAN Transmission +The Torque Encoder PCB is responsible to acquire data of 5 sensors (2 accelerator pedal potenciometers, 1 brake pedal potenciometer and 2 brake pedal pressure sensors). This data is transmitted via CAN. + +### Data processing +The Torque Encoder PCB is responsible to acquire data of 5 sensors ( 2 accelerator pedal potenciometers, 1 brake pedal potenciometer and 2 brake pedal pressure sensors). This data is processed by the microcontroller. + +### Circuit Protection +Both power supplies of the Torque Encoder PCB and its sensors, are connected to a circuit protection which its main porpose is to provide overcurrent and/or overvoltage protection. The circuit protection of the power supply of the TE PCB is composed of a fuse, providing overcurrent protection and a zener,providing overvoltage protection. +The circuit protection of the power supply of the sensors connected to the PCB is composed of fuses. + +In order to protect the MCU pins which are connected to the sensors, it was decided that resistors in series with the signal of the sensors would be enough to limit the current and so, protect the MCU of overcurrent events. + +## Public functions +### set_current_max + + diff --git a/low-voltage-system/torque-encoder.md b/low-voltage-system/torque-encoder.md new file mode 100644 index 0000000000000000000000000000000000000000..d93a24960be423a8c851fa6daf59243e450c8f5a --- /dev/null +++ b/low-voltage-system/torque-encoder.md @@ -0,0 +1,92 @@ +FS Rules relative to the Torque Encoder can be found in [Formula Student Rules 2017 V1.1](https://www.formulastudent.de/uploads/media/FS-Rules_2017_V1.1.pdf) and are the following: + +# General Technical Requirements +## Brake System +### 1. Brake System - General + +* The vehicle must be equipped with a braking system that acts on all four wheels and is +operated by a single control. + +* “Brake-by-wire” systems are prohibited. + +* The first 90 % of the brake pedal travel may be used to regenerate brake energy without actuating the hydraulic brake system. The remaining brake pedal travel must directly actuate the hydraulic brake system, but brake energy regeneration may remain active. + +### 2. Brake Over-Travel Switch (BOTS) + +* A brake pedal over-travel switch must be installed on the vehicle as part of the shutdown circuit, as in EV 5 or CV 4.1. This switch must be installed so that in the event of brake system failure such that the brake pedal over travels it will result in the shutdown circuit being opened. + +* Repeated actuation of the switch must must not close the shutdown circuit, and it must be designed so that the driver cannot reset it. + +* The switch must be implemented with analog components, not incorporating programmable +logic controllers, engine control units, or similar functioning digital controllers. + +* The brake over travel switch must be a mechanical single pole, single throw (commonly +known as a two-position) switch (push-pull or flip type). + +### 3. Brake Light + +* The vehicle must be equipped with one red brake light. The brake light itself must have a black background and a rectangular, triangular or near round shape with a minimum shining +surface of 15 cm2. The brake light must be clearly visible from the rear in very bright +sunlight. When LED lights are used without a diffuser, they may not be more than 20 mm +apart. If a single line of LEDs is used, the minimum length is 150 mm. + +* In side view the brake light must be orientated vertical or near vertical and mounted between the wheel centerline and driver’s shoulder level. Viewed from the back it should be positioned approximately at the vehicle’s centerline. + +## Electrical Components +### 1. Accelerator Pedal Position Sensor (APPS) + +* The APPS must be actuated by a foot pedal. + +* Pedal travel is defined as percent of travel from fully released position to a fully applied position where 0 % is fully released and 100 % is fully applied. + +* The foot pedal must return to the 0 % position when not actuated. The foot pedal must have a positive stop preventing the mounted sensors from being damaged or over-stressed. Two springs must be used to return the foot pedal to the 0 % position and each spring must work when the other is disconnected. Springs in the APPS are not accepted as return springs. + +* At least two separate sensors must be used as APPSs. Separate is defined as not sharing +supply or signal lines. + +* If analog sensors are used, they must have different transfer functions, each having a positive slope sense with either different gradients and/or offsets to the other(s). This will insure that even in case of a short circuit of the signal lines the APPSs will only agree at 0 % pedal position. + +* The APPS signal is a System Critical Signal, see T 10.3. + +* If an implausibility occurs between the values of the APPSs and persists for more than 100 ms the power to the motor(s) must be immediately shut down completely. It +is not necessary to completely deactivate the tractive system, the motor controller(s) +shutting down the power to the motor(s) is sufficient. + +* Implausibility is defined as a deviation of more than ten percentage points pedal travel +between any of the used APPSs or any failure according to T 10.3. + +* If three sensors are used, then in the case of an APPS implausibility, any two sensors that are plausible may be used to define the torque target and the 3rd APPS may be ignored. + +* Each APPS must have a separate detachable connector that enables a check of these functions by unplugging it. If not, an inline switchable break-out box must be made available during technical inspection that allows disconnection of each APPS signal. + +* A fully released accelerator pedal must result in a wheel torque of ≤0 Nm. + + +# Electric Vehicles +## Electric Powertrain +### 1. Brake System Encoder (BSE) + +* A BSE or switch to measure brake pedal position or brake system pressure must be fitted to check for plausibility. + +* The encoder must have a connector that allows disconnection of the encoder signal during +technical inspection. + +* The encoder signal is a system critical signal. + +### 2. APPS / Brake Pedal Plausibility Check + +* The power to the motors must be immediately shut down completely if the mechanical brakes are actuated and the APPS signals more than 25 % pedal travel at the same time. This must be demonstrated when the motor controllers are under load. + +* The motor power shut down must remain active until the APPS signals less than 5 % pedal +travel, no matter whether the brakes are still actuated or not. + +For any questions or more information regarding the FS Rules follow the link [Formula Student Rules 2017 V1.1](https://www.formulastudent.de/uploads/media/FS-Rules_2017_V1.1.pdf) or download the PDF +[FS-Rules_2017_V1.1.pdf](/uploads/93cad9fb1caf68eaddd9be35cca32fd3/FS-Rules_2017_V1.1.pdf) + + + + + +Tomás Carneiro + +September, 2017 \ No newline at end of file