Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADC sample rate and scopeHandler rate? #6

Open
dagnall53 opened this issue Aug 15, 2017 · 5 comments
Open

ADC sample rate and scopeHandler rate? #6

dagnall53 opened this issue Aug 15, 2017 · 5 comments

Comments

@dagnall53
Copy link

@S-March
Hi, I have been looking in more detail at the code and was wondering if you can help explain some details about the timings...
I think that in your original code the "esp" is reading the ADC every 5ms, and then calling the "scopeHandler" code at "mstimer" intervals to update the display, using the most recent adc readings. thus sending ADC data to the display PC/tablet.
BUT, I have been looking at the timings, and the scopehandler code seems to take about 200ms to complete, and only sends one sample from each channel?
I suspect I have "broken" something critical so that any "fast" ADC (eg internal) is now being hobbled by this slow scopeHandler code, quite probably by some edits I have made.
What update rate can you achieve with the original code? I did try to reinstall an early version,but still got 200ms or thereabouts timings for the scopeHandler code part.

Any suggestions, comments or hints gratefully accepted!
Cheers
Dagnall

(I have currently updated the code (again) so that the HTML stuff sorts out a sensible "mSTimer" based on which and how many ADC's it is using and sends this to the ESP .. But I will not upload this until I think the speed issue is sorted.)

@S-March
Copy link
Owner

S-March commented Aug 15, 2017 via email

@dagnall53
Copy link
Author

@S-March thanks, that makes sense, I must have upset or removed the mechanism that stores the readings in a buffer.. I can now see the addadcscopedata functions are called or should be called a few times before the scope handler is called... I think my mods have not take that into account!
I will try to set some interactions so that the code works both with fast adc and the really slow two channel strain gauge interface.

Thanks
D

@S-March
Copy link
Owner

S-March commented Aug 15, 2017 via email

@dagnall53
Copy link
Author

@S-March
Quick update, it was mostly my fault, when I modified the way the scaling was applied, I ended up converting the multiple readings to a single one... Dohh..
I've nearly corrected it. I've also set a long period between html updates, 1.5 sec, so can now get a lot of adc readings in that time. Of course, the adc readings from sequential websends are out of time synch, so I'm working on some details around this to essentially try to display only a 'full set' of data at a time. But have a few issues in that the adc readings are stopped whilst the web server is updated.

In doing this i have also moved the data logging send to the adc routine, from the web update routine where it was it only sent (one) data when sending to the HTML . Not sure if I introduced this or it was there before..

I have one last and very irritating issue: the scope plot (in my version) does not completely plot to the right hand edge of the plot area. If the set of data points being plotted exceeds the plot area, the clear plot is immediately called before the last plot lines are written... This is not so troublesome with time scales of 10 sec or longer, but with expansion and especially on the 2s scale, there can be more plot points than space and so clear plot happens immediately and there is no visible plot. Quite difficult to explain, not sure if this is another bug I introduced or one that was there before... Anyway, I think I need to synchronise the clear with new data arriving. Or I may try to reduce the number of data points so they fit, but would prefer an alternative solution...
Anyway, cheers!
Dagnall

@dagnall53
Copy link
Author

@S-March
OK, I have got it working (again).. !
New code and some pictures are at
https://github.com/dagnall53/dEEbugger_PUBLIC/blob/patch-2/README.md
I have set the defaults to "single channel , internal ADC", so is should work "out of the box" with a Node MCU.

Hope you like it. I do not have the same I2C ADC as you so have not been able to test that feature, but hopefully it should be still working.
The HX711 strain gauge interface and internal ADC stuff have now been tested to my satisfaction, and I have added tweaks so the scope display shows blanks where no ADC reading have been taken.

The code is still littered with comments and commented out lines where I changed my mind or was working on something or trying to see what happened, but hopefully they will assist if you are trying to see what I did.
Cheers
Dagnall

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants