## Beep formula in manual incorrect??? (Solved)

### Beep formula in manual incorrect??? (Solved)

In the manual it states that Frequency=921600/(78+2*y%)Hz) gives the frequency, but this doesn’t give a correct Hz output here, I have checked a few values, for example if you put y% as 440 the result is given as 962 (rounded to int) but if you enter this into the beep parameter then it is not returning a Hz frequency of 440, an actual value of 1007 gives 440 Hz.

Also in the Mike Shaw Using and Programming book the formula is given as Frequency =921600/frequency)-39 but this is not quite correct either, though a lot closer.

The Dabhand LZ book has the same formula as the Psion manual, and gives examples of beep settings as they relate to musical notes, but they are all wrong too.

Anyone care to check this? It seems strange that this published info is wrong.

Edit: The formula is correct but returns the beep frequency after entering a Hz frequency, not the other way around.

Also in the Mike Shaw Using and Programming book the formula is given as Frequency =921600/frequency)-39 but this is not quite correct either, though a lot closer.

The Dabhand LZ book has the same formula as the Psion manual, and gives examples of beep settings as they relate to musical notes, but they are all wrong too.

Anyone care to check this? It seems strange that this published info is wrong.

Edit: The formula is correct but returns the beep frequency after entering a Hz frequency, not the other way around.

Last edited by Daren on Thu Nov 24, 2022 6:30 pm, edited 3 times in total.

### Re: Beep formula in manual is incorrect???

So I calculated A0 to G#6 a few weeks ago by entering the formula from manual into the solver on my TI-89 and running it for each interval. I lost the list stored in my PII when it crashed but luckily I still have the post-it's handy

If I look for A4 (440hz) I can see that the TI-84 returned a value of 1008.27, which I reckon is close enough to 1007.

This is how it's entered into the equation solver if you want to try it yourself: You enter the desired Hz value for the X variable, move the cursor to the empty Y variable and then hit F2 (or whatever "solve" is on your calculator). After it spends a bit of time thinking it will populate the Y variable with the correct BEEP value - at least that's been my experience

If I look for A4 (440hz) I can see that the TI-84 returned a value of 1008.27, which I reckon is close enough to 1007.

This is how it's entered into the equation solver if you want to try it yourself: You enter the desired Hz value for the X variable, move the cursor to the empty Y variable and then hit F2 (or whatever "solve" is on your calculator). After it spends a bit of time thinking it will populate the Y variable with the correct BEEP value - at least that's been my experience

### Re: Beep formula in manual is incorrect???

I have a feeling the y% is the 'pitch' of the beep, the manual should explain it better...

### Re: Beep formula in manual is incorrect???

Thanks @jarrydn I think the Dabhand book led me to believe the manual formula was incorrect but actually it is correct, just works the opposite way I expected

@xchris - spot on!

The Dabhand book is still wrong though as it has the wrong note frequencies, the Shaw book is correct aside from the note frequency is out by a factor of 2.

I’ll write up a little OPL program to allow entering of desired Hz frequency and returning the number to enter for Beep.

Your calculation is actually more accurate than mine, I was just using a tuner to arrive at 1007 for 440Hz.

@xchris - spot on!

The Dabhand book is still wrong though as it has the wrong note frequencies, the Shaw book is correct aside from the note frequency is out by a factor of 2.

I’ll write up a little OPL program to allow entering of desired Hz frequency and returning the number to enter for Beep.

Your calculation is actually more accurate than mine, I was just using a tuner to arrive at 1007 for 440Hz.

### Re: Beep formula in manual incorrect??? (Solved)

With a bit of algebra you can rearrange for y:

y% = (460800/x) - 39

Where x is the frequency in Hz

y% = (460800/x) - 39

Where x is the frequency in Hz

- MartinReid
**Posts:**218**Joined:**Wed Jan 27, 2021 3:44 pm

### Beep formula in manual (which manual)?

Daren

There is definately something going on with the 'frequency' of the beep.. There are descrepencies between the PSION manuals. Below is the result of a search through all the available manuals (in publication date order)..

Sincerely

Martin

There is definately something going on with the 'frequency' of the beep.. There are descrepencies between the PSION manuals. Below is the result of a search through all the available manuals (in publication date order)..

Code: Select all

```
BEEP <exp%1>,<exp%2>
CM/XP (Version 1) Frequency = 921100/(78+2*<exp%1>)Hz
CM/XP (French) Fréquence = 921600/(78+<exp%2>)Hz
CM/XP (Version 2) Frequency = 921100/(78+2*<exp%2>)Hz
CM/XP (Italian) Frequenza = 921600/(78+2*<exp%2>)Hz
BEEP <exp1%>,<exp2%>
CM/XP (version 3) Frequency = 921600/(78+2*<exp2%>)Hz
BEEP x%,y%
LZ/LZ64 (programming) Frequency = 921600/(78+2*y%)Hz
```

Sincerely

Martin

### Re: Beep formula in manual incorrect??? (Solved)

@MartinP very elegant, maths/algebra is not my strong point so I have no idea how that works but it does.

Yes @MartinReid it is strange, I also noticed from some of the promo leaflets that the specifications of the audio frequency changed - the 1986 brochure has it listed as 11hz-10khz, this is the same for subsequent brochures until 1989 when it changes to 300hz-10khz, I guess this could be a change to the piezo element over the production period, maybe they changed to a part with a different usable frequency range - although piezo elements can't really go that low.

I created this program NTOB (

Yes @MartinReid it is strange, I also noticed from some of the promo leaflets that the specifications of the audio frequency changed - the 1986 brochure has it listed as 11hz-10khz, this is the same for subsequent brochures until 1989 when it changes to 300hz-10khz, I guess this could be a change to the piezo element over the production period, maybe they changed to a part with a different usable frequency range - although piezo elements can't really go that low.

I created this program NTOB (

**N**ote**TO****B**eep) to return beep values for a given Hz value, I checked it and it gives accurate results, the result is truncated to 2 decimal places, as this gives sufficient precision.Code: Select all

```
NTOB:
LOCAL X,B,KEY%
START::
PRINT "Enter Note in Hz"
INPUT X
B=(921600/X/2)-39
B=INTF(B*100+0.5)/100
CLS
PRINT X,"Hz ="
PRINT "Beep Frequency"
PRINT B
PRINT "Again? [Y][N]"
AGAIN::
KSTAT 1
KEY%=GET
IF KEY%=%Y
CLS
GOTO START::
ELSEIF KEY%=%N
ELSE GOTO AGAIN::
RETURN
ENDIF
```

- Zenerdiode
**Posts:**5**Joined:**Mon Nov 07, 2022 10:15 pm**Location:**Newcastle, England

### Re: Beep formula in manual incorrect??? (Solved)

I wonder if we hear harmonics, as the input to the piezo is most likely a square wave? I remember as a boy doing frequency sweeps on my XP by increasing/decreasing the value in DO-UNTIL loops - and it never did sound quite as you’d expect.

I also tried to produce a DTMF tone, but that too was disastrous

I also tried to produce a DTMF tone, but that too was disastrous

### Re: Beep formula in manual incorrect??? (Solved)

Just in case people haven't noticed, the figure 921600 is the CPU clock rate, which is set from an external quartz crystal at 3.6864 MHz. The Quartz crystal frequency is divided by 4 in the CPU to get to 921600 Hz. The CPU clock rate gets further divided by 96 to provide the 9600 maximum baud rate for the serial interface; so the 921100 figures in the older manuals were probably typos, which got fixed in the later manuals.

I'm assuming the BEEP is a pulse width modulated (PWM) signal and the CPU doesn't have a hardware PWM generator; so I'm guessing that the 39 (or 78) offset is a correction for the CPU coding overhead in producing a PWM signal?

I think there will be loads of harmonics, and that might also explain why a factor of 2 in some of the formulas is not that critical?

With a tuner (or oscilloscope) it should be possible to check the tuning over a range of frequencies and produce a calibration to adjust the formula, if needed.

Martin P.

I'm assuming the BEEP is a pulse width modulated (PWM) signal and the CPU doesn't have a hardware PWM generator; so I'm guessing that the 39 (or 78) offset is a correction for the CPU coding overhead in producing a PWM signal?

I think there will be loads of harmonics, and that might also explain why a factor of 2 in some of the formulas is not that critical?

With a tuner (or oscilloscope) it should be possible to check the tuning over a range of frequencies and produce a calibration to adjust the formula, if needed.

Martin P.

### Re: Beep formula in manual incorrect??? (Solved)

@MartinP I think I read in the technical manual that beep is derived from the alarm signal which is formed from a divider. Makes sense what you said about the number coming from CPU, though I did not twig before.

In my tests using the formula it seems quite accurate, the next challenge is to figure out a way of putting in a note as a variable say F then having it work out each octave, so in theory 12 variables are needed, one for each note, then a variable for the octave which doubles the hz frequency for each octave, then apply the beep frequency formula to that.

One other point of interest is that the beep signal when set sufficiently long (over about 500ms) it can be heard to ‘stutter” presumably because something else is needing a clock cycle. It is a bit annoying but I don’t think there is any way to avoid it.

In my tests using the formula it seems quite accurate, the next challenge is to figure out a way of putting in a note as a variable say F then having it work out each octave, so in theory 12 variables are needed, one for each note, then a variable for the octave which doubles the hz frequency for each octave, then apply the beep frequency formula to that.

One other point of interest is that the beep signal when set sufficiently long (over about 500ms) it can be heard to ‘stutter” presumably because something else is needing a clock cycle. It is a bit annoying but I don’t think there is any way to avoid it.