Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
LEM_HAIS.cpp@1:3766b24dab80, 2017-09-19 (annotated)
- Committer:
- mcm
- Date:
- Tue Sep 19 16:30:52 2017 +0000
- Revision:
- 1:3766b24dab80
- Child:
- 2:c865023c4b20
Both function and header files are almost ready
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mcm | 1:3766b24dab80 | 1 | /** |
mcm | 1:3766b24dab80 | 2 | * @brief LEM_HAIS.h |
mcm | 1:3766b24dab80 | 3 | * @details Current transducer. For the electronic measurement of currents: |
mcm | 1:3766b24dab80 | 4 | * DC, AC, pulsed..., with galvanic separation between the primary |
mcm | 1:3766b24dab80 | 5 | * circuit and the secondary circuit. |
mcm | 1:3766b24dab80 | 6 | * Function file. |
mcm | 1:3766b24dab80 | 7 | * |
mcm | 1:3766b24dab80 | 8 | * |
mcm | 1:3766b24dab80 | 9 | * @return NA |
mcm | 1:3766b24dab80 | 10 | * |
mcm | 1:3766b24dab80 | 11 | * @author Manuel Caballero |
mcm | 1:3766b24dab80 | 12 | * @date 19/September/2017 |
mcm | 1:3766b24dab80 | 13 | * @version 19/September/2017 The ORIGIN |
mcm | 1:3766b24dab80 | 14 | * @pre NaN. |
mcm | 1:3766b24dab80 | 15 | * @warning NaN |
mcm | 1:3766b24dab80 | 16 | * @pre This code belongs to Nimbus Centre ( http://www.nimbus.cit.ie ). |
mcm | 1:3766b24dab80 | 17 | */ |
mcm | 1:3766b24dab80 | 18 | |
mcm | 1:3766b24dab80 | 19 | #include "LEM_HAIS.h" |
mcm | 1:3766b24dab80 | 20 | |
mcm | 1:3766b24dab80 | 21 | |
mcm | 1:3766b24dab80 | 22 | LEM_HAIS::LEM_HAIS ( PinName OUTPUT, PinName VREF ) |
mcm | 1:3766b24dab80 | 23 | : _OUTPUT ( OUTPUT ) |
mcm | 1:3766b24dab80 | 24 | , _VREF ( VREF ) |
mcm | 1:3766b24dab80 | 25 | { |
mcm | 1:3766b24dab80 | 26 | } |
mcm | 1:3766b24dab80 | 27 | |
mcm | 1:3766b24dab80 | 28 | |
mcm | 1:3766b24dab80 | 29 | LEM_HAIS::~LEM_HAIS() |
mcm | 1:3766b24dab80 | 30 | { |
mcm | 1:3766b24dab80 | 31 | } |
mcm | 1:3766b24dab80 | 32 | |
mcm | 1:3766b24dab80 | 33 | |
mcm | 1:3766b24dab80 | 34 | |
mcm | 1:3766b24dab80 | 35 | /** |
mcm | 1:3766b24dab80 | 36 | * @brief LEM_HAIS_GetVoltage ( void ) |
mcm | 1:3766b24dab80 | 37 | * |
mcm | 1:3766b24dab80 | 38 | * @details It gets both voltages, OUTPUT and Vref voltage. |
mcm | 1:3766b24dab80 | 39 | * |
mcm | 1:3766b24dab80 | 40 | * @param[in] VoltageDivider: If there is a voltage divider before the ADC pin ( if not VoltageDivider = 1 ). |
mcm | 1:3766b24dab80 | 41 | * @param[in] ADC_Vref: Voltage reference for the ADC. |
mcm | 1:3766b24dab80 | 42 | * |
mcm | 1:3766b24dab80 | 43 | * @param[out] NaN. |
mcm | 1:3766b24dab80 | 44 | * |
mcm | 1:3766b24dab80 | 45 | * |
mcm | 1:3766b24dab80 | 46 | * @return The actual voltages. |
mcm | 1:3766b24dab80 | 47 | * |
mcm | 1:3766b24dab80 | 48 | * |
mcm | 1:3766b24dab80 | 49 | * @author Manuel Caballero |
mcm | 1:3766b24dab80 | 50 | * @date 19/September/2017 |
mcm | 1:3766b24dab80 | 51 | * @version 19/September/2017 The ORIGIN |
mcm | 1:3766b24dab80 | 52 | * @pre NaN. |
mcm | 1:3766b24dab80 | 53 | * @warning NaN. |
mcm | 1:3766b24dab80 | 54 | */ |
mcm | 1:3766b24dab80 | 55 | LEM_HAIS::Vector_LEM_HAIS_voltage_t LEM_HAIS::LEM_HAIS_GetVoltage ( float VoltageDivider, float ADC_Vref ) |
mcm | 1:3766b24dab80 | 56 | { |
mcm | 1:3766b24dab80 | 57 | Vector_LEM_HAIS_voltage_t myAuxVoltage; |
mcm | 1:3766b24dab80 | 58 | |
mcm | 1:3766b24dab80 | 59 | myAuxVoltage.VREF_Voltage = _VREF.read() * ADC_Vref; |
mcm | 1:3766b24dab80 | 60 | myAuxVoltage.OUTPUT_Voltage = VoltageDivider * _OUTPUT.read() * ADC_Vref; |
mcm | 1:3766b24dab80 | 61 | |
mcm | 1:3766b24dab80 | 62 | |
mcm | 1:3766b24dab80 | 63 | return myAuxVoltage; |
mcm | 1:3766b24dab80 | 64 | } |
mcm | 1:3766b24dab80 | 65 | |
mcm | 1:3766b24dab80 | 66 | |
mcm | 1:3766b24dab80 | 67 | |
mcm | 1:3766b24dab80 | 68 | /** |
mcm | 1:3766b24dab80 | 69 | * @brief LEM_HAIS_CalculateCurrent ( Vector_LEM_HAIS_voltage_t ,uint32_t ) |
mcm | 1:3766b24dab80 | 70 | * |
mcm | 1:3766b24dab80 | 71 | * @details It gets both voltages, OUTPUT and Vref voltage. |
mcm | 1:3766b24dab80 | 72 | * |
mcm | 1:3766b24dab80 | 73 | * @param[in] myVoltages: Both voltages, OUTPUT and Vref voltages. |
mcm | 1:3766b24dab80 | 74 | * @param[in] myIPN: Primary Nominal rms Current. |
mcm | 1:3766b24dab80 | 75 | * |
mcm | 1:3766b24dab80 | 76 | * @param[out] NaN. |
mcm | 1:3766b24dab80 | 77 | * |
mcm | 1:3766b24dab80 | 78 | * |
mcm | 1:3766b24dab80 | 79 | * @return The calculated current. |
mcm | 1:3766b24dab80 | 80 | * |
mcm | 1:3766b24dab80 | 81 | * |
mcm | 1:3766b24dab80 | 82 | * @author Manuel Caballero |
mcm | 1:3766b24dab80 | 83 | * @date 19/September/2017 |
mcm | 1:3766b24dab80 | 84 | * @version 19/September/2017 The ORIGIN |
mcm | 1:3766b24dab80 | 85 | * @pre NaN. |
mcm | 1:3766b24dab80 | 86 | * @warning NaN. |
mcm | 1:3766b24dab80 | 87 | */ |
mcm | 1:3766b24dab80 | 88 | LEM_HAIS::Vector_LEM_HAIS_current_t LEM_HAIS::LEM_HAIS_CalculateCurrent ( Vector_LEM_HAIS_voltage_t myVoltages, uint32_t myIPN ) |
mcm | 1:3766b24dab80 | 89 | { |
mcm | 1:3766b24dab80 | 90 | Vector_LEM_HAIS_current_t myAuxCurrent; |
mcm | 1:3766b24dab80 | 91 | |
mcm | 1:3766b24dab80 | 92 | |
mcm | 1:3766b24dab80 | 93 | myAuxCurrent.Current = ( 8.0 / 5.0 ) * ( myVoltages.OUTPUT_Voltage - ( myVoltages.VREF_Voltage ) ) * myIPN; |
mcm | 1:3766b24dab80 | 94 | |
mcm | 1:3766b24dab80 | 95 | |
mcm | 1:3766b24dab80 | 96 | |
mcm | 1:3766b24dab80 | 97 | return myAuxCurrent; |
mcm | 1:3766b24dab80 | 98 | } |