added preliminary AD5791 driver

This commit is contained in:
Markus Rosenstihl 2015-11-25 16:39:34 +00:00
parent cbd1017a95
commit a02eb49fa1
3 changed files with 171 additions and 1 deletions

View File

@ -10,7 +10,7 @@ CXXFLAGS=-O0 -g -Wall -Wshadow -pedantic
CXXCPPFLAGS=-I. -I.. CXXCPPFLAGS=-I. -I..
#ToDo PBP-HS3-test.exe #ToDo PBP-HS3-test.exe
SUBDIRS:=SpinCore-PulseBlaster SpinCore-PulseBlaster24Bit SpinCore-PulseBlasterDDSIII PTS-Synthesizer Eurotherm-2000Series dummy Spectrum-MI40xxSeries Spectrum-M2i40xxSeries Tecmag-DAC20 SUBDIRS:=SpinCore-PulseBlaster SpinCore-PulseBlaster24Bit SpinCore-PulseBlasterDDSIII PTS-Synthesizer Eurotherm-2000Series dummy Spectrum-MI40xxSeries Spectrum-M2i40xxSeries Tecmag-DAC20 DAC-AD5791
ifeq ($(shell /bin/uname -o),Cygwin) ifeq ($(shell /bin/uname -o),Cygwin)
SUBDIRS+=TiePie-HS3 Datel-PCI416 SUBDIRS+=TiePie-HS3 Datel-PCI416
endif endif

View File

@ -21,6 +21,7 @@ MACHINES = \
magnexgrad_backend_dds \ magnexgrad_backend_dds \
PFGcore$(EXEEXT) \ PFGcore$(EXEEXT) \
fc2_backend$(EXEEXT) \ fc2_backend$(EXEEXT) \
fc2_backend_AD5791$(EXEEXT) \
fc1neu_backend$(EXEEXT) \ fc1neu_backend$(EXEEXT) \
bg_backend \ bg_backend \
Mobilecore$(EXEEXT) \ Mobilecore$(EXEEXT) \
@ -32,6 +33,7 @@ DRV_SPC_MI40xx = ../drivers/Spectrum-MI40xxSeries/Spectrum-MI40xxSeries.a
DRV_SPC_M2i40xx = ../drivers/Spectrum-M2i40xxSeries/Spectrum-M2i40xxSeries.a DRV_SPC_M2i40xx = ../drivers/Spectrum-M2i40xxSeries/Spectrum-M2i40xxSeries.a
DRV_PTS = ../drivers/PTS-Synthesizer/PTS.o DRV_PTS = ../drivers/PTS-Synthesizer/PTS.o
DRV_DAC20 = ../drivers/Tecmag-DAC20/DAC20.o DRV_DAC20 = ../drivers/Tecmag-DAC20/DAC20.o
DRV_AD5791 = ../drivers/DAC-AD5791/AD5791.o
DRV_PB_24BIT = ../drivers/SpinCore-PulseBlaster24Bit/SpinCore-PulseBlaster24Bit.o DRV_PB_24BIT = ../drivers/SpinCore-PulseBlaster24Bit/SpinCore-PulseBlaster24Bit.o
DRV_PB_DDSIII = ../drivers/SpinCore-PulseBlasterDDSIII/SpinCore-PulseBlasterDDSIII.o DRV_PB_DDSIII = ../drivers/SpinCore-PulseBlasterDDSIII/SpinCore-PulseBlasterDDSIII.o
DRV_PB = ../drivers/SpinCore-PulseBlaster/SpinCore-PulseBlaster.o DRV_PB = ../drivers/SpinCore-PulseBlaster/SpinCore-PulseBlaster.o
@ -90,6 +92,9 @@ $(DRV_PTS):
$(DRV_DAC20): $(DRV_DAC20):
$(MAKE) -C ../drivers/Tecmag-DAC20 DAC20.o $(MAKE) -C ../drivers/Tecmag-DAC20 DAC20.o
$(DRV_AD5791):
$(MAKE) -C ../drivers/DAC-AD5791 AD5791.o
$(DRV_SPC_MI40xx): $(DRV_SPC_MI40xx):
$(MAKE) -C ../drivers/Spectrum-MI40xxSeries Spectrum-MI40xxSeries.o $(MAKE) -C ../drivers/Spectrum-MI40xxSeries Spectrum-MI40xxSeries.o
@ -247,6 +252,21 @@ fc2_backend.o: fc2_backend.cpp \
../drivers/SpinCore-PulseBlaster24Bit/SpinCore-PulseBlaster24Bit.h ../drivers/SpinCore-PulseBlaster/SpinCore-PulseBlaster.h ../drivers/SpinCore-PulseBlaster/PulseBlasterProgram.h ../drivers/Tecmag-DAC20/DAC20.h\ ../drivers/SpinCore-PulseBlaster24Bit/SpinCore-PulseBlaster24Bit.h ../drivers/SpinCore-PulseBlaster/SpinCore-PulseBlaster.h ../drivers/SpinCore-PulseBlaster/PulseBlasterProgram.h ../drivers/Tecmag-DAC20/DAC20.h\
../core/stopwatch.h ../drivers/Spectrum-MI40xxSeries/Spectrum-MI40xxSeries.h ../core/stopwatch.h ../drivers/Spectrum-MI40xxSeries/Spectrum-MI40xxSeries.h
# fc2 with AD5791
fc2_backend_AD5791$(EXEEXT): fc2_backend_AD5791.o \
hardware.o \
$(DRV_SPC_MI40xx) \
$(DRV_PTS) \
$(DRV_AD5791) \
$(DRV_PB_24BIT) $(DRV_PB) $(DRV_PB_PROG) \
../core/core.a
@$(LINK_MACHINE) $^ $(LIBS) -o $@ -lpthread
fc2_backend_AD5791.o: fc2_backend_AD5791.cpp \
../drivers/SpinCore-PulseBlaster24Bit/SpinCore-PulseBlaster24Bit.h ../drivers/SpinCore-PulseBlaster/SpinCore-PulseBlaster.h ../drivers/SpinCore-PulseBlaster/PulseBlasterProgram.h ../drivers/DAC-AD5791/AD5791.h\
../core/stopwatch.h ../drivers/Spectrum-MI40xxSeries/Spectrum-MI40xxSeries.h
berta: berta.o \ berta: berta.o \
hardware.o \ hardware.o \
$(DRV_SPC_MI40xx) \ $(DRV_SPC_MI40xx) \

View File

@ -0,0 +1,150 @@
/* **************************************************************************
Author: Achim Gaedke
Created: June 2004
****************************************************************************/
#include "machines/hardware.h"
#include "core/core.h"
#include "drivers/DAC-AD5791/AD5791.h"
#include "drivers/PTS-Synthesizer/PTS.h"
#include "drivers/Spectrum-MI40xxSeries/Spectrum-MI40xxSeries.h"
#include "drivers/SpinCore-PulseBlaster24Bit/SpinCore-PulseBlaster24Bit.h"
/**
\defgroup fc2machine FC2 NMR Spectrometer
\ingroup machines
Uses Spincore Pulseblaster 24 Bit and Spectrum MI4021, and some DACs
\par Starting the hardware
This procedure should assure the correct initialisation of the hardware:
\li Switch off main switches of SpinCore Pulseblaster and Computer (the main switch of the computer is at the rear)
\li Switch on Computer and start Windows or linux
@{
*/
/**
line 0 for gate
line 1 for pulse
line 22 for trigger
line 3 free
*/
class FC2_hardware: public hardware
{
SpinCorePulseBlaster24Bit* my_pulseblaster;
SpectrumMI40xxSeries* my_adc;
public:
FC2_hardware()
{
ttlout trigger;
trigger.id = 0;
trigger.ttls = 0x400000; /* line 22 */ //
my_adc = new SpectrumMI40xxSeries(trigger);
my_pulseblaster = new SpinCorePulseBlaster24Bit(0, 1e8, 0x800000);
PTS* my_pts = new PTS_latched(0); // ID of PTS_analogout 0
the_fg = my_pts;
the_pg = my_pulseblaster;
the_adc = my_adc;
/* AD5791* dac;
dac = new AD5791(1);
dac->set_latch_bit(17);
list_dacs.push_back(dac);
dac = new AD5791(2);
dac->set_latch_bit(19);
list_dacs.push_back(dac);
*/
}
result* experiment(const state& exp)
{
result* r = NULL;
for (size_t tries = 0; r == NULL && core::term_signal == 0 && tries < 102; ++tries)
{
state* work_copy = exp.copy_flat();
if (work_copy == NULL)
return new error_result(1, "could create work copy of experiment sequence");
try
{
if (the_fg != NULL)
the_fg->set_frequency(*work_copy);
if (the_adc != NULL)
the_adc->set_daq(*work_copy);
experiment_prepare_dacs(work_copy);
// the pulse generator is necessary
my_pulseblaster->run_pulse_program_w_sync(*work_copy, my_adc->get_sample_clock_frequency());
// wait for pulse generator
the_pg->wait_till_end();
// after that, the result must be available
if (the_adc != NULL)
r = the_adc->get_samples();
else
r = new adc_result(1, 0, NULL);
}
catch (const RecoverableException &e)
{
r = new error_result(1, e.what());
}
delete work_copy;
if (core::quit_signal != 0)
break;
}
return r;
}
virtual ~FC2_hardware()
{
if (the_adc != NULL)
delete the_adc;
if (the_pg != NULL)
delete the_pg;
if (the_fg != NULL)
delete the_fg;
}
};
/**
\brief brings standard core together with the Mobile NMR hardware
*/
class FC2_core: public core
{
std::string the_name;
public:
FC2_core(const core_config& conf) :
core(conf),
the_name("FC2 core")
{
the_hardware = new FC2_hardware();
}
virtual const std::string& core_name() const
{
return the_name;
}
};
/**
@}
*/
int main(int argc, const char** argv)
{
int return_result = 0;
try
{
core_config my_conf(argv, argc);
// setup input and output
FC2_core my_core(my_conf);
// start core application
my_core.run();
}
catch (const DamarisException& e)
{
fprintf(stderr, "%s\n", e.what());
return_result = 1;
}
return return_result;
}