Jump to content

Warning: SystemC-AMS: Initialization for tracing of: v_supercap failed set wave to 0


Recommended Posts

Dear Forum, 

I receive the error stated in the title when I simulate with systemC. More precisely, the whole error message is as follows:

Quote

Warning: SystemC-AMS: Initialization for tracing of: v_supercap failed  set wave to 0

In file: ../../../../../../src/scams/impl/util/tracing/sca_trace_object_data.cpp:174
In process: sca_implementation_0.cluster_process_0 @ 0 s

Warning: SystemC-AMS: Initialization for tracing of: e_supercap failed  set wave to 0

In file: ../../../../../../src/scams/impl/util/tracing/sca_trace_object_data.cpp:174
In process: sca_implementation_0.cluster_process_0 @ 0 s

Warning: SystemC-AMS: Initialization for tracing of: soc_supercap failed  set wave to 0

In file: ../../../../../../src/scams/impl/util/tracing/sca_trace_object_data.cpp:174
In process: sca_implementation_0.cluster_process_0 @ 0 s
SOC is less than or equal to 1%: @990365 s

My supercapacitor class consists of a parent class, supercap that instantiates and connects the two child classes, supercap_tdf and supercap_eln . The problem only occurs when I use the supercap class, when I use only the supercap_eln alone I do not get this error. For this reason, I think the problem is related to the other two classes but I couldn't figure out what causes it.

This is not the behaviour I expect as there is a current flowing to the input of the supercapacitor (proven when I use the supercap_eln alone). I would expect the supercap class to output relevant v_supercap, e_supercap, soc_supercap not only 0s at the beginning and then nothing.

I attached the whole project as a zip file. I will also include the most important files below for reference.

Please help me solve this problem.

I also include a quote of the sim trace file and I attach the whole error log as a txt file.

=========================================================================================================================

supercap_eln.h

#ifndef SUPERCAP_ELN_H
#define SUPERCAP_ELN_H

#include <systemc-ams.h>

SC_MODULE(supercap_eln)
{
    public:
        // Interface and internal components declaration
        sca_tdf::sca_in<double> pI_in; // Requested supercapacitor current
        sca_tdf::sca_out<double> pV_out; // Provided supercapacitor voltage

        // transformers bw ELN and TDF
        sca_eln::sca_tdf::sca_isource iin;
        sca_eln::sca_tdf::sca_vsink vout;

        // ELN components
        sca_eln::sca_c C_sc; // Capacitance (for supercap)
        sca_eln::sca_r R_l; // Leakage resistance
        sca_eln::sca_r R_s; // Series resistance

        // Constructor
        supercap_eln( sc_core::sc_module_name nm, double c_par, double r_l_par, double r_s_par):
            pI_in("pI_in"),
            pV_out("pV_out"),
            iin("iin"),
            vout("vout"),
            C_sc("C_sc", c_par),
            R_l("R_l", r_l_par),
            R_s("R_s", r_s_par),
            node_top("node_top"),
            node_mid("node_mid"),
            gnd("gnd")
        {
            iin.inp(pI_in);
            iin.p(node_top);
            iin.n(gnd);

            vout.p(node_top);
            vout.n(gnd);
            vout.outp(pV_out);

            C_sc.p(node_top);
            C_sc.n(node_mid);

            R_l.p(node_top);
            R_l.n(node_mid);

            R_s.p(node_mid);
            R_s.n(gnd);

            cout << "Supercapacitor created, C:" << C_sc.value << ", R_l:" << R_l.value << ", R_s:" << R_s.value << endl;
        }

    private:
    
        // internal node and ref node
        sca_eln::sca_node node_top, node_mid;
        sca_eln::sca_node_ref gnd;
};

#endif

supercap_tdf.h:

#ifndef SUPERCAP_TDF_H
#define SUPERCAP_TDF_H

#include <systemc-ams.h>
#include "config.h"

SC_MODULE(supercap_tdf)
{
    public:
        // Ports
        sca_tdf::sca_in<double> pV_in; //incoming voltage

        sca_tdf::sca_out<double> pV_out; //forwarded voltage
        sca_tdf::sca_out<double> pE_out; //current energy
        sca_tdf::sca_out<double> pSoC_out; //state of charge

        supercap_tdf( sc_core::sc_module_name nm, double c_par): 
                                pV_in("pV_in"),
                                pV_out("pV_out"), 
                                pE_out("pE_out"),
                                pSoC_out("pSoC_out"),
                                C(c_par),
                                MAX_E(0.5 * C * VREF_BUS * VREF_BUS),
                                SoC_val(SOC_INIT),
                                E_val(SoC_val * MAX_E) 
        {
            cout << "Supercapacitor TDF created, C:"<< C << ", MAX_E:" << MAX_E << ", SoC:" << SoC_val << ", E:" << E_val << endl;

        }

        void set_attributes();
        void initialize();
        void processing();

    private:
        const double C;
        const double MAX_E;
        double SoC_val;
        double E_val;
};

#endif

supercap_tdf.cpp

#include "supercap_tdf.h"

void supercap_tdf::set_attributes()
{
    pE_out.set_timestep(SIM_STEP, sc_core::SC_SEC);
    pSoC_out.set_timestep(SIM_STEP, sc_core::SC_SEC);
    pV_out.set_timestep(SIM_STEP, sc_core::SC_SEC);

    pE_out.set_delay(1);
    pSoC_out.set_delay(1);
    pV_out.set_delay(1);
}

void supercap_tdf::initialize(){}

