Would you like to react to this message? Create an account in a few clicks or log in to continue.

You are not connected. Please login or register

Component rail.cpp determine the current delivered

2 posters

Go down  Message [Page 1 of 1]

feri



For example in the rail.cpp component within the code it is possible to know the current it is delivering, to be able to write it in paint.
Greetings

arcachofo

arcachofo

For example in the rail.cpp component within the code it is possible to know the current it is delivering,
Yes, you can just use Ohms law:
Output impedance = cero_doub = 1e-14.
Voltage = voltage drop = m_volt - m_pin[0]->getVoltage()

I = Voltage/1e-14

feri



Ok with Rail it works, while with the battery the voltage m_pin[0]->getVolt() (or m_pin[0]->getVoltage()) is always the same
even when I change the connected load.
The battery always delivers the nominal volts, for example 6V and varying the load can deliver up to 100A always with 6V.
I wish that when the current reaches a certain level the voltage drops like in a real battery.
Unfortunately analog electronics are too complex for me,
If you can give me some advice I would appreciate it.
Thank you
Greetings

arcachofo

arcachofo

Hi.
With Battery is basically the same, but you need to take the difference in voltage of the two pins, then proceed the same than with Rail (Battery also has cero_doub impedance).

double volt = m_pin[0]->getVolt() - m_pin[1]->getVolt();
double curr = (m_volt-volt)/cero_doub;

The problem is that it only works for relatively high currents (same with Rail), but it can still measure 100 mA in a 5 V Battery.

As a workaround, to measure to the microAmp or less, you can set the internal impedance to 1e-6 or so instead of cero_doub ( just replace cero_doub by 1e-6 in Battery::stamp() and calculations).

I wish that when the current reaches a certain level the voltage drops like in a real battery.
Yes, Battery should have a property to set the internal impedance... I will add it.

Sponsored content



Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum