Author Topic: Reverse Polish Notation - need to learn.  (Read 12035 times)

0 Members and 1 Guest are viewing this topic.

Offline Addicted2AnalogTek

  • Frequent Contributor
  • **
  • Posts: 493
  • Country: us
Reverse Polish Notation - need to learn.
« on: February 20, 2016, 09:38:05 pm »
I am interested in learning the RPN language so I can write programs and upload to my Tek 7854 scope.

Does anyone have any book recommendations?


 

Offline amyk

  • Super Contributor
  • ***
  • Posts: 6616
Re: Reverse Polish Notation - need to learn.
« Reply #1 on: February 20, 2016, 10:20:43 pm »
Why a book when you can find everything online?

RPN is very simple but you just need to get used to thinking in terms of a stack.
 

Offline HAL-42b

  • Frequent Contributor
  • **
  • Posts: 423
Re: Reverse Polish Notation - need to learn.
« Reply #2 on: February 20, 2016, 10:22:05 pm »
 

Offline stealthbanana

  • Newbie
  • Posts: 3
  • Country: gb
Re: Reverse Polish Notation - need to learn.
« Reply #3 on: February 20, 2016, 11:09:35 pm »
The way I learned was using FORTH.  and reading a few tutorials on the subject.
 

Offline Addicted2AnalogTek

  • Frequent Contributor
  • **
  • Posts: 493
  • Country: us
Re: Reverse Polish Notation - need to learn.
« Reply #4 on: February 20, 2016, 11:14:50 pm »
Why a book when you can find everything online?

I have a much easier time learning things when I have a book to flip through.  Something about staring at a computer screen reading pages of material makes things immensely harder for me.
 

Offline Addicted2AnalogTek

  • Frequent Contributor
  • **
  • Posts: 493
  • Country: us
Re: Reverse Polish Notation - need to learn.
« Reply #5 on: February 20, 2016, 11:20:07 pm »


Oh, wow.. that's a whole lot simpler than I was expecting.   Thanks for the video series link!

I suppose the best way to learn it would be to just watch some videos and download an emulator to play with.  Followed by learning on the 7854 as I go.

Thanks!
 

Offline rrinker

  • Super Contributor
  • ***
  • Posts: 1950
  • Country: us
Re: Reverse Polish Notation - need to learn.
« Reply #6 on: February 20, 2016, 11:50:04 pm »
 I have to check this out and see how much I remember. I always used a Casio in college, but learned to operate an RPN calculator just in case - if your calculator died during an exam, the professor had no problem lending you his - an HP-41C. I recall several times where people freaked out because they had no idea how to use the RPN style. Thankfully never had to test out my ability, mine was a Casio after all. In fact, it took my then toddler son 'hiding' it in a lamp, and the heat of the bulb melting through the case, to actually destroy my good one, which by that time was about 8 years old.
 

Offline djacobow

  • Super Contributor
  • ***
  • Posts: 1061
  • Country: us
  • takin' it apart since the 70's
Re: Reverse Polish Notation - need to learn.
« Reply #7 on: February 21, 2016, 12:25:07 am »
Just buy an RPN calculator and use it for awhile. Of my HP48G, 28S, 32S-II, and 35S, I reach for the 32S the most. You can also get phone emulator apps for all of those.

Another way to learn RPN is to write an RPN calculator library in your favorite programming language. I like RPN so much that I have added RPN interpreters to many of my software projects over the years. It is useful, for example, in config files where you want certain variables related to each other.
 

Offline IanB

  • Super Contributor
  • ***
  • Posts: 9618
  • Country: us
Re: Reverse Polish Notation - need to learn.
« Reply #8 on: February 21, 2016, 12:40:19 am »
I am interested in learning the RPN language so I can write programs and upload to my Tek 7854 scope.

Does anyone have any book recommendations?

RPN isn't really a language, it's just a notation. There are three possible notations:

Prefix: + 2 3
Infix: 2 + 3
Postfix: 2 3 +

RPN is a postfix notation.

