![]() |
Forum Index : Microcontroller and PC projects : extension of PULSIN function (suggestion for micromite)
Author | Message | ||||
robert.rozee Guru ![]() Joined: 31/12/2012 Location: New ZealandPosts: 2442 |
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: AustraliaPosts: 3292 |
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: AustraliaPosts: 6283 |
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: AustraliaPosts: 1642 |
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: AustraliaPosts: 6283 |
ADC is Analogue to digital. From the manual under ADC command: 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: AustraliaPosts: 1642 |
Thanks Jim, I did read it in the manual but I didn't fully comprehend. Perhaps the description could be changed to: 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 ZealandPosts: 2442 |
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 KingdomPosts: 10310 |
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: AustraliaPosts: 3292 |
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 ZealandPosts: 2442 |
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 KingdomPosts: 4044 |
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 KingdomPosts: 4044 |
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 StatesPosts: 593 |
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 KingdomPosts: 4044 |
Ah, mine defaulted to Non-flash and I hardly noticed that option. John |
||||
Geoffg![]() Guru ![]() Joined: 06/06/2011 Location: AustraliaPosts: 3292 |
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: AustraliaPosts: 292 |
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 |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |