Home » Archimedes archive » Acorn User » AU 1997-05 B.adf » Regulars » RTR/Peak2
RTR/Peak2
This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.
Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.
Tape/disk: | Home » Archimedes archive » Acorn User » AU 1997-05 B.adf » Regulars |
Filename: | RTR/Peak2 |
Read OK: | ✔ |
File size: | 04BD bytes |
Load address: | 0000 |
Exec address: | 0000 |
File contents
10REM> Peak1 20DIM PBK% 5,PBA% 4,PBD% 3,Gain%(5),Scale%(6) 30 40PRINT "Peak Detector 2 programmable gain amplifier" 50PRINT "By Mike Cook" 60PRINT "You need an IIC interface and" 70PRINT "The hardware described in the May 97 Acorn User" 80PRINT "Press SPACE for each reading" 90PROCinit 100REM Set up the control register 110REM read only Channel 0 120Offset%=0 : REM The measured DC offset 130?PBA%=0 140SYS "IIC_Control",&90,PBA%,1 150REPEAT 160G%=0 170 REPEAT 180PBD%?0=&80 OR G% 190PBD%?1=G% 200 210REM Discharge Capacitor 220SYS "IIC_Control",&70,PBD%,1 230REM Remove the short 240SYS "IIC_Control",&70,PBD%+1,1 250PROCdel 260REM Read the A/D 270SYS "IIC_Control",&91,PBK%,3 280Read%=PBK%?2 290G%+=1 300PRINT;Read%;" - "; 310UNTIL Read%>&80 OR G%=5 320G%-=1 330Val%=(Read%-Offset%) * Scale%(G%) 340PRINT 350PRINT "Hex ";~Val%;" Decimal ";Val%;" ";G% 360FOR A%=1 TO 30 370PROCdel 380NEXT 390UNTIL FALSE 400END 410 420DEF PROCdel 430LOCAL T% 440T%=TIME+1 450REPEAT UNTIL TIME>T% 460ENDPROC 470 480DEF PROCinit 490REM Set up Gain bit pattern 500Scale%(0)=16 : REM multiplacation factor for gain of 1 510Scale%(1)=8 : REM multiplacation factor for gain of 2 520Scale%(2)=4 : REM multiplacation factor for gain of 4 530Scale%(3)=2 : REM multiplacation factor for gain of 8 540Scale%(4)=1 : REM multiplacation factor for gain of 16 550ENDPROC
�> Peak1 -� PBK% 5,PBA% 4,PBD% 3,Gain%(5),Scale%(6) (3� "Peak Detector 2 programmable gain amplifier" 2� "By Mike Cook" <%� "You need an IIC interface and" F7� "The hardware described in the May 97 Acorn User" P$� "Press SPACE for each reading" Z �init d!� Set up the control register n� read only Channel 0 x(Offset%=0 : � The measured DC offset �?PBA%=0 �ș "IIC_Control",&90,PBA%,1 �� �G%=0 � � �PBD%?0=&80 � G% � PBD%?1=G% � �� Discharge Capacitor �ș "IIC_Control",&70,PBD%,1 �� Remove the short �!ș "IIC_Control",&70,PBD%+1,1 ��del � Read the A/D ș "IIC_Control",&91,PBK%,3 Read%=PBK%?2 " G%+=1 ,�;Read%;" - "; 6� Read%>&80 � G%=5 @ G%-=1 J%Val%=(Read%-Offset%) * Scale%(G%) T� ^/� "Hex ";~Val%;" Decimal ";Val%;" ";G% h� A%=1 � 30 r�del |� �� � �� � � � �del �� T% � T%=�+1 �� � �>T% �� � �� �init �� Set up Gain bit pattern �8Scale%(0)=16 : � multiplacation factor for gain of 1 �7Scale%(1)=8 : � multiplacation factor for gain of 2 7Scale%(2)=4 : � multiplacation factor for gain of 4 7Scale%(3)=2 : � multiplacation factor for gain of 8 8Scale%(4)=1 : � multiplacation factor for gain of 16 &� �
00000000 0d 00 0a 0c f4 3e 20 50 65 61 6b 31 0d 00 14 2d |.....> Peak1...-| 00000010 de 20 50 42 4b 25 20 35 2c 50 42 41 25 20 34 2c |. PBK% 5,PBA% 4,| 00000020 50 42 44 25 20 33 2c 47 61 69 6e 25 28 35 29 2c |PBD% 3,Gain%(5),| 00000030 53 63 61 6c 65 25 28 36 29 0d 00 1e 04 0d 00 28 |Scale%(6)......(| 00000040 33 f1 20 22 50 65 61 6b 20 44 65 74 65 63 74 6f |3. "Peak Detecto| 00000050 72 20 32 20 70 72 6f 67 72 61 6d 6d 61 62 6c 65 |r 2 programmable| 00000060 20 67 61 69 6e 20 61 6d 70 6c 69 66 69 65 72 22 | gain amplifier"| 00000070 0d 00 32 14 f1 20 22 42 79 20 4d 69 6b 65 20 43 |..2.. "By Mike C| 00000080 6f 6f 6b 22 0d 00 3c 25 f1 20 22 59 6f 75 20 6e |ook"..<%. "You n| 00000090 65 65 64 20 61 6e 20 49 49 43 20 69 6e 74 65 72 |eed an IIC inter| 000000a0 66 61 63 65 20 61 6e 64 22 0d 00 46 37 f1 20 22 |face and"..F7. "| 000000b0 54 68 65 20 68 61 72 64 77 61 72 65 20 64 65 73 |The hardware des| 000000c0 63 72 69 62 65 64 20 69 6e 20 74 68 65 20 4d 61 |cribed in the Ma| 000000d0 79 20 39 37 20 41 63 6f 72 6e 20 55 73 65 72 22 |y 97 Acorn User"| 000000e0 0d 00 50 24 f1 20 22 50 72 65 73 73 20 53 50 41 |..P$. "Press SPA| 000000f0 43 45 20 66 6f 72 20 65 61 63 68 20 72 65 61 64 |CE for each read| 00000100 69 6e 67 22 0d 00 5a 09 f2 69 6e 69 74 0d 00 64 |ing"..Z..init..d| 00000110 21 f4 20 53 65 74 20 75 70 20 74 68 65 20 63 6f |!. Set up the co| 00000120 6e 74 72 6f 6c 20 72 65 67 69 73 74 65 72 0d 00 |ntrol register..| 00000130 6e 19 f4 20 72 65 61 64 20 6f 6e 6c 79 20 43 68 |n.. read only Ch| 00000140 61 6e 6e 65 6c 20 30 0d 00 78 28 4f 66 66 73 65 |annel 0..x(Offse| 00000150 74 25 3d 30 20 3a 20 f4 20 54 68 65 20 6d 65 61 |t%=0 : . The mea| 00000160 73 75 72 65 64 20 44 43 20 6f 66 66 73 65 74 0d |sured DC offset.| 00000170 00 82 0b 3f 50 42 41 25 3d 30 0d 00 8c 1f c8 99 |...?PBA%=0......| 00000180 20 22 49 49 43 5f 43 6f 6e 74 72 6f 6c 22 2c 26 | "IIC_Control",&| 00000190 39 30 2c 50 42 41 25 2c 31 0d 00 96 05 f5 0d 00 |90,PBA%,1.......| 000001a0 a0 08 47 25 3d 30 0d 00 aa 06 20 f5 0d 00 b4 13 |..G%=0.... .....| 000001b0 50 42 44 25 3f 30 3d 26 38 30 20 84 20 47 25 0d |PBD%?0=&80 . G%.| 000001c0 00 be 0d 50 42 44 25 3f 31 3d 47 25 0d 00 c8 05 |...PBD%?1=G%....| 000001d0 20 0d 00 d2 19 f4 20 44 69 73 63 68 61 72 67 65 | ..... Discharge| 000001e0 20 43 61 70 61 63 69 74 6f 72 0d 00 dc 1f c8 99 | Capacitor......| 000001f0 20 22 49 49 43 5f 43 6f 6e 74 72 6f 6c 22 2c 26 | "IIC_Control",&| 00000200 37 30 2c 50 42 44 25 2c 31 0d 00 e6 16 f4 20 52 |70,PBD%,1..... R| 00000210 65 6d 6f 76 65 20 74 68 65 20 73 68 6f 72 74 0d |emove the short.| 00000220 00 f0 21 c8 99 20 22 49 49 43 5f 43 6f 6e 74 72 |..!.. "IIC_Contr| 00000230 6f 6c 22 2c 26 37 30 2c 50 42 44 25 2b 31 2c 31 |ol",&70,PBD%+1,1| 00000240 0d 00 fa 08 f2 64 65 6c 0d 01 04 12 f4 20 52 65 |.....del..... Re| 00000250 61 64 20 74 68 65 20 41 2f 44 0d 01 0e 1f c8 99 |ad the A/D......| 00000260 20 22 49 49 43 5f 43 6f 6e 74 72 6f 6c 22 2c 26 | "IIC_Control",&| 00000270 39 31 2c 50 42 4b 25 2c 33 0d 01 18 10 52 65 61 |91,PBK%,3....Rea| 00000280 64 25 3d 50 42 4b 25 3f 32 0d 01 22 09 47 25 2b |d%=PBK%?2..".G%+| 00000290 3d 31 0d 01 2c 12 f1 3b 52 65 61 64 25 3b 22 20 |=1..,..;Read%;" | 000002a0 2d 20 22 3b 0d 01 36 16 fd 20 52 65 61 64 25 3e |- ";..6.. Read%>| 000002b0 26 38 30 20 84 20 47 25 3d 35 0d 01 40 09 47 25 |&80 . G%=5..@.G%| 000002c0 2d 3d 31 0d 01 4a 25 56 61 6c 25 3d 28 52 65 61 |-=1..J%Val%=(Rea| 000002d0 64 25 2d 4f 66 66 73 65 74 25 29 20 2a 20 53 63 |d%-Offset%) * Sc| 000002e0 61 6c 65 25 28 47 25 29 0d 01 54 05 f1 0d 01 5e |ale%(G%)..T....^| 000002f0 2f f1 20 22 48 65 78 20 22 3b 7e 56 61 6c 25 3b |/. "Hex ";~Val%;| 00000300 22 20 44 65 63 69 6d 61 6c 20 22 3b 56 61 6c 25 |" Decimal ";Val%| 00000310 3b 22 20 20 20 20 20 20 22 3b 47 25 0d 01 68 0f |;" ";G%..h.| 00000320 e3 20 41 25 3d 31 20 b8 20 33 30 0d 01 72 08 f2 |. A%=1 . 30..r..| 00000330 64 65 6c 0d 01 7c 05 ed 0d 01 86 07 fd 20 a3 0d |del..|....... ..| 00000340 01 90 05 e0 0d 01 9a 04 0d 01 a4 0a dd 20 f2 64 |............. .d| 00000350 65 6c 0d 01 ae 08 ea 20 54 25 0d 01 b8 0a 54 25 |el..... T%....T%| 00000360 3d 91 2b 31 0d 01 c2 0c f5 20 fd 20 91 3e 54 25 |=.+1..... . .>T%| 00000370 0d 01 cc 05 e1 0d 01 d6 04 0d 01 e0 0b dd 20 f2 |.............. .| 00000380 69 6e 69 74 0d 01 ea 1d f4 20 53 65 74 20 75 70 |init..... Set up| 00000390 20 47 61 69 6e 20 62 69 74 20 70 61 74 74 65 72 | Gain bit patter| 000003a0 6e 0d 01 f4 38 53 63 61 6c 65 25 28 30 29 3d 31 |n...8Scale%(0)=1| 000003b0 36 20 3a 20 f4 20 6d 75 6c 74 69 70 6c 61 63 61 |6 : . multiplaca| 000003c0 74 69 6f 6e 20 66 61 63 74 6f 72 20 66 6f 72 20 |tion factor for | 000003d0 67 61 69 6e 20 6f 66 20 31 0d 01 fe 37 53 63 61 |gain of 1...7Sca| 000003e0 6c 65 25 28 31 29 3d 38 20 3a 20 f4 20 6d 75 6c |le%(1)=8 : . mul| 000003f0 74 69 70 6c 61 63 61 74 69 6f 6e 20 66 61 63 74 |tiplacation fact| 00000400 6f 72 20 66 6f 72 20 67 61 69 6e 20 6f 66 20 32 |or for gain of 2| 00000410 0d 02 08 37 53 63 61 6c 65 25 28 32 29 3d 34 20 |...7Scale%(2)=4 | 00000420 3a 20 f4 20 6d 75 6c 74 69 70 6c 61 63 61 74 69 |: . multiplacati| 00000430 6f 6e 20 66 61 63 74 6f 72 20 66 6f 72 20 67 61 |on factor for ga| 00000440 69 6e 20 6f 66 20 34 0d 02 12 37 53 63 61 6c 65 |in of 4...7Scale| 00000450 25 28 33 29 3d 32 20 3a 20 f4 20 6d 75 6c 74 69 |%(3)=2 : . multi| 00000460 70 6c 61 63 61 74 69 6f 6e 20 66 61 63 74 6f 72 |placation factor| 00000470 20 66 6f 72 20 67 61 69 6e 20 6f 66 20 38 0d 02 | for gain of 8..| 00000480 1c 38 53 63 61 6c 65 25 28 34 29 3d 31 20 3a 20 |.8Scale%(4)=1 : | 00000490 f4 20 6d 75 6c 74 69 70 6c 61 63 61 74 69 6f 6e |. multiplacation| 000004a0 20 66 61 63 74 6f 72 20 66 6f 72 20 67 61 69 6e | factor for gain| 000004b0 20 6f 66 20 31 36 0d 02 26 05 e1 0d ff | of 16..&....| 000004bd