Search found 14 matches
- Wed Jan 05, 2022 10:01 am
- Forum: ESP8266 boards
- Topic: How to build string in pre-allocated bytearray
- Replies: 1
- Views: 8299
Re: How to build string in pre-allocated bytearray
A partial solution seems to be the use of Python module io, class BytesIO (see https://docs.micropython.org/en/latest/library/io.html ). The size of the buffer to be allocated can be specified. However, I found no way to clear the buffer other than releasing it using method close and allocate a new ...
- Mon Jan 03, 2022 12:49 pm
- Forum: ESP8266 boards
- Topic: How to build string in pre-allocated bytearray
- Replies: 1
- Views: 8299
How to build string in pre-allocated bytearray
Background: an ESP8266 running micropython v1.16, is used to measure the voltage and the frequency of the mains power. The frequency is measured using an ISR, which measures the time it takes to receive 250 pulses. The main loop has been changed from sending the measurements of the voltage and the f...
- Mon Oct 05, 2020 10:41 am
- Forum: General Discussion and Questions
- Topic: [Answered] Question about micropython.schedule and parameter counts
- Replies: 2
- Views: 1654
Re: Question about micropython.schedule and parameter counts
Ah, now the error messages make sense: in the first case the TypeError was generated when calling micropython.schedule, in the second case the TypeError was generated when calling Frequency.update from within micropython.schedule. Hence the variable number of expected arguments.
- Sun Oct 04, 2020 8:11 pm
- Forum: General Discussion and Questions
- Topic: [Answered] Question about micropython.schedule and parameter counts
- Replies: 2
- Views: 1654
[Answered] Question about micropython.schedule and parameter counts
The use case is the measurement of the frequency of the mains power supply. The sinus wave form is converted into a square wave. The time T needed to see N rising edges is used to calculate the frequency: f = N/T. The rising edges are counted in an ISR, thus floating point arithmetic is not allowed....
- Thu Oct 01, 2020 8:03 pm
- Forum: ESP8266 boards
- Topic: [SOLVED] ESP8266, read 80 [MHz] counter
- Replies: 4
- Views: 2798
Re: ESP8266, read 80 [MHz] counter
I am not looking for a resolution of about 10 [ns]. Such a resolution is much, much better than I need. The target is to get an accuracy of the measured frequency of 10 [mHz]. This implies that the duration of one period must be measured with an accuracy of 4 [µs]. Given a variation of the ISR laten...
- Thu Oct 01, 2020 8:44 am
- Forum: ESP8266 boards
- Topic: [SOLVED] ESP8266, read 80 [MHz] counter
- Replies: 4
- Views: 2798
[SOLVED] ESP8266, read 80 [MHz] counter
The intent is to build a device which monitors the mains frequency, which is about 50 [Hz] over here. The device should use less than 0.5 [W], which is a reason to use an ESP8266 microcontroller. When the sine wave is converted to a digital signal, the time it takes to receive N pulses needs to be d...
- Thu Jul 16, 2020 8:29 pm
- Forum: General Discussion and Questions
- Topic: Strange behaviour class variables [SOLVED]
- Replies: 9
- Views: 4392
Re: Strange behaviour class variables
It might look like local versus global variables, but the tests don't support that idea. In the method in which this phenomena was discovered the first line is an assert command containing both cvsp_lst_task and cvsp_max_task in the condition part. Thus the first action on those variables is a read.
- Thu Jul 16, 2020 5:56 pm
- Forum: General Discussion and Questions
- Topic: Strange behaviour class variables [SOLVED]
- Replies: 9
- Views: 4392
Re: Strange behaviour class variables
Remarkable, this (what seems to be) inconsistent behaviour is thus reproducible in CPython.
The workaround mentioned is now used, so I can continue with development and tests. I probably will go for a shorter module and class name.
The workaround mentioned is now used, so I can continue with development and tests. I probably will go for a shorter module and class name.
- Thu Jul 16, 2020 12:22 pm
- Forum: General Discussion and Questions
- Topic: Strange behaviour class variables [SOLVED]
- Replies: 9
- Views: 4392
Strange behaviour class variables [SOLVED]
The problem described below was found while using the currently latest build of MicroPython on an ESP8266. A (test) class with 3 class variables is created, as well as two instances of the test class. Two class variables are modified, but only one of the two modifications is visible to both instance...
- Fri Jul 10, 2020 9:17 am
- Forum: General Discussion and Questions
- Topic: [SOLVED] time.time() very inaccurate when using uasyncio
- Replies: 8
- Views: 3847
Re: time.time() very inaccurate when using uasyncio
If I understand it correctly, time.time() gets the time from the RTC on the ESP8266, but time.ticks_ms() and time.sleep() use another source for time. I failed to locate the source code of time.time() to verify this statement. Thus the conclusion is that I happen to have an ESP8266 with a very inacc...