Motion Control and Motor Drives

cancel
Showing results for 
Search instead for 
Did you mean: 

cannot read encoder

Our set up consists of a PCI-7334 connected to a UMI-7764.  One axis is wired to a MCB15081 Bipolar Microstep Driver driving a 200 step Lin Eng. motor. The same axis is wired to a US Digital S6D-1024-I encoder. 
I have some C++ code that will move the motor in open-loop mode.  That seems to work fine.  I am just trying to read the encoder output while the motor is turning.
Here is a code snippet:

//////////////////////////////////////////////////

//

// Start the motor.

//

if( !error )

{

status = flex_start(BOARD_ID, axis,

0 );

if( status != NIMC_noError )

{

error =

true;

printf(

"flex_start()\n");

nimcHandleError(&status);

}

}

//////////////////////////////////////////////////

//

// Wait until the motor move completes

//

if( !error )

{

status = WaitDone( &error, axis );

if( status != NIMC_noError )

{

error =

true;

printf(

"WaitDone()\n");

nimcHandleError(&status);

}

}

 
Here is the WaitDone() routine:

/****************************************************************

**

** WaitDone

**

** PURPOSE: Wait for a move to complete

**

** PASS: Nothing

**

** RETURN: FLEXFUNC containing status

**

** NOTES:

**

***************************************************************/

FLEXFUNC WaitDone(

bool *error, u8 axis )

{

int i = 0;

u16 axisStatus;

u16 moveComplete;

i32 status, encoder_counts, position;

do

{

i++;

//printf("%i\n", i);

axisStatus =

0;

moveComplete =

0;

// Check the move complete status

if( !(*error) )

{

status = flex_check_move_complete_status(BOARD_ID, axis,

0, &moveComplete);

if( status != NIMC_noError )

{

*error =

true;

printf(

"flex_check_move_complete_status()\n");

}

}

if( !(*error) )

{

status = flex_read_axis_status_rtn(BOARD_ID, axis, &axisStatus);

if( status != NIMC_noError )

{

*error =

true;

printf(

"flex_read_axis_status_rtn()\n");

}

}

if( !(*error) )

{

status = flex_read_encoder_rtn(BOARD_ID, (u8)(axis+ENC_OFFSET), &encoder_counts);

status = flex_read_pos_rtn(BOARD_ID, axis, &position);

if( status != NIMC_noError )

{

*error =

true;

printf(

"flex_read_encoder_rtn()\n");

printf(

"flex_read_pos_rtn()\n");

}

printf(

"Ecoder 0X%0X:\t%05i\tPos: %05i\r", (u8)(axis+ENC_OFFSET), encoder_counts, position );

//printf("Ecoder 0X%0X:\t%05i\r", (axis+ENC_OFFSET), i );

}

Sleep(

50);

}

while( !moveComplete && !(*error) &&

!( axisStatus & NIMC_FOLLOWING_ERROR_BIT ) &&

!( axisStatus & NIMC_AXIS_OFF_BIT ));

printf(

"\n");

return status;

}

<End Snippet>

 

The motor moves as expected.  I get no change in encoder_counts.  position displays as expected.

I'm sure there can be a whole host of reasons for this.  I suspect it is a wiring issue.  Is there anyhting in the configuration or set up I could be missing?

Any Thoughts?

 

Chris

 

 

 
 
Chris
0 Kudos
Message 1 of 5
(3,908 Views)
Because I'm a LV programer, I will not be able to help you changing your code. Anyway, IMHO the problem is not related to the programming language but to the mode of the movement. No encoder is supposed to be connected in open loop and therefore it will not be possible to read it in this mode.

Message Edité par JB le 05-23-2007 05:52 PM

0 Kudos
Message 2 of 5
(3,907 Views)
Shouldn't I be able to read the output from an ecoder regardless of whether it is used in the control loop?
0 Kudos
Message 3 of 5
(3,901 Views)
Yes, under certain conditions. See here.
0 Kudos
Message 4 of 5
(3,890 Views)

As I thought.

We were able to successfully read the encoder.  I was an wiring problem.

0 Kudos
Message 5 of 5
(3,888 Views)