Motion Control and Motor Drives

cancel
Showing results for 
Search instead for 
Did you mean: 

Onboard Wait On High Speed Capture

I would like for an onboard program to wait for a high speed capture signal from a trigger input. Unfortunately, I have not had success with the flex_wait_on_condition function; it has always timed out before detecting the event. However, calls to the function flex_read_hs_cap_status identify that the high speed capture line is indeed toggling faster than the 3 second timeout. I use the following sequence of functions to configure the high speed capture:

flex_configure_hs_capture(m_BoardID, NIMC_AXIS2, NIMC_HS_LOW_TO_HIGH_EDGE, 0);
flex_begin_store(m_BoardID, ProgramNumber);
flex_enable_hs_capture(m_BoardID, NIMC_AXIS2, NIMC_TRUE);
flex_wait_on_condition(m_BoardID, NIMC_AXIS2, NIMC_WAIT, NIMC_CONDITION_HIGH_SPEED_CAPTURE, 0, 0,
NIMC_MATCH_ANY, 30, 0);
.
.
.
flex_end_store(m_BoardID, ProgramNumber);

Axis 2 is configured as a open loop stepper axis with encoder resource 2 mapped to it.

Any thoughts as to why this wouldn't work?

Thanks!
0 Kudos
Message 1 of 3
(3,411 Views)
Hello,
I would suggest using a jump to label on condition function along with an insert label. The flow of code would be Insert Label 1, Jump to Label Two when High Speed Capture Condition is met, otherwise jump to condition one. Once you receive a high speed capture you need to enable your high speed capture to use it again.

Regards

Russell Blake
Applications Engineering
National Instruments
Director of Engineering
G Systems, www.gsystems.com
Certified LabVIEW Architect
Certified LabVIEW Embedded Systems Developer
Certified Professional Instructor
GCentral
0 Kudos
Message 2 of 3
(3,410 Views)
Thanks for the suggestion. It seems to work fairly well, although there is some delay between the trigger event and the execution of the critical section of code.

Are you aware of a method to speed up execution of an on-board program? The critical section of code in the attached program fragment takes about 4ms to execute. With the added delay of the polled high speed capture line, I am limited to a ~150 Hz loop. I would like to increase the execution time by about twice.

Also, a command from the host computer seems to preempt the on-board program, causing it to take up to ten times as long to complete. Is there a way to set the priority of the on-board program task above host communication?

Thanks for you assistance,

Mike

flex_insert_program_label(m_BoardID, LABEL_LOOP_START); // main program loop
flex_read_hs_cap_status(m_BoardID, NIMC_AXIS3, DATA_HS_CAP_STATUS); // check if high speed capture triggered
flex_and_vars(m_BoardID, DATA_HS_CAP_STATUS, DATA_HS_CAP_STATUS_MASK, DATA_HS_CAP_STATUS_MASKED); // AND high speed capture with trigger 3 mask
flex_jump_label_on_condition(m_BoardID, NIMC_AXIS3, NIMC_CONDITION_EQUAL, NIMC_FALSE, NIMC_FALSE, NIMC_MATCH_ANY, LABEL_LOOP_START); // if trigger 3 not triggered, jump to main program loop
// Critical Section Code >>>
flex_set_breakpoint_momo(m_BoardID, NIMC_AXIS3, 0x08, 0x00, 0xFF); // set digital output high
flex_enable_hs_capture(m_BoardID, NIMC_AXIS3, NIMC_TRUE); // re-enable the high-speed capture
flex_read_adc(m_BoardID, NIMC_ADC1, DATA_ANALOG_INPUT_1); // read the analog input
flex_write_buffer(m_BoardID, ANALOG_INPUT_BUFFER, 1, 0, &UselessLong, DATA_WRITE_TO_BUFFER_NUM_PTS); // write the analog input to the buffer
flex_read_buffer(m_BoardID, VELOCITY_PROFILE_BUFFER, 1, DATA_VELOCITY_CMD); // read the next velocity profile point
flex_load_velocity(m_BoardID, NIMC_AXIS3, UselessLong, DATA_VELOCITY_CMD); // set the axis velocity
flex_start(m_BoardID, NIMC_AXIS3, 0); // update the velocity by calling start
flex_set_breakpoint_momo(m_BoardID, NIMC_AXIS3, 0x00, 0x08, 0xFF); // set digital output low
// <<< Critical Section Code
flex_jump_label_on_condition(m_BoardID, NIMC_AXIS3, NIMC_CONDITION_TRUE, NIMC_FALSE, NIMC_FALSE, NIMC_MATCH_ANY, LABEL_LOOP_START); // jump to main program loop
flex_end_store(m_BoardID, ProgramNumber); // stop program store
0 Kudos
Message 3 of 3
(3,410 Views)