Go to advanced search

by RichardRussell
Fri Jun 14, 2019 5:24 pm
Forum: Other programming languages
Topic: ScriptBasic
Replies: 1021
Views: 25170

Re: ScriptBasic

Is seems 5 microsecond sampling of the pin is the sweet spot. Anything shorter just increase the time parsing the palse data with no additional benefit. Personally I'd rather sample as fast as I can, even if there's no great benefit it certainly can't make anything worse. It might make the differen...
by RichardRussell
Fri Jun 14, 2019 9:50 am
Forum: Other programming languages
Topic: ScriptBasic
Replies: 1021
Views: 25170

Re: ScriptBasic

PeterO wrote:
Fri Jun 14, 2019 9:47 am
Is that the right way round ? Sampling at the lower rate should compress not stretch the samples, or have I missed something ?
You're right, I spotted that before you posted and have corrected the text.
by RichardRussell
Fri Jun 14, 2019 9:32 am
Forum: Other programming languages
Topic: ScriptBasic
Replies: 1021
Views: 25170

Re: ScriptBasic

My samples look pretty consistant with 1/0 pulse widths if no delays beyond my control happen. What bad data looks like to me is late start and shortened pulse widths. Here's a graphical plot of what I am getting. The most notable features are the occasional capture at 1.2 GHz clock rather than 600...
by RichardRussell
Thu Jun 13, 2019 4:27 pm
Forum: Other programming languages
Topic: ScriptBasic
Replies: 1021
Views: 25170

Re: ScriptBasic

It was more how to deal with hardware which needs more than just sampling, needs reasonable timing accuracy on sending for example. The significant latency and jitter between what's seen at /dev/gpiomem and the actual GPIO pins (which I assume affects both directions) probably rules out sending, if...
by RichardRussell
Thu Jun 13, 2019 1:54 pm
Forum: Other programming languages
Topic: ScriptBasic
Replies: 1021
Views: 25170

Re: ScriptBasic

Instruction timing was what I was thinking would be easiest.And I expect it would be possible to calibrate 'how many nops' during the 18ms reset period for DHT11, and explicitly for other cases, keep fingers crossed that timing holds true through the full sampling period. Rather than do that, my ti...
by RichardRussell
Thu Jun 13, 2019 12:43 pm
Forum: Other programming languages
Topic: ScriptBasic
Replies: 1021
Views: 25170

Re: ScriptBasic

So how are accurate short microsecond delays being achieved ? In the case of BBC BASIC, and I think of some other languages, simply through instruction timings. Accuracy isn't essential (my code, and some Python code I've seen, is 'self calibrating' in that it doesn't rely on any absolute delays). ...
by RichardRussell
Thu Jun 13, 2019 8:11 am
Forum: Other programming languages
Topic: ScriptBasic
Replies: 1021
Views: 25170

Re: ScriptBasic

ScriptBasic wrote:
Thu Jun 13, 2019 12:10 am
Or people can call me John if they wish to refer to me instead of ScriptBasic.
I always have.
by RichardRussell
Tue Jun 11, 2019 8:27 am
Forum: Other programming languages
Topic: ScriptBasic
Replies: 1021
Views: 25170

Re: ScriptBasic

You can use my posted raw reads to play with if you want to try and find a better way. Extra points if you find a way to do data correction. Are you already taking advantage of the redundancy in the DHT11's data, as my BBC BASIC code does? This is "data correction" in a sense because you can derive...
by RichardRussell
Sun Jun 09, 2019 5:48 pm
Forum: Other programming languages
Topic: ScriptBasic
Replies: 1021
Views: 25170

Re: ScriptBasic

BBC BASIC news and progress reports should go in your thread. I think it would be better to take the 'DHT11 interfacing' discussion away from this thread altogether, a good place for it might be in the 'Projects... Automation, Sensing and Robotics' section. That way we can continue to compare imple...
by RichardRussell
Sun Jun 09, 2019 2:57 pm
Forum: Other programming languages
Topic: ScriptBasic
Replies: 1021
Views: 25170

Re: ScriptBasic

It's amusing to think that one could interrogate many DHT11 sensors simultaneously I've added a second DHT11, external to the RPi's case; here are the results with my BBC BASIC code modified to read both: Sun. 9 Jun 2019,15:48:26 Sensor 1: 15.0% RH, 38.5C Sensor 2: 50.0% RH, 23.9C Sun. 9 Jun 2019,1...
by RichardRussell
Sat Jun 08, 2019 3:34 pm
Forum: Other programming languages
Topic: ScriptBasic
Replies: 1021
Views: 25170

Re: ScriptBasic