The nice thing about postfix notations like RPN is that you can store intermediate values on a stack and pull them off later as you need them. That reduces the need for "memories" or "variables" to store temporary values.
I'm not an EE--what am I doing here?
 

Offline helius

  • Super Contributor
  • ***
  • Posts: 2870
  • Country: us
Re: Reverse Polish Notation - need to learn.
« Reply #9 on: February 21, 2016, 12:59:18 am »
RPN isn't really a language, it's just a notation.
True, but...
Quote
The nice thing about postfix notations like RPN is that you can store intermediate values on a stack and pull them off later as you need them. That reduces the need for "memories" or "variables" to store temporary values.
Once you're speaking of "memories", "variables", "performing calculations" or "writing algorithms", you are in the domain of programming languages, not just notations. Some postfix languages make it easy to use variables where they are appropriate (HP's RPL) and some are really not designed for that (ANS Forth). As a purely algebraic notation, infix holds a monopoly over the alternatives, even when it's being processed by a program written in a prefix language! (Macsyma, Axiom, Reduce are all written in Lisp but use "standard mathematical notation" which is infix.)
 

Offline djacobow

  • Super Contributor
  • ***
  • Posts: 1061
  • Country: us
  • takin' it apart since the 70's
Re: Reverse Polish Notation - need to learn.
« Reply #10 on: February 21, 2016, 01:07:39 am »
RPN isn't really a language, it's just a notation. There are three possible notations:

Well, there are many RPN-based computer languages that are frequently referred to as "RPN" even though a more accurate name might be "the postfix notation supported by the HP-XX calculator"

Let's say I wanted the equivalent resistance of a 10 ohm and 5 ohm resistor in parallel:

10 INV 5 INV + INV

And it leaves 3.33333 on the stack

But I could also do:

<< INV SWAP INV + INV >> 'REQ' STO

And I'd now have a little program called REQ in memory.

Then I can do

10 5 REQ

and it would also leave 3.33333 on the stack, except now I have a generic program that works for any two resistors. (Better yet, that program would work for any type that supports inversion and addition, so, for example those could be complex impedance, etc)

 

Online rdl

  • Super Contributor
  • ***
  • Posts: 2758
  • Country: us
Re: Reverse Polish Notation - need to learn.
« Reply #11 on: February 21, 2016, 10:09:05 am »
I have a much easier time learning things when I have a book to flip through.  Something about staring at a computer screen reading pages of material makes things immensely harder for me.

Understandable, since there is mounting evidence that real books are probably better.
 

Offline chris_leyson

  • Super Contributor
  • ***
  • Posts: 1349
  • Country: wales
Re: Reverse Polish Notation - need to learn.
« Reply #12 on: February 21, 2016, 10:49:54 am »
Can't think of any books off hand, Google for TEK 7854 app notes, I'm sure you can find a few examples. I have two 7854s and one keyboard, both 7854s have broken IEEE488 interfaces so they will need to be rebuilt at some time. It's a nice feature, being able to run small programs.
 

Offline Addicted2AnalogTek

  • Frequent Contributor
  • **
  • Posts: 493
  • Country: us
Re: Reverse Polish Notation - need to learn.
« Reply #13 on: February 21, 2016, 02:41:34 pm »
Can't think of any books off hand, Google for TEK 7854 app notes, I'm sure you can find a few examples. I have two 7854s and one keyboard, both 7854s have broken IEEE488 interfaces so they will need to be rebuilt at some time. It's a nice feature, being able to run small programs.

After a couple quick searches, I haven't come up with any 7854 notes - just manuals, ROM images, and the like. I'll ask over at Tekscopes if anyone has any references.  There's a bunch of people who frequently use the 7854 over there.   I just thought that asking here about RPN might yield a wider range of references and learning methods. :-)

I've been compiling some info for the 7854 over at Tekscopes while I wait to receive mine.  It's an option 2D/option 3 unit.
I hope the GPIB on mine works!! If not, maybe we can start a thread for that repair.  Even if mine does work fine, if you need any info from the circuit to aid in fixing yours, let me know.

 

