patrickokeeffe Posted October 29, 2010 Share Posted October 29, 2010 I'm monitoring the continuous output from a Hamamatsu PMT via RS-232. The PMT controls triggering and sends data for 100-10ms readings giving a sampling rate very very close to but not precisely 1 Hz. Since the timestamps are marked upon arrival, the frequency is further distorted by tiny, varying delays in serial comm. All the other I/O for this setup is done through a Labjack however so its timing is DAQFactory-controlled and sampling is done on nice intervals. This timing difference is enough that my aligned logging set doesn't align too well. The daily files typically end up a few records shy of 86400 and missing records are distributed throughout the day. It's also common to see two entries for a single second with different fractions of a second that should have been merged together or to have multiple PMT records aligned to the same second (then I lose a record). Before deployment, I tried different alignment threshold values and figured it was unavoidable so we've logged an 'all points' dataset too & used it to repair the aligned sets - this method is tedious and means I'm the only one doing it. The easiest solution would be to change the timing of the PMT daq so its timestamps are identical to the other channels. It does have poll-response capabilities but using them requires a lower integration time (<1s) and that deflates my signal. To ensure all records are received before the next poll is sent would also require a fairly large listen window, probably a full quarter-second so poll-response is not really an option. What else could be done to ensure 86400pnts/day and no record-squishing? Would it be crazy to have a sequence mirroring my PMT channel into a dummy channel & rounding the timestamps to whole sec. values? Or to have a Test device "Lag5s" with 1hz timing that 'samples' PMT_channel[now-5s]? Any suggestions welcome & appreciated Link to comment Share on other sites More sharing options...
AzeoTech Posted October 30, 2010 Share Posted October 30, 2010 Well, first, how are you actually reading this PMT? From a sequence? It sounds like you are reading 100 values and then averaging them into a 1hz signal, but its not clear where this is done. Link to comment Share on other sites More sharing options...
patrickokeeffe Posted November 1, 2010 Author Share Posted November 1, 2010 The PMT module has its own crystal-controlled counter/timer which sets the effective integration time as a sum of 10-ms intervals. It defaults to 100 intervals for a 1-second measurement time and outputs automatically via RS-232 after receiving the character "C" + a carriage return. Link to comment Share on other sites More sharing options...
patrickokeeffe Posted November 4, 2010 Author Share Posted November 4, 2010 I guess I didn't really answer the question, sorry.. The PMT has its own separate protocol file so it's not based on sequence timing. I'm just listening to the serial line after sending the 'continuous output' command while the PMT does the integration and reports once/second. When the data actually shows up is not exactly 1Hz though and that seems to be the root of the "timing" issue I described. Link to comment Share on other sites More sharing options...
AzeoTech Posted November 7, 2010 Share Posted November 7, 2010 Depends on what you want. If you really need it at exactly 1 second, you need to decide what to do with either the extra (data coming in faster than 1 per second) or missing data point (data less than 1 per second) on the PMT. The best solution, however, is to probably let the PMT do the timing, and simply read the labjack as soon as the PMT responds. Just set the timeout of your serial port to something larger than 1 second (say 1500), then put the read() or readuntil() inside a loop without much of a delay, and read the LabJack as soon as the read returns. Something like this: while(1) try private string datain = device.mydevice.readuntil(13) read(mylabjackChan) ... catch() endcatch delay(0.1) // just in case endwhile What happens is that the readuntil() will pause until the PMT responds, which presumably is once a second, and then you use that as a trigger to read the labjack channels. Link to comment Share on other sites More sharing options...
patrickokeeffe Posted November 9, 2010 Author Share Posted November 9, 2010 This is a creative idea and it seems well suited for the channel event. The instrument is deployed right now but once back, I'll try setting the timing on all labjack channels to zero and add a Read(...) statement for each labjack channel in the PMT channel event code. Link to comment Share on other sites More sharing options...
AzeoTech Posted November 10, 2010 Share Posted November 10, 2010 That would be a good place too, but make sure you don't put the while() loop there too. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.