ScriptBasic is using string to store sample bits and most people here are using array. I think I will directly use buffer to store bits. That way it's really easy to process and convert buffer data by using unpack. I'm using a buffer, allocated on the stack, to store the bits directly (24000 bytes,...
by RichardRussell
Sat Jun 08, 2019 1:43 pm
Forum: Other programming languages
Topic: ScriptBasic
Replies: 1021
Views: 25170

Re: ScriptBasic

I expect an interpreter coded in assembly language, like Sophie Wilson (CBE)'s ARM BBC BASIC, would be considerably faster. That's been confirmed by somebody at the StarDot forum. Sophie's BASIC runs a 1 million iteration empty FOR loop in 35 ms compared with my 190 ms or so. So that's 35 nanosecon...
by RichardRussell
Sat Jun 08, 2019 11:56 am
Forum: Other programming languages
Topic: ScriptBasic
Replies: 1021
Views: 25170

Re: ScriptBasic

And it should be pointed out that I'm locked at 600MHz because I have /dev/serial0 enabled. I wasn't aware of that side-effect, I wonder why. I don't know for sure what the CPU clock was when I ran my FOR loop test but I'm assuming probably 1.2 GHz because of the 100% load on one core for a signifi...
by RichardRussell
Sat Jun 08, 2019 9:53 am
Forum: Other programming languages
Topic: ScriptBasic
Replies: 1021
Views: 25170

Re: ScriptBasic

I'm surprised Python is fast enough to do meaningful sampling. With BBC BASIC and Python both able to sample natively, it blurs the line between interpreters and compilers. A sample period of 1μs isn't really 'fast' when you consider that, at a 1.2 GHz CPU clock speed, it amounts to 1,200 clock cyc...
by RichardRussell
Fri Jun 07, 2019 10:24 pm
Forum: Other programming languages
Topic: ScriptBasic
Replies: 1021
Views: 25170

Re: ScriptBasic

Arrays (linked lists) are much slower. How do you manage if ScriptBasic needs to call an API function which takes an array as a parameter? For example suppose you want to call the GDI32 PolyLine API to draw a polygon. Windows will assume that the array elements are in consecutive memory locations, ...
by RichardRussell
Fri Jun 07, 2019 9:02 pm
Forum: Other programming languages
Topic: ScriptBasic
Replies: 1021
Views: 25170

Re: ScriptBasic

Here is my data capture results using 99 for priority and no delays between reading the pin. It seems it's all over around 200 - 210 reads Only 200 reads in 5 milliseconds? That's 25 μs per sample, which isn't going to be fast enough (as Heater said the theoretical minimum sampling rate is twice th...
by RichardRussell
Fri Jun 07, 2019 8:46 pm
Forum: Other programming languages
Topic: ScriptBasic
Replies: 1021
Views: 25170

Re: ScriptBasic

All of which sounds a bit tricky to me when we are talking about using interpreted languages running on a non-realtime operating system Tricky in the sense of getting reliable results, yes - as we have seen. But not tricky in the sense of writing the code, indeed quite straightforward; I think my B...
by RichardRussell
Fri Jun 07, 2019 11:14 am
Forum: Other programming languages
Topic: ScriptBasic
Replies: 1021
Views: 25170

Re: ScriptBasic

2) An interpreter may have enough speed which allows sampling the stream into an array and decoding that later. Either by sampling directly or through a native library. We know that one interpreter, BBC BASIC, is fast enough to sample the data stream into an array. At about 1μs sample period when t...
by RichardRussell
Fri Jun 07, 2019 10:54 am
Forum: Other programming languages
Topic: ScriptBasic
Replies: 1021
Views: 25170

Re: ScriptBasic

Don't know Richard. You were asking that kind of question so I gave that kind of answer. My question was: is it possible to run my program with high thread priority without invoking sudo? The answer ought in principle to be yes, because the permission required by sched_setscheduler() can be granted...
by RichardRussell
Fri Jun 07, 2019 10:34 am
Forum: Other programming languages
Topic: ScriptBasic
Replies: 1021
Views: 25170

Re: ScriptBasic

When you sudo you are not taking your normal environment with you into the privileged world. Who are you responding to? Using sudo to run BBC BASIC works perfectly, there is no issue related to the library path. That's how I ran the DHT11 program with increased thread priority, but obviously runnin...
by RichardRussell
Fri Jun 07, 2019 9:57 am
Forum: Other programming languages
Topic: ScriptBasic
Replies: 1021
Views: 25170

Re: ScriptBasic

To read the actual data value one needs to spot the rising edge and then determine how long the pulse was. That's one way (and what most implementations seem to do). But as I mentioned before the redundancy in the DHT11 data means there are other methods, such as measuring the time between consecut...
by RichardRussell
Fri Jun 07, 2019 9:05 am
Forum: Other programming languages
Topic: ScriptBasic
Replies: 1021
Views: 25170

Re: ScriptBasic

I've elevated priority without being root. I should more correctly have said "has the required permission" rather than "has root privilege" but sched_setscheduler() (which is what both WiringPi and my BBC BASIC code call) returns -1 here, meaning the function failed, if run normally (i.e. without s...
by RichardRussell
Fri Jun 07, 2019 8:39 am
Forum: Other programming languages
Topic: Searching for BASIC
Replies: 19
Views: 602

Re: Searching for BASIC

If vintage BASIC is your cup of tea. BASICs that treat 'line numbers' like labels tend not to support a couple of features that 'traditional' line-numbered BASICs do: The ability to RENUMBER the program (e.g. to make space for new lines) whilst automatically adjusting references to lines whose numb...
by RichardRussell
Thu Jun 06, 2019 9:43 pm
Forum: Other programming languages
Topic: ScriptBasic
Replies: 1021
Views: 25170

Re: ScriptBasic

With the elevated process priority, I can meet the 'ten error-free reads in a row' challenge: Thu. 6 Jun 2019,22:23:18 DHT11/12/22 read failed: checksum error Thu. 6 Jun 2019,22:23:20 Humidity = 13.0%, temperature = 39.6C Thu. 6 Jun 2019,22:23:22 Humidity = 13.0%, temperature = 39.6C Thu. 6 Jun 2019...
by RichardRussell
Thu Jun 06, 2019 8:45 pm
Forum: Other programming languages
Topic: ScriptBasic
Replies: 1021
Views: 25170

Re: ScriptBasic

I'm assuming the priority returns to defaults once the script ends? In the case of BBC BASIC the program runs in a separate process (independent of the IDE from which it was launched) so when the program closes so does the process, and the elevated priority is no longer in effect. That might not be...

Go to advanced search