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