shithub: leaf

Download patch

ref: 31c7e637a85158a126420bf9128dd102a495a12e
parent: f39097166d74311950348fa3205bed7838ba3b25
author: Jeff Snyder <jeff@snyderphonics.com>
date: Wed Sep 25 18:44:41 EDT 2019

added WDF resistor

--- /dev/null
+++ b/LEAF/Inc/leaf-WDF.h
@@ -1,0 +1,28 @@
+/*
+ * leaf-WDF.h
+ *
+ *  Created on: Sep 25, 2019
+ *      Author: jeffsnyder
+ */
+
+#ifndef LEAF_INC_LEAF_WDF_H_
+#define LEAF_INC_LEAF_WDF_H_
+
+
+typedef struct _tWDFresistor
+{
+	float port_resistance;
+	float port_conductance;
+	float electrical_resistance;
+	float incident_wave;
+	float reflected_wave;
+} tWDFresistor;
+
+void tWDFresistor_init(tWDFresistor* const r, float electrical_resistance);
+float tWDFresistor_getPortResistance(tWDFresistor* const r);
+void tWDFresistor_setIncidentWave(tWDFresistor* const r, float incident_wave);
+float tWDFresistor_getVoltage(tWDFresistor* const r);
+float tWDFresistor_getCurrent(tWDFresistor* const r);
+
+
+#endif /* LEAF_INC_LEAF_WDF_H_ */
--- /dev/null
+++ b/LEAF/Src/leaf-WDF.c
@@ -1,0 +1,32 @@
+/*
+ * leaf-WDF.c
+ *
+ *  Created on: Sep 25, 2019
+ *      Author: jeffsnyder
+ */
+
+
+void tWDFresistor_init(tWDFresistor* const r, float electrical_resistance)
+{
+	r->port_resistance = electrical_resistance;
+	r->port_conductance = 1.0f / electrical_resistance;
+	r->electrical_resistance = electrical_resistance;
+	r->incident_wave = 0.0f;
+	r->reflected_wave = 0.0f;
+}
+float tWDFresistor_getPortResistance(tWDFresistor* const r)
+{
+	return r->port_resistance;
+}
+void tWDFresistor_setIncidentWave(tWDFresistor* const r, float incident_wave)
+{
+	r->incident_wave = incident_wave;
+}
+float tWDFresistor_getVoltage(tWDFresistor* const r)
+{
+	return ((r->incident_wave * 0.5f) + (r->reflected_wave * 0.5f));
+}
+float tWDFresistor_getCurrent(tWDFresistor* const r)
+{
+	return (((r->incident_wave * 0.5f) - (r->reflected_wave * 0.5f)) / r->port_conductance);
+}