Hier ist eine Schritt-für-Schritt-Liste mit Bildern und Code, die detailliert beschreibt, was ich getan habe:
- Ich habe einen Eingangskanal als Zeitsignal eingestellt. (Dewesoft benötigt mindestens einen Eingangskanal).

- Ich habe zwei Ausgangskanäle für den digitalen Ausgang 1 bzw. 2 eingestellt. Dann habe ich ein Oszilloskop an meine digitalen Ausgangspins angeschlossen und eine 5-V-Quelle sowohl an den Eingangs- als auch an den Ausgangspin angeschlossen, der für 5 V reserviert ist, um einfach alle meine Basen abzudecken.

- Ich habe meine digitalen Ausgangspins mit den Softwareausgängen verknüpft.

- Ich habe meinen Code innerhalb des Skelettcodes geschrieben, den Dewesoft als solchen anbietet:
Code: Select all
namespace bsc = Dewesoft::Math::Api::Basic;
class Module : public bsc::MathModule {
public:
Module();
~Module();
void configure() override;
void start() override;
void stop() override;
void clear() override;
// MY CODE BELOW THIS POINT
// Outputs have been mapped to Ctrl DO1 / Ctrl DO2 in A/D out
double PyroOneOut = 0.0; // "First Pyro's Output"
double PyroTwoOut = 0.0; // "Second Pyro's Out"
private:
// Timing parameters (ms)
const double t1_ms = 25.0; // DO1 fires at 25 ms
const double t2_ms = 50.0; // DO2 fires at 50 ms
const double width_ms = 5.0; // pulse width (will change if needed)
// Internal clock
std::chrono::steady_clock::time_point t0;
};
inline Module::Module() {
// Procedure which gets called the first thing a setup containing your module gets loaded
// or when the window with your module's setup form is closed.
// During this call only variables in 'published' struct are properly set.
// Useful for loading heavy libraries, reading from files, etc.
}
inline Module::~Module() {
// Called when your module is no longer used, giving you an opportunity to clean up.
}
inline void Module::configure() {
// Procedure used for overriding settings set in 'Configure' tab.
// Most useful for setting blockSizeInSamples, and output channel's units, axes, and
// expectedAsyncRates, based on the values of published variables.
PyroOneOut = 0.0;
PyroTwoOut = 0.0;
}
inline void Module::start() {
// Procedure which gets called at the start of a new measurement,
// strictly after Module::init(). Useful for setting initial values.
// Called at measurement start — zero outputs and arm the timer.
t0 = std::chrono::steady_clock::now();
PyroOneOut = 0.0;
PyroTwoOut = 0.0;
}
inline void Module::stop() {
// A converse of Module::start(), called when the measurement is stopped.
// Ensure outputs go LOW when stopping.
PyroOneOut = 0.0;
PyroTwoOut = 0.0;
}
inline void Module::clear() {
// Procedure which gets called whenever DEWESoft clears data in channels,
// e.g., when storing is started.
PyroOneOut = 0.0;
PyroTwoOut = 0.0;
}
inline void Module::calculate() {
// Procedure which gets called repeatedly whenever DEWESoft has exactly
// 'Block size' (or 1, in sample-based mode) number of new samples in input channels.
using namespace std::chrono;
const double ms =
duration(steady_clock::now() - t0).count();
const bool do1_high = (ms >= t1_ms) && (ms < (t1_ms + width_ms));
const bool do2_high = (ms >= t2_ms) && (ms < (t2_ms + width_ms));
PyroOneOut = do1_high ? 1.0 : 0.0;
PyroTwoOut = do2_high ? 1.0 : 0.0;
}
Mobile version