home *** CD-ROM | disk | FTP | other *** search
/ HTBasic 9.3 / HTBasic 9.3.iso / 83win / data1.cab / Basic_Plus_Examples / FREQRESP < prev    next >
Encoding:
Text File  |  2001-03-02  |  2.2 KB  |  62 lines

  1. 10    ! ************************************************************
  2. 20    ! Example: Frequency Response
  3. 30    !
  4. 40    ! This program generates a theoretical frequency response
  5. 50    ! display (response in dB vs. frequency in Hz) for two channels.
  6. 60    !
  7. 70    ! ************************************************************
  8. 80    !
  9. 90       REAL Freq(1:31),Channel_1(1:31),Channel_2(1:31)
  10. 100   !
  11. 110   ! Define test frequencies.
  12. 120   !
  13. 130       DATA 20,25,32,40,50,63,80,100,125,160
  14. 140       DATA 200,250,320,400,500,630,800,1000,1250,1600
  15. 150       DATA 2000,2500,3200,4000,5000,6300,8000,10000,12500,16000,20000
  16. 160       READ Freq(*)
  17. 170   !
  18. 180   ! Take voltage measurements for both channels, convert to dB.
  19. 190   !
  20. 200       FOR I=1 TO 31
  21. 210           Channel_1(I)=20*LGT(FNMeasure(Freq(I),1))
  22. 220           Channel_2(I)=20*LGT(FNMeasure(Freq(I),2))
  23. 230       NEXT I
  24. 240   !
  25. 250   ! Create and set up the graph
  26. 260   !
  27. 270       ASSIGN @Graph TO WIDGET "XY GRAPH";SET ("SHARED X":1,"VISIBLE":0,"TITLE":" Example: Frequency Response","WIDTH":400,"HEIGHT":300)
  28. 280       CONTROL @Graph;SET ("SYSTEM MENU":"Quit")
  29. 290       ON EVENT @Graph,"SYSTEM MENU" GOTO Finis
  30. 300   !
  31. 310   ! Set X axis attributes
  32. 320   !
  33. 330       CONTROL @Graph;SET ("CURRENT AXIS":"X","AUTOSCALE":1,"LOGARITHMIC":1,"AXIS LABEL":"Frequency (Hz)")
  34. 340   !
  35. 350   ! Set Y axis attributes
  36. 360   !
  37. 370       CONTROL @Graph;SET ("CURRENT AXIS":"Y","AUTOSCALE":1,"AXIS LABEL":"Response (dB)")
  38. 380   !
  39. 390   ! Enter the data into the graph
  40. 400   !
  41. 410       CONTROL @Graph;SET ("X DATA":Freq(*))
  42. 420       CONTROL @Graph;SET ("CURRENT TRACE":1,"Y DATA":Channel_1(*),"TRACE LABEL":"Channel 1")
  43. 430       CONTROL @Graph;SET ("CURRENT TRACE":2,"Y DATA":Channel_2(*),"TRACE LABEL":"Channel 2")
  44. 440   !
  45. 450   ! Display the graph
  46. 460   !
  47. 470       CONTROL @Graph;SET ("VISIBLE":1)
  48. 480       LOOP
  49. 490           WAIT FOR EVENT
  50. 500       END LOOP
  51. 510  Finis: END
  52. 520   !
  53. 530   ! This function simulates some data for the use of this program
  54. 540   !
  55. 550       DEF FNMeasure(Freq,Chan)
  56. 560   !
  57. 570   ! Simulate measured data for second order lowpass filters
  58. 580   !
  59. 590           F=Freq*(.8+Chan/5)
  60. 600           RETURN 1/(1-F/(3000-Chan*400)+(F/3000)^2)
  61. 610       FNEND
  62.