ccs waveform vdd

Signed-off-by: James Cherry <cherry@parallaxsw.com>
This commit is contained in:
James Cherry 2023-05-09 19:42:53 -07:00
parent c2e2846f4c
commit 9bda639d9c
2 changed files with 21 additions and 15 deletions

View File

@ -513,6 +513,7 @@ public:
const Table1 *currentWaveform(float slew, const Table1 *currentWaveform(float slew,
float cap); float cap);
float referenceTime(float slew); float referenceTime(float slew);
void setVdd(float vdd);
static bool checkAxes(TableTemplate *tbl_template); static bool checkAxes(TableTemplate *tbl_template);
private: private:
@ -530,7 +531,7 @@ private:
Table1Seq current_waveforms_; Table1Seq current_waveforms_;
FloatTable voltage_times_; FloatTable voltage_times_;
Table1 *ref_times_; Table1 *ref_times_;
float voltage_max_; float vdd_;
static constexpr size_t voltage_waveform_step_count_ = 20; static constexpr size_t voltage_waveform_step_count_ = 20;
}; };

View File

@ -1572,9 +1572,6 @@ tableVariableUnit(TableAxisVariable variable,
return nullptr; return nullptr;
} }
////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
OutputWaveforms::OutputWaveforms(TableAxisPtr slew_axis, OutputWaveforms::OutputWaveforms(TableAxisPtr slew_axis,
@ -1587,7 +1584,8 @@ OutputWaveforms::OutputWaveforms(TableAxisPtr slew_axis,
rf_(rf), rf_(rf),
current_waveforms_(current_waveforms), current_waveforms_(current_waveforms),
voltage_times_(current_waveforms.size()), voltage_times_(current_waveforms.size()),
ref_times_(ref_times) ref_times_(ref_times),
vdd_(0.0)
{ {
} }
@ -1631,6 +1629,12 @@ OutputWaveforms::referenceTime(float slew)
return ref_times_->findValue(slew); return ref_times_->findValue(slew);
} }
void
OutputWaveforms::setVdd(float vdd)
{
vdd_ = vdd;
}
float float
OutputWaveforms::voltageTime(float slew, OutputWaveforms::voltageTime(float slew,
float cap, float cap,
@ -1674,7 +1678,7 @@ Table1
OutputWaveforms::voltageWaveform(float slew, OutputWaveforms::voltageWaveform(float slew,
float cap) float cap)
{ {
float volt_step = voltage_max_ / voltage_waveform_step_count_; float volt_step = vdd_ / voltage_waveform_step_count_;
FloatSeq *times = new FloatSeq; FloatSeq *times = new FloatSeq;
FloatSeq *volts = new FloatSeq; FloatSeq *volts = new FloatSeq;
for (size_t v = 0; v <= voltage_waveform_step_count_; v++) { for (size_t v = 0; v <= voltage_waveform_step_count_; v++) {
@ -1693,7 +1697,7 @@ OutputWaveforms::voltageTime1(float voltage,
float cap) float cap)
{ {
FloatSeq *voltage_times = voltageTimes(wave_index, cap); FloatSeq *voltage_times = voltageTimes(wave_index, cap);
float volt_step = voltage_max_ / voltage_waveform_step_count_; float volt_step = vdd_ / voltage_waveform_step_count_;
size_t volt_idx = voltage / volt_step; size_t volt_idx = voltage / volt_step;
float time0 = (*voltage_times)[volt_idx]; float time0 = (*voltage_times)[volt_idx];
float time1 = (*voltage_times)[volt_idx + 1]; float time1 = (*voltage_times)[volt_idx + 1];
@ -1701,17 +1705,16 @@ OutputWaveforms::voltageTime1(float voltage,
return time; return time;
} }
// Integrate current waveform to find voltage waveform.
// i = C dv/dt
FloatSeq * FloatSeq *
OutputWaveforms::voltageTimes(size_t wave_index, OutputWaveforms::voltageTimes(size_t wave_index,
float cap) float cap)
{ {
FloatSeq *voltage_times = voltage_times_[wave_index]; FloatSeq *voltage_times = voltage_times_[wave_index];
if (voltage_times == nullptr) { if (voltage_times == nullptr) {
// Integrate current waveform to find voltage waveform.
// i = C dv/dt
FloatSeq volts; FloatSeq volts;
Table1 *currents = current_waveforms_[wave_index]; Table1 *currents = current_waveforms_[wave_index];
TableAxisPtr time_axis = currents->axis1(); TableAxisPtr time_axis = currents->axis1();
float prev_time = time_axis->axisValue(0); float prev_time = time_axis->axisValue(0);
float prev_current = currents->value(0); float prev_current = currents->value(0);
@ -1728,11 +1731,11 @@ OutputWaveforms::voltageTimes(size_t wave_index,
prev_time = time; prev_time = time;
prev_current = current; prev_current = current;
} }
voltage_max_ = volts[volts.size() - 1];
// Sample voltage waveform a uniform intervals to speed up time to voltage lookup. // Sample the voltage waveform at uniform intervals to speed up
// voltage time lookup.
voltage_times = new FloatSeq; voltage_times = new FloatSeq;
float volt_step = voltage_max_ / voltage_waveform_step_count_; float volt_step = vdd_ / voltage_waveform_step_count_;
size_t i = 0; size_t i = 0;
float time0 = time_axis->axisValue(i); float time0 = time_axis->axisValue(i);
float volt0 = volts[i]; float volt0 = volts[i];
@ -1741,7 +1744,7 @@ OutputWaveforms::voltageTimes(size_t wave_index,
float volt1 = volts[i]; float volt1 = volts[i];
for (size_t v = 0; v <= voltage_waveform_step_count_; v++) { for (size_t v = 0; v <= voltage_waveform_step_count_; v++) {
float volt3 = v * volt_step; float volt3 = v * volt_step;
while (volt3 > volt1 && i < volts.size()) { while (volt3 > volt1 && i < volts.size() - 1) {
time0 = time1; time0 = time1;
volt0 = volt1; volt0 = volt1;
i++; i++;
@ -1749,6 +1752,8 @@ OutputWaveforms::voltageTimes(size_t wave_index,
volt1 = volts[i]; volt1 = volts[i];
} }
float time3 = time0 + (time1 - time0) * (volt3 - volt0) / (volt1 - volt0); float time3 = time0 + (time1 - time0) * (volt3 - volt0) / (volt1 - volt0);
if (time3 < 0.0)
printf("luse\n");
//printf("%.2f %.2e\n", volt3, time3); //printf("%.2f %.2e\n", volt3, time3);
voltage_times->push_back(time3); voltage_times->push_back(time3);
} }