Reverse Polish Notation - need to learn. - Page 1
Forum section: electronics / general

author: Addicted2AnalogTek
author_rank: Frequent Contributor
timestamp: February 20, 2016, 09:38:05 pm
content: 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?

author: amyk
author_rank: Super Contributor
timestamp: February 20, 2016, 10:20:43 pm
content: 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.

author: stealthbanana
author_rank: Newbie
timestamp: February 20, 2016, 11:09:35 pm
content: The way I learned was using FORTH. and reading a few tutorials on the subject.

author: Addicted2AnalogTek
author_rank: Frequent Contributor
timestamp: February 20, 2016, 11:14:50 pm
content: Quote from: amyk on February 20, 2016, 10:20:43 pmI 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.

author: Addicted2AnalogTek
author_rank: Frequent Contributor
timestamp: February 20, 2016, 11:20:07 pm
content: Quote from: HAL-42b on February 20, 2016, 10:22:05 pmOh, 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!

author: rrinker
author_rank: Super Contributor
timestamp: February 20, 2016, 11:50:04 pm
content: 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.

author: djacobow
author_rank: Super Contributor
timestamp: February 21, 2016, 12:25:07 am
content: 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.

author: IanB
author_rank: Super Contributor
timestamp: February 21, 2016, 12:40:19 am
content: Quote from: Addicted2AnalogTek on February 20, 2016, 09:38:05 pmRPN isn't really a language, it's just a notation. There are three possible notations:Prefix: + 2 3Infix: 2 + 3Postfix: 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.

author: helius
author_rank: Super Contributor
timestamp: February 21, 2016, 12:59:18 am
content: Quote from: IanB on February 21, 2016, 12:40:19 amTrue, but...QuoteOnce you're speaking of "memories", "variables", "performing calculations" or "writing algorithms", youarein 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.)

author: djacobow
author_rank: Super Contributor
timestamp: February 21, 2016, 01:07:39 am
content: Quote from: IanB on February 21, 2016, 12:40:19 amWell, 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 + INVAnd it leaves 3.33333 on the stackBut I could also do:<< INV SWAP INV + INV >> 'REQ' STOAnd I'd now have a little program called REQ in memory.Then I can do10 5 REQand 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)

author: rdl
author_rank: Super Contributor
timestamp: February 21, 2016, 10:09:05 am
content: Quote from: Addicted2AnalogTek on February 20, 2016, 11:14:50 pmUnderstandable, since there is mounting evidence that real books are probably better.

author: chris_leyson
author_rank: Super Contributor
timestamp: February 21, 2016, 10:49:54 am
content: 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.

author: Addicted2AnalogTek
author_rank: Frequent Contributor
timestamp: February 21, 2016, 02:41:34 pm
content: Quote from: chris_leyson on February 21, 2016, 10:49:54 amAfter 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.

author: chris_leyson
author_rank: Super Contributor
timestamp: February 21, 2016, 04:56:27 pm
content: 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.pdfCan't seem to read my CD from Artek Manuals, damn Windows.

author: Addicted2AnalogTek
author_rank: Frequent Contributor
timestamp: February 21, 2016, 05:06:51 pm
content: Quote from: chris_leyson on February 21, 2016, 04:56:27 pmOh, 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!

author: Wytnucls
author_rank: Super Contributor
timestamp: February 21, 2016, 07:23:17 pm
content: Have a look at this manual:http://www.greendyk.nl/hp97/index.php

author: AlxDroidDev
author_rank: Frequent Contributor
timestamp: February 21, 2016, 07:25:33 pm
content: Just start programming like Yoda talks. That's pretty much it.(sorry, couldn't resist!)

author: Addicted2AnalogTek
author_rank: Frequent Contributor
timestamp: February 22, 2016, 01:22:32 am
content: 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....

author: TerraHertz
author_rank: Super Contributor
timestamp: February 22, 2016, 01:22:28 pm
content: Quote from: chris_leyson on February 21, 2016, 04:56:27 pmDammit, 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

author: paf
author_rank: Regular Contributor
timestamp: February 22, 2016, 02:36:56 pm
content: 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+53 ( 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*43 ( 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.

author: Addicted2AnalogTek
author_rank: Frequent Contributor
timestamp: February 23, 2016, 01:29:19 am
content: Quote from: TerraHertz on February 22, 2016, 01:22:28 pmWell, TH.... I just received my 7854 - which came with a full set of nicely copied manuals.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.

author: Addicted2AnalogTek
author_rank: Frequent Contributor
timestamp: February 23, 2016, 01:53:32 am
content: Quote from: paf on February 22, 2016, 02:36:56 pmSeems 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.

author: djacobow
author_rank: Super Contributor
timestamp: February 23, 2016, 02:48:41 am
content: Quote from: Addicted2AnalogTek on February 23, 2016, 01:53:32 amI 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.

author: chris_leyson
author_rank: Super Contributor
timestamp: February 23, 2016, 02:57:37 am
content: Like djacobow say, there are no tricks, just use the stack, learn to think.

author: miguelvp
author_rank: Super Contributor
timestamp: February 23, 2016, 03:05:44 am
content: 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.

author: TerraHertz
author_rank: Super Contributor
timestamp: February 23, 2016, 04:00:46 am
content: Quote from: Addicted2AnalogTek on February 23, 2016, 01:29:19 amOh, 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.QuoteNo 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.QuoteSo, 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.

author: Addicted2AnalogTek
author_rank: Frequent Contributor
timestamp: February 23, 2016, 04:25:32 am
content: Quote from: TerraHertz on February 23, 2016, 04:00:46 amYes, 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..QuoteWell 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=ncThey'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.QuoteEhhh... 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

author: chris_leyson
author_rank: Super Contributor
timestamp: February 25, 2016, 08:32:47 pm
content: TEK 7854 GPIB now workingTook 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