Jump to content
  • 0

MCC 172 Synchronous scan question


skycraper3

Question

Hello,

 

I have 2 MCC 172 DAQs and would like to synchronous scan now, but there are only examples with external triggers. So I modified existing example like attached code, and test without external trigger. But it seem DAQs have different start time (Figure 1). I used BNC distributor so blue and green graph on Figure 1 have same input. Additionally, blue graph is data from device #0 (Master).

Is there any way to start DAQs simultaneously without external trigger or just code is wrong?

 

Cheers,

Lee

 

 

Figure_1.png

multi_hat_synchronous_scan_test.py

Edited by skycraper3
Link to comment
Share on other sites

12 answers to this question

Recommended Posts

  • 0

Hey Lee,

I've reached out to the design engineer regarding the use of external trigger and your original assumption is true. Although the two boards share the sample clock they need an external trigger to provide the initial synchronization. 

You need a trigger signal to synchronize the sampling start between the two 172s, but it can be done without an external source or wiring.  Set both 172s up as trigger slaves, start a scan on both boards, then create a rising edge on the Pi GPIO pin that is used to share the trigger (GPIO 5).

mcc172_a_in_clock_config_write using SOURCE_SLAVE

mcc172_a_in_clock_config_write using SOURCE_MASTER

mcc172_trigger_config using SOURCE_SLAVE

mcc172_trigger_config using SOURCE_SLAVE

Toggle GPIO5 to trigger both without adding any external wires.

Best regards,

John

 

Link to comment
Share on other sites

  • 0

Hello,

The EXTCLOCK scan option will instruct the board to wait until the clock signal appears. Therefore, it must be programmed first with this  option. Use the Option Flag DEFAULT for the master board. When it is started, the scan clock signal is applied to the other board effectively starting it too. For example, replace the start scan for...loop and instead use something like the following:

chan_mask = chan_list_to_mask(chansl[1])

hats(1).a_in_scan_start(chan_mask, samples_per_channel, OptionFlags.EXTCLOCK)

chan_mask = chan_list_to_mask(chansl[0])

hats(0).a_in_scan_start(chan_mask, samples_per_channel, OptionFlags.DEFAULT)

If you wish to run continuously, use OptionFlags.CONTINUOUS | OptionFlags.EXTCLOCK and instead of DEFAULT use OptionFlags.CONTINUOUS

You should also get rid of the lines that have to do with setting up the external trigger.

Forgive me if there is Python mistake, I'm better with C programming:-o)

Best regards,

John

Link to comment
Share on other sites

  • 0

Hello and good catch,

I apologize for the misinformation.

The MCC 172 is a little different, when compared to our other products, in that it has the function a_in_clock_config_write that sets the clock direction. Because of this, you don't use the OptionsFlags.EXTCLOCK and instead use just DEFAULT or CONTINUOUS with a_in_scan_start.  Start the slave board first then the master and it should all fall into to place. 

Best regards,

John

Link to comment
Share on other sites

  • 0

Hi again,

I changed codes to call start slave board first, but result is not so different just Master DAQ is faster than Slave DAQ.

Codes like:

master_hat.iepe_config_write()
slave_hat.iepe_config_write()

slave_hat.a_in_clock_config_write()
master_hat.a_in_clock_config_write()

synced = False
while not synced:
	(_, _, synced) = master_hat.a_in_clock_config_read() # for get "synced" (i also tried this for slave_hat)

slave_hat.a_in_scan_start() # with option Continuous
master_hat.a_in_scan_start() # with option Continuous

read_and_display_data_loop()

hats.a_in_scan_stop()
hats.a_in_scan_cleanup()

When I call a_in_clock_config_read() during read function, both HATs saying 'synchronized=True'... I'm confused now.

Link to comment
Share on other sites

  • 0

Hello,

I found this statement in the programming guide for the clock config write:

If you change the clock configuration on one device after configuring the master, then the data will no longer be in sync. The devices cannot detect this and will still report that they are synchronized. 

Try reversing the order for the clock config write functions and configure the slave is first. Let me know if it solves the issue, but if does not attach your script and I'll investigate.

Best regards,
John

Link to comment
Share on other sites

  • 0

Hello,

Tried changing clock configuring order of HATs and I even tried with C examples, but still 2~4 samples difference was detected. I'm just guessing there were only external trigger examples because these hardware issue :/

Attached file is code that i modified running option and skipping trigger routine for test.

Sincerely,

Lee

multi_hat_synchronous_scan.c

Edited by skycraper3
Link to comment
Share on other sites

  • 0

Hey Lee,

I've order a second MCC 172 but it won't arrive until next week - I'm hoping Monday.  In the meantime, I modified the code - attached.

MASTER is defined as zero, so I added a SLAVE defined as 1 and changed the clock config write and ain scan start sequence to reflect SLAVE first. 

    // Configure the slave clock first
    result = mcc172_a_in_clock_config_write(address[SLAVE],SOURCE_SLAVE, sample_rate);
    // Configure the master clock last so the clocks are synchronized
    result = mcc172_a_in_clock_config_write(address[MASTER],SOURCE_MASTER, sample_rate);
    STOP_ON_ERROR(result);

.....

    // Start the scans
    //for (device = 0; device < DEVICE_COUNT; device++)
    //{
        result = mcc172_a_in_scan_start(address[SLAVE], chan_mask[SLAVE],samples_per_channel, options);
        result = mcc172_a_in_scan_start(address[MASTER], chan_mask[MASTER],samples_per_channel, options);
        STOP_ON_ERROR(result);
    //}

I couldn't run it but it did compile. Let me know if you see improvement otherwise I'll plan on testing early next week.

Best regards,
John

 

1a_multi_hat_synchronous_scan.c

Link to comment
Share on other sites

  • 0

Thanks for reply, I ran modified code but no difference 😅 (added mcc172_iepe_config_write() because I'm using IEPE mic)

These are my setup,

 

latest Raspberry Pi OS 32bit, SPI, I2C On, using external ports - Keyboard/Mouse/HDMI

2 MCC 172 HATs, jumper installed A0 on slave HAT (upper board) - followed instruction (Installing the DAQ HAT board — MCC DAQ HAT Library 1.0.0 documentation)

IEPE sensor input with BNC splitter at master HAT (under board) CH0 and slave HAT (upper board) CH0, BNC splitter likes this
(Actually signal without splitter seems have difference so I decided to gives same input to DAQs)

10-32 to BNC were connected with provided connectors and same length of each cables

Edited by skycraper3
Link to comment
Share on other sites

  • 0

Hi

I have the same daqhat setting and observed the same problem. In my case, when I start from a fresh power on, above solution  works. But if I stop the scan and then restart again, the synchronization between two hats is lost. I have to power off and on to have synch again. I tried to reset the hats by mcc172_reset() but it is not successful and returns -1. Is there any way to have synch between hats without  a need for power off?

Thanks

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...