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.
Diff: LEM_HAIS.cpp
- Revision:
- 1:3766b24dab80
- Child:
- 2:c865023c4b20
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/LEM_HAIS.cpp Tue Sep 19 16:30:52 2017 +0000
@@ -0,0 +1,98 @@
+/**
+ * @brief LEM_HAIS.h
+ * @details Current transducer. For the electronic measurement of currents:
+ * DC, AC, pulsed..., with galvanic separation between the primary
+ * circuit and the secondary circuit.
+ * Function file.
+ *
+ *
+ * @return NA
+ *
+ * @author Manuel Caballero
+ * @date 19/September/2017
+ * @version 19/September/2017 The ORIGIN
+ * @pre NaN.
+ * @warning NaN
+ * @pre This code belongs to Nimbus Centre ( http://www.nimbus.cit.ie ).
+ */
+
+#include "LEM_HAIS.h"
+
+
+LEM_HAIS::LEM_HAIS ( PinName OUTPUT, PinName VREF )
+ : _OUTPUT ( OUTPUT )
+ , _VREF ( VREF )
+{
+}
+
+
+LEM_HAIS::~LEM_HAIS()
+{
+}
+
+
+
+/**
+ * @brief LEM_HAIS_GetVoltage ( void )
+ *
+ * @details It gets both voltages, OUTPUT and Vref voltage.
+ *
+ * @param[in] VoltageDivider: If there is a voltage divider before the ADC pin ( if not VoltageDivider = 1 ).
+ * @param[in] ADC_Vref: Voltage reference for the ADC.
+ *
+ * @param[out] NaN.
+ *
+ *
+ * @return The actual voltages.
+ *
+ *
+ * @author Manuel Caballero
+ * @date 19/September/2017
+ * @version 19/September/2017 The ORIGIN
+ * @pre NaN.
+ * @warning NaN.
+ */
+LEM_HAIS::Vector_LEM_HAIS_voltage_t LEM_HAIS::LEM_HAIS_GetVoltage ( float VoltageDivider, float ADC_Vref )
+{
+ Vector_LEM_HAIS_voltage_t myAuxVoltage;
+
+ myAuxVoltage.VREF_Voltage = _VREF.read() * ADC_Vref;
+ myAuxVoltage.OUTPUT_Voltage = VoltageDivider * _OUTPUT.read() * ADC_Vref;
+
+
+ return myAuxVoltage;
+}
+
+
+
+/**
+ * @brief LEM_HAIS_CalculateCurrent ( Vector_LEM_HAIS_voltage_t ,uint32_t )
+ *
+ * @details It gets both voltages, OUTPUT and Vref voltage.
+ *
+ * @param[in] myVoltages: Both voltages, OUTPUT and Vref voltages.
+ * @param[in] myIPN: Primary Nominal rms Current.
+ *
+ * @param[out] NaN.
+ *
+ *
+ * @return The calculated current.
+ *
+ *
+ * @author Manuel Caballero
+ * @date 19/September/2017
+ * @version 19/September/2017 The ORIGIN
+ * @pre NaN.
+ * @warning NaN.
+ */
+LEM_HAIS::Vector_LEM_HAIS_current_t LEM_HAIS::LEM_HAIS_CalculateCurrent ( Vector_LEM_HAIS_voltage_t myVoltages, uint32_t myIPN )
+{
+ Vector_LEM_HAIS_current_t myAuxCurrent;
+
+
+ myAuxCurrent.Current = ( 8.0 / 5.0 ) * ( myVoltages.OUTPUT_Voltage - ( myVoltages.VREF_Voltage ) ) * myIPN;
+
+
+
+ return myAuxCurrent;
+}