Offline chris_leyson

  • Super Contributor
  • ***
  • Posts: 1349
  • Country: wales
Re: Reverse Polish Notation - need to learn.
« Reply #14 on: February 21, 2016, 04:56:27 pm »
Found this, I think this is what you are after. http://docmesure.free.fr/telecharger.php?dir=Tektronix/Serie%207000/0scillos%207000/7854/&file=7854_ops_sm.pdf

Can't seem to read my CD from Artek Manuals, damn Windows.
 

Offline Addicted2AnalogTek

  • Frequent Contributor
  • **
  • Posts: 493
  • Country: us
Re: Reverse Polish Notation - need to learn.
« Reply #15 on: February 21, 2016, 05:06:51 pm »
Found this, I think this is what you are after. http://docmesure.free.fr/telecharger.php?dir=Tektronix/Serie%207000/0scillos%207000/7854/&file=7854_ops_sm.pdf

Can't seem to read my CD from Artek Manuals, damn Windows.

Oh, wow..... I didn't even consider that the manuals would contain all the info necessary for the 7854 programming..   My scope comes with a full set of manuals.

I will have to see if the manuals contain this, but another part of what I am after is the information necessary to program the scope using the GPIB interface and computer programs. 

I will still d/l a couple of calculator emulators and possibly even buy an RPN calculator.  I really want to be able to take full advantage of the 7854's abilities as my knowledge and projects progress.

Thanks, everyone!   :-+
 

Offline Wytnucls

  • Super Contributor
  • ***
  • Posts: 2837
  • Country: be
Re: Reverse Polish Notation - need to learn.
« Reply #16 on: February 21, 2016, 07:23:17 pm »
Have a look at this manual:
http://www.greendyk.nl/hp97/index.php
 

Offline AlxDroidDev

  • Frequent Contributor
  • **
  • Posts: 471
  • Country: br
    • Arduino Web Brasil
Re: Reverse Polish Notation - need to learn.
« Reply #17 on: February 21, 2016, 07:25:33 pm »
Just start programming like Yoda talks. That's pretty much it.

