Post Reply 
A shorter Pause (PSE) in a program
01-31-2018, 01:32 AM
Post: #1
A shorter Pause (PSE) in a program
I am writing an HP 41 program to control an AirTherm ATC-0010 relay actuator. The purpose is to randomly activate channels 1 through 8. Part of the program adjusts the speed of the actuations using flag branching to control the speed:

08 LBL 00
09
the random channel selection part of the program
23
24 FS? 01
25 XEQ 01
26 FS? 02
27 XEQ 02
28 FS? 03
29 EXQ 03
30 GTO 00

31 LBL 01
32 RTN
33 LBL 02
34 PSE
35 RTN
36 LBL 03
37 PSE
38 PSE
39 RTN
40 END

I would like to insert an operation between lines 31 & 32 which functions as a half pause.

As it is written the program runs the ATC-0010 at the following speeds:
32 cycles a minute with no flags
30 cycles a minute with flag 1 set
18 cycles a minute with flag 2 set
14 cycles a minute with flag 3 set

I would like to get flag 1 cycle time in the 20s. The stack needs to be undisturbed after the operation since the pseudo random routine I am using relies on Y: 0, X: seed. The other cycle times are about right for the purpose.

Is there such a beast?

Steve
In order of appearance: HP 41CV, CMT-MCGPS, HP 41CX, DM 41, DM 42
Find all posts by this user
Quote this message in a reply
01-31-2018, 02:56 AM
Post: #2
RE: A shorter Pause (PSE) in a program
VIEW X

or perhaps a couple of them? That might adjust the timing.
Find all posts by this user
Quote this message in a reply
01-31-2018, 03:12 AM
Post: #3
RE: A shorter Pause (PSE) in a program
Page 11 of Jeremy Smith's "HP-41 Synthetic Quick Ref Guide" (available on TOS) lists the timing (in mS) for every 41 normal (non-synthetic) instruction.

A PSE lasts 1300 mS; the only other instruction that is close is BEEP (1100 mS), but there are other combinations you can use to take up the desired amount of time, however most instructions are not stack-neutral, so you'll have to select commands which minimally change the stack in ways you may be able to easily correct, something like SDEV followed by RDN (a total of 496 mS).

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
01-31-2018, 03:49 AM
Post: #4
RE: A shorter Pause (PSE) in a program
Or maybe an appropriate even number of X <> Y may help?
Andi
Find all posts by this user
Quote this message in a reply
01-31-2018, 05:09 AM
Post: #5
RE: A shorter Pause (PSE) in a program
Thanks all for the good ideas.

It took 4 VIEW Xs: "Does my program look fat with this code?"
I will try SDEV; RDN next.

Steve
In order of appearance: HP 41CV, CMT-MCGPS, HP 41CX, DM 41, DM 42
Find all posts by this user
Quote this message in a reply
01-31-2018, 05:28 AM (This post was last modified: 01-31-2018 05:33 AM by Thomas Okken.)
Post: #6
RE: A shorter Pause (PSE) in a program
(01-31-2018 03:12 AM)rprosperi Wrote:  however most instructions are not stack-neutral, so you'll have to select commands which minimally change the stack in ways you may be able to easily correct, something like SDEV followed by RDN (a total of 496 mS).

If you want to keep the stack (mostly) intact, SDEV is not a good choice, because it overwrites X and Y, leaving T and Z intact, and saving X in LASTX. Also, you risk an error if the summation registers don't contain valid statistical data.
Maybe use something like PI LN RDN instead, losing T and LASTX? (Avoid trigs for time-wasting as their timing probably depends on the angular mode.)
Visit this user's website Find all posts by this user
Quote this message in a reply
01-31-2018, 06:52 AM
Post: #7
RE: A shorter Pause (PSE) in a program
(01-31-2018 05:28 AM)Thomas Okken Wrote:  
(01-31-2018 03:12 AM)rprosperi Wrote:  however most instructions are not stack-neutral, so you'll have to select commands which minimally change the stack in ways you may be able to easily correct, something like SDEV followed by RDN (a total of 496 mS).

