msoon / PyMonsoon

Monsoon Power Monitor Python Library
MIT License
55 stars 23 forks source link

Cannot collect more than 10 seconds of samples #16

Closed luiscruz closed 7 years ago

luiscruz commented 7 years ago

The maximum number of samples I can collect is 50000 (10s).

This is what I call:

engine.startSampling(15*5000)

The problem is in the stop condition of sampleEngine in the method __evalStopTrigger(self,measurement). It has a second condition based on triggers that is not being customized:

After commenting the following lines, everything works fine:

        # test = self.__stopTriggerStyle(measurement,self.__stopTriggerLevel)
        # self.__stopTriggerLevel
        # if(np.any(test)):
        #     self.__stopTriggerSet = True

Is this a feature or should I do a pull request removing those lines?

Mbrinker commented 7 years ago

The second trigger condition can be set to any trigger channel with the setStartTrigger(), setStopTrigger, and setTriggerChannel commands. I.e. adding

     engine.setStartTrigger(sampleEngine.triggers.GREATER_THAN,0)
     engine.setStopTrigger(sampleEngine.triggers.GREATER_THAN,100)
     engine.setTriggerChannel(sampleEngine.channels.timeStamp)

to your main function will tell it to collect 100s worth of samples. This also gives the flexibility to start collecting samples when, for example, current on the main channel exceeds 100 mA, and stop sampling when current drops below 10 mA.

I agree the default behavior should not be to stop at 10s worth of samples. The simpleSamplingExample file has also not been updated to show this, which will certainly be frustrating.

luiscruz commented 7 years ago

It seems to be a great feature. I think it is somehow conflicting with a feature implemented with the method startSampling in which you can define the number of samples. Perhaps startSampling should use the same triggering mechanism.

Mbrinker commented 7 years ago

I just pushed an update that should fix this.

Stop triggers now default to disabled, and can be set back to disabled by setting the stop trigger to SAMPLECOUNT_INFINITE as you've been doing.

luiscruz commented 7 years ago

Perfect! Fixed with 0f14c06