Added code for counter source filtering

r1848 | dcl | 2007-04-12 15:54:04 +1000 (Thu, 12 Apr 2007) | 2 lines
This commit is contained in:
Douglas Clowes
2007-04-12 15:54:04 +10:00
parent f95142b219
commit cff3ac6553
7 changed files with 97 additions and 1 deletions

View File

@@ -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)
{

View File

@@ -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;

View File

@@ -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);

View File

@@ -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];

View File

@@ -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
*

View File

@@ -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");

View File

@@ -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;