(sorry, couldn't resist!)
"The nice thing about standards is that you have so many to choose from." (Andrew S. Tanenbaum)
 

Offline Addicted2AnalogTek

  • Frequent Contributor
  • **
  • Posts: 493
  • Country: us
Re: Reverse Polish Notation - need to learn.
« Reply #18 on: February 22, 2016, 01:22:32 am »
Thanks, Wytnucls, I'm going to pick out an emulator and get some practice in starting this week.  :-+

Now I just need to relearn trig and calculus....
« Last Edit: February 22, 2016, 01:48:55 am by Addicted2AnalogTek »
 

Offline TerraHertz

  • Super Contributor
  • ***
  • Posts: 3640
  • Country: au
  • Why shouldn't we question everything?
    • It's not really a Blog
Re: Reverse Polish Notation - need to learn.
« Reply #19 on: February 22, 2016, 01:22:28 pm »
Found this, I think this is what you are after. http://docmesure.free.fr/telecharger.php?dir=Tektronix/Serie%207000/0scillos%207000/7854/&file=7854_ops_sm.pdf

Dammit, that manual was so nice, I now want an original even if I never do own a 7854.
Also, wishing I had an original (so I could do a proper scan, unlike that rather poor one) just makes me sad that now I can't ask Manuals Plus if they have it. Which they probably did.

Ha. For a long-running background writing project (about scanning technique) I keep notes of useful examples. Here's my notes on that 7854 pdf. Just to confirm the views of anyone who thinks I'm OCD.
Quote
This manual has some fine examples of scanning/encoding mistakes.
* It's all jpg encoded, with terrible jpeg artefacts if you zoom in. For most of the content type, PNG would have been much better.
* None of it is de-spotted, so there are spots on many pages.
* The spiral binder holes are pointlessly visible on every page.
* Pages that were foldouts are split into pieces. PDF-Pg: 20-21, 26-27, 32-33, 36-37
* Some pages have content that is rotated, so the pdf has those pages in landscape orientation. Thus making the rest of
  of the doc display with wide wasted blank side borders. Also makes zoom shift off screen.
* Chapter covers are in colour, and were screened images. In the pdf (eg pg 334) there is residual moire patterning of gray
  areas. Also no attempt was made to posterize flat colours, so things like the brown colour area are full of jpg patterning noise.

* Due to it being one hugely long pdf of several hundred pages, zoom and scroll are extremely touchy, and can throw you a long way off your current position easily.

* It has a "Digitally signed by http://www.aa4df.com" crud on PDF pg 325.
  http://www.aa4df.com  is a parked domain. So what was the fricking point?

* The file name 7854_ops_sm.pdf implies Ops and Service manual, but it is only an ops-programming manual. No service info.
  The manual title page says:
   7854 Oscilloscope
   Operators Manual
     with Waveform Calculator.
   070-2873-00         First printing JAN 1980
   Product Group 42    Revised AUG 1986

-------------------------------

http://www.greendyk.nl/hp97/index.php
This is HEWLETT-PACKARD  HP-97 programmable Printing Calculator Owner’s Handbook  and Programming Guide October 1976

It's *very* well done in html. Except:
* Page loads are extremely slow, even small images are abysmally slow.
* Fatally, there's no facility to download the thing as one portable file.
* It has all been OCR'd, so there's no assurance of veracity to original appearance.
  Of course there are OCR errors. For eg on the title page (pg 1) the title is:
    "The HP-97 Prgrammable Printing Calculator"
  Prgrammable ?  So one can assume there will be other errors. In a programming manual. Great.

http://www.greendyk.nl/   Oh god... this guy has swallowed the MS 'Metro' shit-pill.
  Ha ha, new meaning for 'MS' - Metro Shit.
  The author has a lot of nicely done content. None of it in portable form though.

Collecting old scopes, logic analyzers, and unfinished projects. http://everist.org
 

Offline paf

  • Contributor
  • Posts: 47
Re: Reverse Polish Notation - need to learn.
« Reply #20 on: February 22, 2016, 02:36:56 pm »
Get an old HP calculator manual or a Forth Book.

How to convert from algebraic "normal" notation to RPN:
Write number by number and after each number write "what" that number is doing to the other numbers that you have already written.


Examples (with comments like this): 

Example 1:
3*2+5

3       ( no operation because no numbers available )
2 *    ( the 2 is doing * to the previous number )
5 +    ( the 5 is doing + to the previous number )

Result:
3 2 * 5 + 

Example 2:

3*2+5*4

3      ( nothing )
2  *  ( the 2 is doing a * to the 3  )
5       ( the 5 is not doing anything to the numbers that we have written )
4   *  ( the 4 is doing a * to the 5 )
+      ( and the result is doing a + to the previous  result )

Result:
3 2 *  5 4 * +


Hope that is clear.

 




 

Offline Addicted2AnalogTek

  • Frequent Contributor
  • **
  • Posts: 493
  • Country: us
Re: Reverse Polish Notation - need to learn.
« Reply #21 on: February 23, 2016, 01:29:19 am »
Found this, I think this is what you are after. http://docmesure.free.fr/telecharger.php?dir=Tektronix/Serie%207000/0scillos%207000/7854/&file=7854_ops_sm.pdf

Dammit, that manual was so nice, I now want an original even if I never do own a 7854.
Also, wishing I had an original (so I could do a proper scan, unlike that rather poor one) just makes me sad that now I can't ask Manuals Plus if they have it. Which they probably did.


Well, TH....  I just received my 7854 - which came with a full set of nicely copied manuals.   ;D

In addition to all the info you've compiled for scanned & copied manuals, do you know what the cost is to have such a massive manual professionally copied?  It doesn't seem like there are any high quality PDF format scans of this set.

When stacked and compressed, there is 2.5 inches of manual here.  That's with standard thickness paper, not tek-manual-spec paper.
« Last Edit: February 23, 2016, 01:50:45 am by Addicted2AnalogTek »
 

Offline Addicted2AnalogTek

  • Frequent Contributor
  • **
  • Posts: 493
  • Country: us
Re: Reverse Polish Notation - need to learn.
« Reply #22 on: February 23, 2016, 01:53:32 am »
Get an old HP calculator manual or a Forth Book.

How to convert from algebraic "normal" notation to RPN:
Write number by number and after each number write "what" that number is doing to the other numbers that you have already written.


Examples (with comments like this): 

Example 1:
3*2+5

3       ( no operation because no numbers available )
2 *    ( the 2 is doing * to the previous number )
5 +    ( the 5 is doing + to the previous number )

Result:
3 2 * 5 + 

Example 2:

3*2+5*4

3      ( nothing )
2  *  ( the 2 is doing a * to the 3  )
5       ( the 5 is not doing anything to the numbers that we have written )
4   *  ( the 4 is doing a * to the 5 )
+      ( and the result is doing a + to the previous  result )

Result:
3 2 *  5 4 * +


Hope that is clear.

Seems simple enough to comprehend.  It appears to be simplistic and straightforward. I'm sure there will be some tricks when it comes to more advanced functions, though.

I found a book for under $5 which covers multiple TI and HP calculator models.  I'm about to buy it.  :-+
 

Offline djacobow

  • Super Contributor
  • ***
  • Posts: 1061
  • Country: us
  • takin' it apart since the 70's
Re: Reverse Polish Notation - need to learn.
« Reply #23 on: February 23, 2016, 02:48:41 am »

Seems simple enough to comprehend.  It appears to be simplistic and straightforward. I'm sure there will be some tricks when it comes to more advanced functions, though.


I think you'l find that there are *no* tricks, and that is part of RPN's charm. When using in-fix, you have to remember a potentially complex and subtle order of operations, or else use lots of parentheses. Most of us might remember "PEMDAS" (parentheses, exponents, multiplication, division, addition, subtraction) but in a programming language with lots of operators there can be subtle variations that can bite and annoy you. If you've ever written a grammar and accompanying parser for an in-fix language... you'll know it's work.

Enter RPN. There is no order of operations. Every operation pops its operands directly from the top of the s stack and pushes its results back onto the stack. There's nothing to parse. There may be some special functions to 'rotate' and 'swap' things' position on the stack (so that the next function can access them), but even those can be implemented as a bunch of pops, rearrange and then pushes. Honestly, once you get used to it, you'll think it is _easier_ than infix.

Well, if you get the bug, anyway.
 

Offline chris_leyson

  • Super Contributor
  • ***
  • Posts: 1349
  • Country: wales
Re: Reverse Polish Notation - need to learn.
« Reply #24 on: February 23, 2016, 02:57:37 am »
Like djacobow say, there are no tricks, just use the stack, learn to think.
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5549
  • Country: us
Re: Reverse Polish Notation - need to learn.
« Reply #25 on: February 23, 2016, 03:05:44 am »
Using the stack for floating point is still in use today for matrix calculations for 3D animation and FPU computation in general, most FPUs are RPN based and have their own FP stack.

For 3D graphics, you push parent matrices and child matrices as you go through the skeleton mesh, then you pop the last child and push the child sibling and recuse through the whole skeleton tree and applying the current matrix through the vertex points taking in consideration the weight of the vertex in regards of the parent and child weight influence on that point.
 

Offline TerraHertz

  • Super Contributor
  • ***
  • Posts: 3640
  • Country: au
  • Why shouldn't we question everything?
    • It's not really a Blog
Re: Reverse Polish Notation - need to learn.
« Reply #26 on: February 23, 2016, 04:00:46 am »
Well, TH....  I just received my 7854 - which came with a full set of nicely copied manuals.   ;D

Oh, sorry to hear 'copies'. Were you expecting originals? As a collector like me, I expect you'd rather they were.
Not copied in color of course, so they lost a lot wherever color was used, such as in schematics.

Quote
In addition to all the info you've compiled for scanned & copied manuals, do you know what the cost is to have such a massive manual professionally copied?  It doesn't seem like there are any high quality PDF format scans of this set.
No idea. But how did they deal with large foldout pages? I have one manual (for a non-Tek scope) from Manuals Plus, that is a careful hand made copy. Done by someone before Manuals Plus got it. It's almost all fold-outs, all stickytaped together. It's a pain to use, and will eventually disintegrate as the tape ages. But it was the only one for that scope I could find anywhere.

One problem with photocopies. If you keep them in any binder with PVC covers, the plasticiser from the PVC diffuses into the thermally melted-on toner deposits, and makes them sticky. Diffusion passes through several sheets of paper, and so the front and rear few pages all get ruined by text contact transferring between facing pages.
A solution is to put some old magazines at front and back, spacing the binder covers away from the photocopied pages.

Quote
When stacked and compressed, there is 2.5 inches of manual here.  That's with standard thickness paper, not tek-manual-spec paper.
So, it took someone a loooong time. All for what - a single new copy, way below the quality of the original, and with zero historical value. And there *will* be a few messed-up pages. Waste of effort I think.
Collecting old scopes, logic analyzers, and unfinished projects. http://everist.org
 

Offline Addicted2AnalogTek

  • Frequent Contributor
  • **
  • Posts: 493
  • Country: us
Re: Reverse Polish Notation - need to learn.
« Reply #27 on: February 23, 2016, 04:25:32 am »
Well, TH....  I just received my 7854 - which came with a full set of nicely copied manuals.   ;D

Oh, sorry to hear 'copies'. Were you expecting originals? As a collector like me, I expect you'd rather they were.
Not copied in color of course, so they lost a lot wherever color was used, such as in schematics.

Yes, I much rather they were genuine of course.  I don't care if I have copies, I am still going to buy the originals as I find them for reasonable prices. Preferably auctions that start under $10usd..   ;)


Quote
But how did they deal with large foldout pages? I have one manual (for a non-Tek scope) from Manuals Plus, that is a careful hand made copy. Done by someone before Manuals Plus got it. It's almost all fold-outs, all stickytaped together. It's a pain to use, and will eventually disintegrate as the tape ages. But it was the only one for that scope I could find anywhere.

Well that sucks!!  I guess you'll be stuck re-taping it sometime since it's pointless to make single page copies out of those...  There are a few pictures of the copied manuals in the listing... here's the link.
http://www.ebay.com/itm/Tektronix-7854-Oscilloscope-Mainframe-with-Waveform-Calculator-for-Repair-/291679909626?_trksid=p2047675.l2557&ssPageName=STRK%3AMEBIDX%3AIT&nma=true&si=cZheso%252BTqMILxftiQZIuAGiBXu4%253D&orig_cvip=true&rt=nc

They're actually not bad.  Probably the best set of copies I've seen thus far, actually.  Of course there's the ' no color ' issue, but at least they used grayscale and the once-color text is dark enough to clearly read.  -- and they're actually properly bound like originals.


Quote
So, it took someone a loooong time. All for what - a single new copy, way below the quality of the original, and with zero historical value. And there *will* be a few messed-up pages. Waste of effort I think.

Ehhh...  at least I have something to go off of for now so I'm not in a huge rush to buy originals! I could EASILY have had to spend more than I paid for the scope and shipping for a set of manuals...

 - I also got a good 7B87 for $30 extra.  Plus another free copied manual.... I suppose at least they knew what they're worth!!  hahaha
 

Offline chris_leyson

  • Super Contributor
  • ***
  • Posts: 1349
  • Country: wales
Re: Reverse Polish Notation - need to learn.
« Reply #28 on: February 25, 2016, 08:32:47 pm »
TEK 7854 GPIB now working  :) Took eight MC3448As of two GPIB boards, tested them, all OK, fitted turned pin sockets and put them back onto the boards. Using Agilent 82357B and Keysight interactive IO Version 17.2. Last time I used the 82357B I could only talk to a 7D20 and not the 7854 for some reason.

Over 700Mbytes of software and an 82357B, seems like overkill to send and receive a few ASCII encoded serial streams  :--
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf