Driver Development Kit (DDK)

cancel
Showing results for 
Search instead for 
Did you mean: 

Controlling the derection of Counting for M Series

Hello
 
According to "DAQ M Series User Manual", there is a description about the controlling the direction of counting at page 7-4 Chapter 7: Counters .
It says there are 3 ways to configure the counting direction like as the following:
- Always count up
- Always count down
- Count up when the counter n B input is high; count down when it is low.
 
I started to test this with M series example gpctex1.cpp.
I could understand the first two but couldn't the last one.
I suppose making the last one success, you need to make the B input, and I did like this:
 
board->G0_Input_Select.setG0_Source_Select(1);    //PFI1 for that I  currently use PCI 6229(37pin)
                                                                                      // Assume that PFI1 is the counting source
 board->G0_Input_Select.setG0_Source_Polarity(0); //rising=0 
...
board->G0_Input_Select.setG0_Gate_Select(2);       // PFI2 for B input
board->G0_Input_Select.setG0_Gate_Select_Load_Source(0);
board->G0_Input_Select.setG0_Output_Polarity(0); //active high=0
board->G0_Input_Select.setG0_OR_Gate(0);
board->G0_Input_Select.flush();
...
// To make the input B, I guess the followings are needed.
board->G0_MSeries_ABZ.setG0_A_Select(1);
board->G0_MSeries_ABZ.setG0_B_Select(2);
board->G0_MSeries_ABZ.flush();
 
board->G0_Command.setG0_Up_Down(tTIO::tG0_Command::kG0_Up_DownSoftware_Up);
 
I guess the line above would make the counting direction decided but I don't know how to make this direction changed depending on the B inputs.
I'm pleased that anyone could tell me how to change the counting direction between up and down, depending on the B inputs.
 
Thank you in advance.
0 Kudos
Message 1 of 4
(7,104 Views)

Hi Ash-

You need to set the G0_Up_Down bitfield to either kG0_Up_DownHardware or kG0_Up_DownHardware_Gate.  Your current setting relies on software and ignores the hardware up/down signals you have selected.  More info can be found in the TIO RLP manual.

Hopefully this helps-

Tom W
National Instruments
0 Kudos
Message 2 of 4
(7,103 Views)
Hello Tom
 
Thank you for your advice and the documentation. I could find that the 660x document tells me a lot about TIO that seems like being compatible with the one for M series. According to the document, it surely says that I need to make the Up_Down as 2(Up/Down Hardware),  if I configure the up/down direction by I O pin. I understand that.
Then I changed as so and the result was like the following:
 
Up_Down = 2: Hardware
 While PFI2 input is low(0), it counts down but, if PFI2 input is high, it never counts to any direction.
 
Up_Down = 3: Hardware_Gate
 While PFI2 input is low(0), it counts up but, if PFI2 input is high, it never counts.
 
I would be pleased if you could point out where the problem is in my code:
 
 
0 Kudos
Message 3 of 4
(7,090 Views)

Hello Tom

I've been doing something stupid. I should have illustrated the sample gpctex2.cpp. That is exactly what I have needed to test with.

I found that for the up/down counting on B input, you don't need to configure the Gate select:

// board->G0_Input_Select.setG0_Gate_Select(2); //PFI1=2 ---> This is wrong
 board->G0_Input_Select.setG0_Gate_Select(31); // Low=31 --> should gate to low
 board->G0_Input_Select.setG0_Gate_Select_Load_Source(0);
 board->G0_Input_Select.setG0_Output_Polarity(0); //active high=0
 board->G0_Input_Select.setG0_OR_Gate(0);
 board->G0_Input_Select.flush();

And you shouldn't configure source input as A

 board->G0_MSeries_ABZ.setG0_A_Select(1); --> this was wrong and should be commented
 board->G0_MSeries_ABZ.setG0_B_Select(2);
 board->G0_MSeries_ABZ.flush();

I'm sorry for this fuss. I could get efficient information about counter/timer anyway.

Thanks

Ash

 

Message 4 of 4
(7,087 Views)