Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 11:15 01 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : extension of PULSIN function (suggestion for micromite)

Author Message
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2442
Posted: 02:04pm 05 Jul 2020
Copy link to clipboard 
Print this post

hi,
   this is probably one for geoff:

it would be useful (for some folks) if the PULSIN function were extended to allow measuring a train of pulses, such as that produced by various remote controls, weather stations, etc. often the protocol used by these devices is relative simple, repeated frequently, but not well documented and hard to reverse-engineer without a DSO.

how practical would it be to extend the syntax and functioning of PULSIN as follows:

PULSIN( [TVarray] pin [, polarity [, t1 [, t2]]] )

where TVarray is an array of floats or integers that would be populated with time values (in microseconds).

as TVarray would be of a different type (array) to that of pin (float or integer), the interpreter should be able to distinguish between the existing and new syntax, and proceed accordingly.

polarity would be the polarity of the FIRST pulse timed and stored in TVarray[0] (or 1, depending on the setting of OPTION BASE). thereafter the lengths of pulses of alternating polarity would be measured and stored in successive elements of TVarray until the end of the array is reached. at this point, PULSIN would return with either the total of all measured pulses, or -1 on timeout.

the values stored in TVarray could be either the length of individual pulses, or a running total, whichever was most convenient to be implemented - a simple FOR...STEP-1...NEXT loop can be used later on to convert from cumulative to individual times.


i've been playing around with decoding the output from EV1527 key fobs in another thread (started by Grogster), and while a tight loop using PULSIN on negative pulses did work ok, the ability to fully measure the timing (both positive and negative) would be far more general-purpose and able to handle signals with a far greater bitrate. indeed, the extended version of PULSIN may even be able to directly decode the data stream from IR remote signals.


cheers,
rob   :-)
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3292
Posted: 11:12pm 05 Jul 2020
Copy link to clipboard 
Print this post

Interesting.  This would be very specialised and I am now only adding bug fixes and critical feature to the Micromite family (especially the MX170 version).

However, I do believe that it could be implemented as a CFunction and that would work well.  If it was matched with a similar pulse send function it would make the basics of a simple learning IR remote control.

I will give it a go and see what eventuates.

Geoff
Geoff Graham - http://geoffg.net
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 04:01am 06 Jul 2020
Copy link to clipboard 
Print this post

  Geoffg said  Interesting.  This would be very specialised and I am now only adding bug fixes and critical feature to the Micromite family (especially the MX170 version).

However, I do believe that it could be implemented as a CFunction and that would work well.  If it was matched with a similar pulse send function it would make the basics of a simple learning IR remote control.

I will give it a go and see what eventuates.

Geoff


Peter gave us the BITBANGER csub.
This would be the reverse and very useful.
On the CMM2 you can get away with using the ADC function but it's an overkill for binary.

Jim
VK7JH
MMedit
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1642
Posted: 04:12am 06 Jul 2020
Copy link to clipboard 
Print this post

  Quote  On the CMM2 you can get away with using the ADC function but it's an overkill for binary

What does ADC stand for in this case? I only know it as Analogue to Digital Converter and Google doesn't help.

Bill
Keep safe. Live long and prosper.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 04:48am 06 Jul 2020
Copy link to clipboard 
Print this post

ADC is Analogue to digital.
From the manual under ADC command:
  Quote  The ADC functionality can capture up to 3 channels of data in the
background at up to 500KHz per channel with user selectable triggering


In this case we would have to scan the resulting array looking for hi-low and hi-low transitions.

500kHz gives us a time resolution of 2uS which ain't bad.
The good bit is BACKGROUND sampling.

Jim
VK7JH
MMedit
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1642
Posted: 05:17am 06 Jul 2020
Copy link to clipboard 
Print this post

Thanks Jim,

I did read it in the manual but I didn't fully comprehend. Perhaps the description could be changed to:
  Quote  The ADC functionality can capture up to 3 channels of analog data in the background at up to 500KHz per channel with user selectable triggering


