Advertisement
Guest User

HAL file for DRO

a guest
Feb 6th, 2013
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.34 KB | None | 0 0
  1. # pyvcp-dro2.xml chg names of pins from pyvcp.pinname to SES,
  2. # got some errs that 'pyvcp.Xdisplay' not found, so try not to use a name that may be 'spcl
  3. # result:
  4. #tomp@cncbox:~/emc2-head$ halrun pyvcp-dro2.hal
  5. # pyVCP: Creating widgets from pyvcp-dro.xml ... Done.
  6. # Waiting for component 'pyvcp' to become ready (i waited no more than 3 seconds, cuz i saw the dro, and closed it )
  7. # HAL:30: ERROR: pyvcp exited without becoming ready
  8. #
  9. #hmmm, and without renaming to SES, it says like it got done making the pins , tho the names are bad
  10. # tomp@cncbox:~/emc2-head$ halrun pyvcp-dro.hal
  11. # pyVCP: Creating widgets from pyvcp-dro.xml ... Done.
  12. # HAL: ERROR: pin 'pyvcp.Xdisplay' not found
  13. # HAL:113: link failed
  14. # tomp@cncbox:~/emc2-head$
  15.  
  16. # Name of NML file to use, default is emc.nml
  17. NML_FILE = emc.nml
  18.  
  19. #
  20. # three axis PyVCP/HAL DRO configuration
  21. # this uses HAL and PyVCP only, no EMC
  22. #
  23. #
  24. # this assumes software encoder counting, with the encoder
  25. # signals coming in through the parallel port. If you have
  26. # hardware encoder counters, you would load the appropriate
  27. # driver instead
  28.  
  29. # load parport driver
  30. #
  31. loadrt hal_parport cfg="0x0378 in"
  32.  
  33. # load encoder counters
  34. #
  35. loadrt encoder num_chan=3
  36.  
  37. # load mux and sum blocks
  38. #
  39. loadrt mux2 count=3
  40. #
  41. loadrt sum2 count=3
  42.  
  43. # load PyVCP
  44. #
  45. loadusr -Wn SES pyvcp -c SES pyvcp-dro.xml
  46.  
  47.  
  48. # create 20uS and 1mS realtime threads
  49. # the 20uS fast thread means that the DRO can keep
  50. # up with encoder rates of 10-15KHz
  51. #
  52. loadrt threads name1=fast period1=20000 name2=slow period2=1000000
  53.  
  54. #
  55. # add realtime functions to threads
  56. # fast thread first:
  57. addf parport.0.read fast
  58. #
  59. addf encoder.update-counters fast
  60.  
  61. # slow thread next:
  62. #
  63. addf encoder.capture-position slow
  64. addf mux2.0 slow
  65. addf mux2.1 slow
  66. addf mux2.2 slow
  67. addf sum2.0 slow
  68. addf sum2.1 slow
  69. addf sum2.2 slow
  70. addf parport.0.write slow
  71.  
  72. #
  73. # interconnections
  74. #
  75. # NOTE: for demo purposes, I used the old (and still valid)
  76. # "newsig+linksp" syntax for X, and the new "net" syntax
  77. # for Y and Z. The resulting connections are the same, but
  78. # you can see that the "net" syntax is much more compact.
  79. # It is only available in CVS HEAD, but the same is true of
  80. # PyVCP.
  81. #
  82.  
  83. # encoder phase A and B from parport to encoder counter
  84. # X - old syntax:
  85. #
  86. newsig XphaseA bit
  87. linksp XphaseA <= parport.0.pin-02-in
  88. linksp XphaseA => encoder.0.phase-A
  89. newsig XphaseB bit
  90. linksp XphaseB <= parport.0.pin-03-in
  91. linksp XphaseB => encoder.0.phase-B
  92.  
  93. #
  94. # Y - new syntax:
  95. #
  96. net YphaseA parport.0.pin-04-in => encoder.1.phase-A
  97. net YphaseB parport.0.pin-05-in => encoder.1.phase-B
  98. #
  99. # Z - new syntax:
  100. #
  101. net ZphaseA parport.0.pin-06-in => encoder.2.phase-A
  102. net ZphaseB parport.0.pin-07-in => encoder.2.phase-B
  103.  
  104. #
  105. # raw positions from encoders to one input of mux and summer
  106. #
  107. newsig Xpos-raw float
  108. linksp Xpos-raw <= encoder.0.position
  109. linksp Xpos-raw => mux2.0.in1
  110. linksp Xpos-raw => sum2.0.in0
  111. #
  112. net Ypos-raw encoder.1.position => mux2.1.in1 sum2.1.in0
  113. net Zpos-raw encoder.2.position => mux2.2.in1 sum2.2.in0
  114.  
  115. #
  116. # offset position from mux output to other input of mux and summer
  117. #
  118. newsig Xoffset float
  119. linksp Xoffset <= mux2.0.out
  120. linksp Xoffset => mux2.0.in0
  121. linksp Xoffset => sum2.0.in1
  122. net Yoffset mux2.1.out => mux2.1.in0 sum2.1.in1
  123. net Zoffset mux2.2.out => mux2.2.in0 sum2.2.in1
  124. #
  125.  
  126. #
  127. # output of summer is corrected position for display
  128. #
  129. newsig Xpos-corr float
  130. linksp Xpos-corr <= sum2.0.out
  131.  
  132. linksp Xpos-corr => SES.Xdisplay
  133. net Ypos-corr sum2.1.out => SES.Ydisplay
  134. net Zpos-corr sum2.2.out => SES.Zdisplay
  135. #
  136.  
  137. #
  138. # select input of mux comes from "zero" button
  139. #
  140. newsig Xzero bit
  141. linksp Xzero <= SES.Xzerobutton
  142. linksp Xzero => mux2.0.sel
  143. net Yzero SES.Yzerobutton => mux2.1.sel
  144. net Zzero SES.Zzerobutton => mux2.2.sel
  145. #
  146.  
  147. #
  148. # finally, we need to set a few parameters
  149. #
  150. # set the scaling for X, Y, and Z
  151. #
  152. setp encoder.0.position-scale 20000
  153. setp encoder.1.position-scale 20000
  154. setp encoder.2.position-scale 10000
  155. #
  156.  
  157. #
  158. # we want the summer to subtract the offset from the
  159. #
  160. # raw position, so we set the gains appropriately
  161. #
  162. setp sum2.0.gain0 1.0
  163. setp sum2.0.gain1 -1.0
  164. setp sum2.1.gain0 1.0
  165. setp sum2.1.gain1 -1.0
  166. setp sum2.2.gain0 1.0
  167. setp sum2.2.gain1 -1.0
  168. setp parport.0.pin-01-out true
  169. #
  170.  
  171. #
  172. # start realtime execution
  173. #
  174. start
  175. show pin
  176. waitusr SES
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement