Closed cynthi8 closed 3 years ago
I would like to work on this issue
Ok, go for it! Should be a quick fix. Checking out #159 might give you some context on how previous auto gain setting bugs were fixed.
@Kartik125 Go ahead. The problem is that the state of the analog input gain is not shared between different instances that use the analog inputs. The easiest way to fix this is for every Oscilliscope instance to always set the most recently selected gain before starting capture.
A more robust solution would be to make AnalogInput into a shared multiton, but that would require significantly more work and the extra complexity may or may not be worth it.
I'll keep in mind
On Fri, Feb 26, 2021 at 3:02 PM Alexander Bessman notifications@github.com wrote:
@Kartik125 https://github.com/Kartik125 Go ahead. The problem is that the state of the analog input gain is not shared between different instances that use the analog inputs. The easiest way to fix this is for every Oscilliscope instance to always set the most recently selected gain before starting capture.
A more robust solution would be to make AnalogInput into a shared multiton, but that would require significantly more work and the extra complexity may or may not be worth it.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/fossasia/pslab-python/issues/171#issuecomment-786526652, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM5NTD6SE2HY6NGEF2GK5SDTA5TC7ANCNFSM4YH4KQPQ .
can you guide me where can I find this issue I'm new at this, I will be pleased if you tell me
The issue is caused by the actual gain being different from what the oscilloscope instance thinks it is. Since there is no way to query the device to find out the gain, each oscilloscope instance must keep track of what the gain is. If there are multiple oscilloscope instances, one of them can change the gain without the other instances knowing about it. The next time such an instance captures samples, it might think that the gain is, for example, 1 when it is really 4. Then the returned values will be off by a factor of 4.
In order to solve that, each oscilloscope instance should first set the gain to whatever it thinks it is before capturing samples.
On L134 in oscilloscope.py, before the self._capture
call, call self._set_gain
for each of self._channels["CH1"]
and self._channels["CH2"]
(the other channels do not support gain) and set the gain to the value stored in channel.gain
.
Note that since this will change the traffic signature of Oscilloscope.capture
, it will cause several tests to fail. If you have a PSLab device, you should record new serial traffic for any failing tests and include that in the pull request. See CONTRIBUTING.md for instructions on how to do that. If you do not have a PSLab device I can help you record new traffic after you have opened a pull request.
Thanks, I'll check it out.
On Sat, 27 Feb 2021, 18:40 Alexander Bessman, notifications@github.com wrote:
The issue is caused by the actual gain being different from what the oscilloscope instance thinks it is. Since there is no way to query the device to find out the gain, each oscilloscope instance must keep track of what the gain is. If there are multiple oscilloscope instances, one of them can change the gain without the other instances knowing about it. The next time such an instance captures samples, it might think that the gain is, for example, 1 when it is really 4. Then the returned values will be off by a factor of 4.
In order to solve that, each oscilloscope instance should first set the gain to whatever it thinks it is before capturing samples.
On L134 https://github.com/fossasia/pslab-python/blob/development/pslab/instrument/oscilloscope.py#L134 in oscilloscope.py, before the self._capture call, call self._set_gain for each channel in self._channels and set the gain to the value stored in channel.gain.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/fossasia/pslab-python/issues/171#issuecomment-787070650, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM5NTD7BEDP64SWSXBO24UTTBDVOBANCNFSM4YH4KQPQ .
Any progress on this, @Kartik125?
Yes, I am working on it.
On Sun, Mar 7, 2021 at 1:29 AM Alexander Bessman notifications@github.com wrote:
Any progress on this, @Kartik125 https://github.com/Kartik125?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/fossasia/pslab-python/issues/171#issuecomment-792042897, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM5NTD2KIP4JLQ742TN7RP3TCKCS3ANCNFSM4YH4KQPQ .
Issue:
Test Code
Result
I would expect the oscilloscope to return a value around 3.3 V.