Peter's demo program earlier in this post demonstrates it. I can see an DSO program in the future.

Bill
Keep safe. Live long and prosper.
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2442
Posted: 10:44am 06 Jul 2020
Copy link to clipboard 
Print this post

  Geoffg said  Interesting.  This would be very specialised and I am now only adding bug fixes and critical feature to the Micromite family (especially the MX170 version).

However, I do believe that it could be implemented as a CFunction and that would work well.  If it was matched with a similar pulse send function it would make the basics of a simple learning IR remote control.

I will give it a go and see what eventuates.

Geoff


i'd not thought of a learning remote control! i could use this to replace my really annoying heatpump remote that has too many buttons and an LCD that is impossible to read without a microscope.

a pulse send function could be implemented as a variation of PULSE thus:

PULSE pin, width | TVarray

ie, if the second parameter specifies an array, then a series of alternating polarity pulses are sent using pulse width values held in TVarray.

i feel that in the case of passing TVarray from/to PULSIN and PULSE, it would be perfectly acceptable for interrupts to be disabled for the duration of the function/command. as you say, this is a specialized application and it would be a bit of a stretch to expect things like serial comms to carry on completely unimpeded at the same time!

other applications for PULSIN with an array may be reading the IR data output that some electricity meters produce, the data stream available from some digital multimeters, low-frequency radio transmissions of atomic clock time signals, weather broadcasts...


cheers,
rob   :-)
Edited 2020-07-06 20:50 by robert.rozee
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10310
Posted: 12:06pm 06 Jul 2020
Copy link to clipboard 
Print this post

Ages ago I wrote a logic analyser CFunction for the MM2 which should do the job

Check out http://www.thebackshed.com/forum/ViewTopic.php?TID=8082

There is also a BITBANG cfunction for generating arbitrary pulse trains
Edited 2020-07-06 22:11 by matherp
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3292
Posted: 12:19pm 06 Jul 2020
Copy link to clipboard 
Print this post

  robert.rozee said  
i could use this to replace my really annoying heatpump remote that has too many buttons and an LCD that is impossible to read without a microscope.

This month Silicon Chip has a neat learning remote project that does just what you want: http://www.siliconchip.com.au/Issue/2020/July/Infrared+Remote+Control+Assistant

I'm disappointed that I did not think of it first.
Geoff Graham - http://geoffg.net
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2442
Posted: 03:58pm 06 Jul 2020
Copy link to clipboard 
Print this post

alas, firefox under linux just displays a red box instead of the article. what device do they use to do the decoding? i'm going to guess an arduino.


btw, have been playing around looking at the innards of micromite basic again, and found a few interesting oddities:

1. THEN and TRACE share the same token

2. STATIC and ELSE share the same token

3. if you enter the invalid line DO WHILE LOOP then WHILE is encoded as the token for CONST

4. CONTINUE FOR uses a token for "for", while  CONTINUE DO stores the literal text of the "do" part

5. (addendum): if you use REM to begin a comment, every time you edit your program (making a change) an extra space character will be added between REM and the rest of the comment!


so far i've just been looking and commands, will move on to operators and functions later. the idea is to have a massive 'sample program' that exhibits all variants of tokenizing (valid and invalid), with a bit of code at the end that runs through it all generating an output spreadsheet that can be analysed for errors.


cheers,
rob   :-)


RUN
List all
GoTo start


If 1 Then Trace on Else Trace off
'If 1 Then Trace on Else Trace off

Static I'static S
If Else'if else

Do 'do
While 1'while 1
Do :While 1'do:while 1

Do While 1'do while 1
Const K'const K

Continue do'continue do
Continue For'continue for


ZZZ:
start:
I=0
Do
 Z=Y
 Y=X
 X=Peek(progmem,I)
 Select Case X
   Case 1
     comment=0
     Print :Print "<1>";
   Case <32
     Print "<" Str$(X) ">";
   Case 32
     If comment Then Print " "; Else Print "_";
   Case 39
     comment=1
     Do While (Pos<30):Print " ";:Loop
     Print "'";
   Case <128
     Print Chr$(X);
   Case Else
     Print "[" Str$(X) "]";
 End Select
 I=I+1
Loop Until (X=90)And(Y=90)And(Z=90)
Print :Print

<1>[160]all<0>
<1>[155]start<0>
<1><0>
<1><0>
<1>[156]1_[177]_[177]on_[173]_[177]off<0>
<1>                          'If 1 Then Trace on Else Trace off<0>
<1><0>
<1>[173]I                    'static S<0>
<1>[156][173]                'if else<0>
<1><0>
<1>[132]                     'do<0>
<1>[179]1                    'while 1<0>
<1>[132]<0>[179]1            'do:while 1<0>
<1><0>
<1>[132][180]_1              'do while 1<0>
<1>[180]K                    'const K<0>
<1><0>
<1>[129]do                   'continue do<0>
<1>[129][172]                'continue for<0>
<1><0>
<1><0>
<1><3><3>ZZZ

>

Edited 2020-07-07 02:06 by robert.rozee
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4044
Posted: 04:22pm 06 Jul 2020
Copy link to clipboard 
Print this post

  robert.rozee said  alas, firefox under linux just displays a red box instead of the article.


But for me it displays - so there's probably some add-on or lib (used by firefox when present) which you could install.

I'll post again if I figure what!

John
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4044
Posted: 04:30pm 06 Jul 2020
Copy link to clipboard 
Print this post

I'm drowning in a daft amounts of HTML but it looks like it should just work.

You could open the source as the article itself is quite readable even then.
(Maybe search on Remote controls are handy)

I can't see why your 'fox isn't displaying it.

John
 
Quazee137

Guru

Joined: 07/08/2016
Location: United States
Posts: 593
Posted: 06:01pm 06 Jul 2020
Copy link to clipboard 
Print this post

I am using Mint 18 and Firefox and at the Silicon Chip link get a black box
 with a "run flash" box in the center.

 In lower left browser screen I see bar button "Full Screen"
 and a drop down one with "Med Res (?MB)" and "Non Flash"
 selecting "Non Flash" lets me see the text.
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4044
Posted: 06:31pm 06 Jul 2020
Copy link to clipboard 
Print this post

Ah, mine defaulted to Non-flash and I hardly noticed that option.

John
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3292
Posted: 09:46pm 06 Jul 2020
Copy link to clipboard 
Print this post

Re the article:
It might be best to go to their main page and click your way to the article: http://www.siliconchip.com.au/

Re tokens:
There are two types of tokens:
- Commands (at the start of a statement)
- Operators, keywords, etc (in the body of the statement)

For example, STATIC is a command while ELSE is a keyword.

Geoff
Geoff Graham - http://geoffg.net
 
BrianP
Senior Member

Joined: 30/03/2017
Location: Australia
Posts: 292
Posted: 01:29am 09 Jul 2020
Copy link to clipboard 
Print this post

  TassyJim said  
  Geoffg said  Interesting.  This would be very specialised and I am now only adding bug fixes and critical feature to the Micromite family (especially the MX170 version).

However, I do believe that it could be implemented as a CFunction and that would work well.  If it was matched with a similar pulse send function it would make the basics of a simple learning IR remote control.

I will give it a go and see what eventuates.

Geoff


Peter gave us the BITBANGER csub.
This would be the reverse and very useful.
On the CMM2 you can get away with using the ADC function but it's an overkill for binary.

Jim


The SC project uses a pre-programmed DIP-20 PIC16F1459-I/P & a memory module for storage (no MMbasic). When I saw this suggestion I immediately thought this would be a MASSIVE addition to the 'Mite stable if it could be implemented. We all have too many separate remotes adding to our already cluttered living space. Worldwide the numbers would be astronomical.

I for one would definately be a user. Go for it guys - I'll donate to your favourite charity...

B
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025