If you want to keep the stack (mostly) intact, SDEV is not a good choice, because it overwrites X and Y, leaving T and Z intact, and saving X in LASTX. Also, you risk an error if the summation registers don't contain valid statistical data.
Maybe use something like PI LN RDN instead, losing T and LASTX? (Avoid trigs for time-wasting as their timing probably depends on the angular mode.)

Yes SDEV; RDN messes with the stack.

Steve
In order of appearance: HP 41CV, CMT-MCGPS, HP 41CX, DM 41, DM 42
Find all posts by this user
Quote this message in a reply
01-31-2018, 08:00 AM (This post was last modified: 01-31-2018 01:33 PM by Dieter.)
Post: #8
RE: A shorter Pause (PSE) in a program
(01-31-2018 01:32 AM)4ster Wrote:  I would like to insert an operation between lines 31 & 32 which functions as a half pause.
...
Is there such a beast?

As already noted, VIEW X plus a command that takes a fraction of a second is the solution. If you want to display X, that is. Maybe the PSE in your program is only supposed to cause a delay and the X-display is not required. Then the VIEW X can be omitted. Also keep in mind that the VIEW display stays on even when the program continues, so a CLD afterwards may clear the display again, if desired.

As far as "delay commands" are concerned I like to do this with 0 SIN or 0 TAN (tan is faster than sin), or several consecutive SIN/TAN in series. Other transcendental functions may work as well (cf. the proposed PI LN), but be sure to provide a defined X-value as the execution time can vary with X. Since 0 SIN or 0 TAN return zero, a final "+" may drop the stack. This preserves three out of four stack registers. Do you need more?

(01-31-2018 01:32 AM)4ster Wrote:  As it is written the program runs the ATC-0010 at the following speeds:
32 cycles a minute with no flags
30 cycles a minute with flag 1 set
18 cycles a minute with flag 2 set
14 cycles a minute with flag 3 set

Let's see. Without any delay commands (and a subroutine call) the program requires 2 seconds per loop. With a PSE it's 3,3 seconds. Which matches the 1,3 seconds that a PSE is supposed to delay. You now want 24 cycles per minute, i.e. 2,5 seconds per loop. So compared to the non-delaying LBL 01 routine you need to add a 0,5 second delay. Or if you want "half a PSE" it's more like 0,6 s. I'd suggest you try 0 SIN + here. You can fine-tune the delay with TAN which is roughly half a SIN delay.

Dieter
Find all posts by this user
Quote this message in a reply
01-31-2018, 01:43 PM
Post: #9
RE: A shorter Pause (PSE) in a program
I didn't examine stack use/needs in the provided program at all; SDEV/RDN was only used as an example of relatively slow commands to take up the desired amount of time. But as noted and inferred above, a series of more obvious commands like X<>X will likely be easier to insert without stack juggling and will certainly be easier to understand a year from now.

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
01-31-2018, 03:17 PM (This post was last modified: 01-31-2018 03:59 PM by 4ster.)
Post: #10
RE: A shorter Pause (PSE) in a program
Thanks again, everyone.

4 VIEW Xs worked with no stack disturbance. That solution operated with slightly more delay than 0 SIN +. Both fit requirements since I am only using X: and Y: in the stack at that point in the program.

So now I have to choose. rprosperi's point about my future self figuring out what was in my mind today is well taken. I've got some real head scratchers from 20+ years ago that I didn't document for my current self: I ended up rewriting one, since it still solved a work related task. I've learned to document better as the mind calcifies.

I think the VIEW X method wins for it's simplicity. It has the added benefit that it is easily adjustable by simply adding or subtracting a VIEW X (or two X<>Ys) to adjust the delay under flag 1.

Again, thank you for the help!

Steve
In order of appearance: HP 41CV, CMT-MCGPS, HP 41CX, DM 41, DM 42
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)