From cff3ac6553df1c56aea26a1ace562018f5397c46 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Thu, 12 Apr 2007 15:54:04 +1000 Subject: [PATCH] Added code for counter source filtering r1848 | dcl | 2007-04-12 15:54:04 +1000 (Thu, 12 Apr 2007) | 2 lines --- site_ansto/hardsup/Monitor/device.c | 7 ++++ site_ansto/hardsup/Monitor/device.h | 2 ++ site_ansto/hardsup/Monitor/display.c | 9 +++++ site_ansto/hardsup/Monitor/hware.c | 49 +++++++++++++++++++++++++++- site_ansto/hardsup/Monitor/hware.h | 16 +++++++++ site_ansto/hardsup/Monitor/params.c | 13 ++++++++ site_ansto/hardsup/Monitor/params.h | 2 ++ 7 files changed, 97 insertions(+), 1 deletion(-) diff --git a/site_ansto/hardsup/Monitor/device.c b/site_ansto/hardsup/Monitor/device.c index daf62848..2b7c9e9d 100644 --- a/site_ansto/hardsup/Monitor/device.c +++ b/site_ansto/hardsup/Monitor/device.c @@ -605,6 +605,13 @@ int device_poll(DEVICE* device) HWARE_TEST(hware_source(device->private_data, device->source)); } + /* set the line filter */ + if (device->filter != pp->filter) + { + device->filter = pp->filter; + HWARE_TEST(hware_filter(device->private_data, device->filter)); + } + /* drive the output line */ if (device->output_line != pp->output_line) { diff --git a/site_ansto/hardsup/Monitor/device.h b/site_ansto/hardsup/Monitor/device.h index 060d85dc..87e8eb3f 100644 --- a/site_ansto/hardsup/Monitor/device.h +++ b/site_ansto/hardsup/Monitor/device.h @@ -95,6 +95,8 @@ typedef struct counter_t PARAMETERS params; /** active value of parameter source */ int source; + /** active value of parameter filter */ + int filter; /** active value of parameter output_line */ int output_line; struct device_private_t* private_data; diff --git a/site_ansto/hardsup/Monitor/display.c b/site_ansto/hardsup/Monitor/display.c index 5aad9038..98cee84d 100644 --- a/site_ansto/hardsup/Monitor/display.c +++ b/site_ansto/hardsup/Monitor/display.c @@ -210,6 +210,15 @@ void put_form(int n) add_option(&buffer, "Clock_2 100KHz", "2", pp->source == 2); add_option(&buffer, "Clock_3 80MHz", "3", pp->source == 3); add_select_end(&buffer); + add_select_begin(&buffer, "Filter", "filter"); + add_option(&buffer, "None", "0", pp->filter == 0); + add_option(&buffer, "Filter_1 SyncT3", "1", pp->filter == 1); + add_option(&buffer, "Filter_2 5000nS", "2", pp->filter == 2); + add_option(&buffer, "Filter_3 1000nS", "3", pp->filter == 3); + add_option(&buffer, "Filter_4 500nS", "4", pp->filter == 4); + add_option(&buffer, "Filter_5 100nS", "5", pp->filter == 5); + add_option(&buffer, "Filter_6 25nS", "6", pp->filter == 6); + add_select_end(&buffer); add_select_begin(&buffer, "Output Line", "output"); add_option(&buffer, "Disabled", "disabled", pp->output_line == 0); add_option(&buffer, "Enabled", "enabled", pp->output_line == 1); diff --git a/site_ansto/hardsup/Monitor/hware.c b/site_ansto/hardsup/Monitor/hware.c index b79c34db..a19b2fa4 100644 --- a/site_ansto/hardsup/Monitor/hware.c +++ b/site_ansto/hardsup/Monitor/hware.c @@ -389,6 +389,53 @@ int hware_source(pHWARE hware, int value) return error; } +/* + * Select the filter + */ +int hware_filter(pHWARE hware, int value) +{ + int error = 0; +#ifdef REGISTER_LEVEL_PROGRAMMING + CARD* pci = hware->card; + int src = 0; + if (value > 0 && value < 7) + src = value; + switch (hware->channel_number) + { + case 0: + pci->tio_1->IO_Pin_38_39_Configuration_Register.writeIO_Filter_39_Select(src); + break; + case 1: + pci->tio_1->IO_Pin_34_35_Configuration_Register.writeIO_Filter_35_Select(src); + break; + case 2: + pci->tio_1->IO_Pin_30_31_Configuration_Register.writeIO_Filter_31_Select(src); + break; + case 3: + pci->tio_1->IO_Pin_26_27_Configuration_Register.writeIO_Filter_27_Select(src); + break; + case 4: + pci->tio_2->IO_Pin_22_23_Configuration_Register.writeIO_Filter_23_Select(src); + break; + case 5: + pci->tio_2->IO_Pin_18_19_Configuration_Register.writeIO_Filter_19_Select(src); + break; + case 6: + pci->tio_2->IO_Pin_14_15_Configuration_Register.writeIO_Filter_15_Select(src); + break; + case 7: + pci->tio_2->IO_Pin_10_11_Configuration_Register.writeIO_Filter_11_Select(src); + break; + } +#else + // TODO + // DAQmxGetDevCIPhysicalChans + // DAQmxSetCICountEdgesTerm + //Error: +#endif + return error; +} + /* * Set the output line corresponding to the counter */ @@ -460,7 +507,7 @@ void hware_sync(pHWARE hware, bool external) { #if REGISTER_LEVEL_PROGRAMMING //CARD* pci = hware->card; - // TODO + // TODO RLP #else int error = 0; char device_name[40]; diff --git a/site_ansto/hardsup/Monitor/hware.h b/site_ansto/hardsup/Monitor/hware.h index 1567adc3..7cc2e4ee 100644 --- a/site_ansto/hardsup/Monitor/hware.h +++ b/site_ansto/hardsup/Monitor/hware.h @@ -54,6 +54,22 @@ int hware_read(pHWARE hware, HWARE_VALUE* value); */ int hware_source(pHWARE hware, int value); +/** + * Select the filter + * + * \param hware pointer to opaque private data structure + * \param value filter selector + * 0 Input signal unchanged + * 1 Input synchronised to timebase 3 (80Mhz on PCI-6602) + * 2 Digital filter 100 * timebase 1 (2.5-5uS) + * 3 Digital filter 20 * timebase 1 (0.5-1uS) + * 4 Digital filter 10 * timebase 1 (250-500nS) + * 5 Digital filter 2 * timebase 1 ( 50-100nS) + * 6 Digital filter 2 * timebase 3 (12.5-25nS) + * else same as zero + */ +int hware_filter(pHWARE hware, int value); + /** * Enables external output on designated DIO line * diff --git a/site_ansto/hardsup/Monitor/params.c b/site_ansto/hardsup/Monitor/params.c index 2a225aa3..a81a89f0 100644 --- a/site_ansto/hardsup/Monitor/params.c +++ b/site_ansto/hardsup/Monitor/params.c @@ -18,6 +18,7 @@ #define CMD_OUTPUT 13 #define CMD_SYNC 14 #define CMD_SOURCE 15 +#define CMD_FILTER 16 #define TXT_DIRECTION "DIRECTION" #define TXT_SCAN "SCAN" @@ -34,6 +35,7 @@ #define TXT_OUTPUT "OUTPUT" #define TXT_SYNC "SYNC" #define TXT_SOURCE "SOURCE" +#define TXT_FILTER "FILTER" static struct param_command_t { int cmd; @@ -54,6 +56,7 @@ static struct param_command_t { {CMD_OUTPUT, TXT_OUTPUT}, {CMD_SYNC, TXT_SYNC}, {CMD_SOURCE, TXT_SOURCE}, + {CMD_FILTER, TXT_FILTER}, {0, NULL} }; #define NUM_CMDS ((int) ((sizeof(param_command)/sizeof(param_command[0])))) @@ -191,6 +194,16 @@ bool param_set(pPARAMETERS pp, char* name, char* value) pp->source = 0; dbg_printf(0, "=>%d\n", pp->source); break; + case CMD_FILTER: + result = true; + dbg_printf(0, "Filter=%d", pp->filter); + pp->filter = strtol(value, NULL, 10); + if (pp->filter < 0) + pp->filter = 0; + else if (pp->filter > 6) + pp->filter = 0; + dbg_printf(0, "=>%d\n", pp->filter); + break; case CMD_SYNC: result = true; dbg_printf(0, "Sync=%s", pp->sync ? "External" : "Internal"); diff --git a/site_ansto/hardsup/Monitor/params.h b/site_ansto/hardsup/Monitor/params.h index 26433ad2..fbd2bb01 100644 --- a/site_ansto/hardsup/Monitor/params.h +++ b/site_ansto/hardsup/Monitor/params.h @@ -43,6 +43,8 @@ typedef struct parameter_t bool sync; /** source 0:default, 1:timebase_1, 2:timebase_2, 3:timebase_3 */ int source; + /** filter 0:none, 1:sync_TB3, 2:5uS, 3:1uS, 4:500nS, 5:100nS, 6:25nS */ + int filter; } PARAMETERS, *pPARAMETERS;