void supercap_tdf::processing()
{

    double tmp_v;

    tmp_v = pV_in.read();
    cout << "Voltage value: " << tmp_v << " @" << sc_time_stamp() << endl;

    if(tmp_v <= 0)
    {
        cout << "ERROR: 0 or less voltage value" << " @" << sc_time_stamp() << "Value V=" << tmp_v << endl;
        sc_stop();
    }
    if(tmp_v > VREF_BUS)
    {
        cout << "Voltage is greatar than VREF_BUS" << " @" << sc_time_stamp() << "Value V=" << tmp_v << endl;
        tmp_v = VREF_BUS;
    }

    pV_out.write(tmp_v);

    E_val = 0.5 * C * tmp_v * tmp_v;
    
    pE_out.write(E_val);

    SoC_val = E_val / MAX_E;
    
    if(SoC_val <= 0.01)
    {
        cout << "SC SOC is less than or equal to 1%:" << " @" << sc_time_stamp() << endl;
        sc_stop();
    }

    pSoC_out.write(SoC_val);

}

 

supercap.h:

#ifndef SUPERCAP_H
#define SUPERCAP_H

#include <systemc-ams.h>
#include "supercap_eln.h"
#include "supercap_tdf.h"
#include "config.h"

SC_MODULE(supercap)
{
    public:
        sca_tdf::sca_in<double> pI_in; // Battery current
        sca_tdf::sca_out<double> pV_out; // Voltage
        sca_tdf::sca_out<double> pE_out; // Energy
        sca_tdf::sca_out<double> pSoC_out; // State of Charge

        // connecting signals
        sca_tdf::sca_signal<double> sVoltage;

        supercap_eln eln_module;
        supercap_tdf tdf_module;

        supercap( sc_core::sc_module_name nm, double c_par = 3.0, double r_l_par = 500000.0, double r_s_par = 0.08): 
                                pI_in("pI_in"),
                                pV_out("pV_out"),
                                pE_out("pE_out"),
                                pSoC_out("pSoC_out"),
                                eln_module("eln_module", c_par, r_l_par, r_s_par),
                                tdf_module("tdf_module", c_par)
        {

            eln_module.pI_in(pI_in);
            eln_module.pV_out(sVoltage);

            tdf_module.pV_in(sVoltage);
            tdf_module.pV_out(pV_out);
            tdf_module.pE_out(pE_out);
            tdf_module.pSoC_out(pSoC_out);
        }

};

#endif

main.cpp

#include <systemc-ams.h>

#include "battery.h"
#include "bus.h"
#include "converter_battery.h"
#include "mcu.h"
#include "air_quality_sensor.h"
#include "supercap.h"

int sc_main(int argc, char* argv[])
{
    // Instantiate signals
    sca_tdf::sca_signal<double> i_batt, v_batt, soc;
    sca_tdf::sca_signal<double> i_air_quality_sensor; 
    sca_tdf::sca_signal<double> i_mcu;
    sca_tdf::sca_signal<double> i_tot_batt, i_tot_sc;

    //sca_tdf::sca_signal<double> i_supercap;
    sca_tdf::sca_signal<double> v_supercap;
    sca_tdf::sca_signal<double> e_supercap;
    sca_tdf::sca_signal<double> soc_supercap;

    // Instantiate modules
    bus bus("bus");
    battery battery("battery");
    converter_battery converter_battery("converter_battery");
    mcu mcu("mcu");
    air_quality_sensor air_quality_sensor("air_quality_sensor");

    supercap supercap_module("supercap");

    supercap_module.pI_in(i_tot_sc);
    supercap_module.pV_out(v_supercap);
    supercap_module.pE_out(e_supercap);
    supercap_module.pSoC_out(soc_supercap);

    // Connect signals to modules
    battery.i_batt(i_batt);
    battery.v_batt(v_batt);
    battery.soc(soc);

    converter_battery.i_bus(i_tot_batt);
    converter_battery.v_batt(v_batt);
    converter_battery.i_batt(i_batt);
    
    air_quality_sensor.i(i_air_quality_sensor);
    mcu.i(i_mcu);
    

    bus.i_mcu(i_mcu);
    bus.i_tot_batt(i_tot_batt);
    bus.i_tot_sc(i_tot_sc);
    bus.i_air_quality_sensor(i_air_quality_sensor);
    
    // define simulation file
    sca_util::sca_trace_file* atf = sca_util::sca_create_tabular_trace_file("sim_trace.txt");

    // the following signals will be traced. Comment any signal you don't want to trace     
    sca_util::sca_trace(atf, i_tot_sc, "i_tot_sc" );
    sca_util::sca_trace(atf, v_supercap, "v_supercap" );
    sca_util::sca_trace(atf, e_supercap, "e_supercap" );
    sca_util::sca_trace(atf, soc_supercap, "soc_supercap" );

    cout<<"The simulation starts!"<<endl;

    sc_start(SIM_LEN, sc_core::SC_SEC); // Set the simulation length

    cout<<"The simulation ends @ "<<sc_time_stamp()<<endl;

    sca_util::sca_close_tabular_trace_file(atf);

    return 0;
}

sim_trace file output:

Quote

%time i_tot_sc v_supercap e_supercap soc_supercap
0 4.8202 0 0 0
1 4.8202 0 0 0
2 4.8202 0 0 0
3 4.8202 0 0 0
4 4.8202 0 0 0
5 4.8202 0 0 0

 

supercap-project.zip console.txt

Edited by Balint Bujtor
I was able to eliminate some sources of the error.
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...