My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

RunConfiguration.pde 9.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. /*
  2. TMC26XMotorTest.pde - - TMC26X Stepper Tester for Processing
  3. Copyright (c) 2011, Interactive Matter, Marcus Nowotny
  4. Permission is hereby granted, free of charge, to any person obtaining a copy
  5. of this software and associated documentation files (the "Software"), to deal
  6. in the Software without restriction, including without limitation the rights
  7. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. copies of the Software, and to permit persons to whom the Software is
  9. furnished to do so, subject to the following conditions:
  10. The above copyright notice and this permission notice shall be included in
  11. all copies or substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  18. THE SOFTWARE.
  19. */
  20. Slider speedSlider;
  21. Toggle runToggle;
  22. RadioButton directionButtons;
  23. Toggle enabledToggle;
  24. RadioButton microsteppingButtons;
  25. Slider sgtSlider;
  26. Button sgtPlus;
  27. Button sgtMinus;
  28. Toggle sgFilterToggle;
  29. Slider currentSlider;
  30. Slider coolStepMinSlider;
  31. Slider coolStepMaxSlider;
  32. Toggle coolStepActiveToggle;
  33. RadioButton coolStepIncrementButtons;
  34. RadioButton coolStepDecrementButtons;
  35. RadioButton coolStepMinButtons;
  36. List runControls = new LinkedList();
  37. Button trinamicButton;
  38. Button motionControlButton;
  39. void setupRunConfig() {
  40. //the run configuration
  41. //controlP5.getControlFont().setSize(10); - the font is too small, try to increase it!
  42. //add a button te let the motor run
  43. runToggle = controlP5.addToggle("run", false, 20, 40, 30, 30);
  44. controlElements.add(runToggle);
  45. runToggle.moveTo(runTab);
  46. //add some directions buttons
  47. directionButtons = controlP5.addRadioButton("direction", 20, 90);
  48. controlElements.add(directionButtons);
  49. directionButtons.addItem("forward", 1);
  50. directionButtons.addItem("backward", -1);
  51. directionButtons.activate(0);
  52. directionButtons.moveTo(runTab);
  53. enabledToggle = controlP5.addToggle("enabled", false, 20, 220, 30, 30);
  54. controlElements.add(enabledToggle);
  55. enabledToggle.moveTo(runTab);
  56. // add a vertical slider for speed
  57. speedSlider = controlP5.addSlider("speed", 1, 100, 10, 85, 40, 20, 210);
  58. controlElements.add(speedSlider);
  59. speedSlider.moveTo(runTab);
  60. //ad a multilist for the microstepping setting
  61. microsteppingButtons = controlP5.addRadioButton("microstepping", 150, 40);
  62. controlElements.add(microsteppingButtons);
  63. microsteppingButtons.addItem("m_1/1", 1);
  64. microsteppingButtons.addItem("m_1/2", 2);
  65. microsteppingButtons.addItem("m_1/4", 4);
  66. microsteppingButtons.addItem("m_1/8", 8);
  67. microsteppingButtons.addItem("m_1/16", 16);
  68. microsteppingButtons.addItem("m_1/32", 32);
  69. microsteppingButtons.addItem("m_1/64", 64);
  70. microsteppingButtons.addItem("m_1/128", 128);
  71. microsteppingButtons.addItem("m_1/256", 256);
  72. for (Object o:microsteppingButtons.getItems()) {
  73. Toggle t = (Toggle) o;
  74. t.setCaptionLabel(t.getName().substring(2));
  75. }
  76. microsteppingButtons.showBar();
  77. microsteppingButtons.moveTo(runTab);
  78. currentSlider = controlP5.addSlider("current", 0.46, maxCurrent, 0.4, 250, 40, 20, 210);
  79. controlElements.add(currentSlider);
  80. currentSlider.moveTo(runTab);
  81. // add a vertical slider for stallGuard threshold
  82. sgtPlus = controlP5.addButton("sgtplus", 0, 400, 40, 20, 20);
  83. controlElements.add(sgtPlus);
  84. sgtPlus.setCaptionLabel("+");
  85. sgtPlus.moveTo(runTab);
  86. sgtMinus = controlP5.addButton("sgtminus", 1, 400, 70, 20, 20);
  87. controlElements.add(sgtMinus);
  88. sgtMinus.setCaptionLabel("-");
  89. sgtMinus.moveTo(runTab);
  90. sgtSlider = controlP5.addSlider("stallguardthreshold", -64, 63, 0, 350, 40, 20, 150);
  91. controlElements.add(sgtSlider);
  92. sgtSlider.setSliderMode(Slider.FIX);
  93. sgtSlider.setCaptionLabel("Stall Guard Threshold");
  94. sgtSlider.moveTo(runTab);
  95. //ading some buttons to have finer sg control
  96. //adding a button for the filter
  97. sgFilterToggle = controlP5.addToggle("sgfilter", false, 350, 220, 30, 30);
  98. controlElements.add(sgFilterToggle);
  99. sgFilterToggle.setCaptionLabel("Stall GuardFilter");
  100. sgFilterToggle.moveTo(runTab);
  101. //add the coolstep sliders
  102. coolStepMaxSlider = controlP5.addSlider("coolStepUpper", 0, 480, 0, 500, 40, 20, 90);
  103. controlElements.add(coolStepMaxSlider);
  104. coolStepMaxSlider.setCaptionLabel("Cool Step Hysteresis");
  105. coolStepMaxSlider.moveTo(runTab);
  106. coolStepMinSlider = controlP5.addSlider("coolStepLower", 0, 480, 0, 500, 160, 20, 90);
  107. controlElements.add(coolStepMinSlider);
  108. coolStepMinSlider.setCaptionLabel("Cool Step Minimum");
  109. coolStepMinSlider.moveTo(runTab);
  110. coolStepActiveToggle = controlP5.addToggle("coolStepActive", false, 600, 220, 30, 30);
  111. controlElements.add(coolStepActiveToggle);
  112. coolStepActiveToggle.setCaptionLabel("Enable CoolStep");
  113. coolStepActiveToggle.moveTo(runTab);
  114. coolStepIncrementButtons = controlP5.addRadioButton("coolStepIncrement", 600, 40);
  115. controlElements.add(coolStepIncrementButtons);
  116. coolStepIncrementButtons.captionLabel().set("Cool Step Increment");
  117. coolStepIncrementButtons.addItem("i_1", 0);
  118. coolStepIncrementButtons.addItem("i_2", 1);
  119. coolStepIncrementButtons.addItem("i_4", 2);
  120. coolStepIncrementButtons.addItem("i_8", 3);
  121. for (Object o:coolStepIncrementButtons.getItems()) {
  122. Toggle t = (Toggle) o;
  123. t.setCaptionLabel(t.getName().substring(2));
  124. }
  125. coolStepIncrementButtons.showBar();
  126. coolStepIncrementButtons.moveTo(runTab);
  127. coolStepDecrementButtons = controlP5.addRadioButton("coolStepDecrement", 600, 110);
  128. controlElements.add(coolStepDecrementButtons);
  129. coolStepDecrementButtons.captionLabel().set("Cool Step Decrement");
  130. coolStepDecrementButtons.addItem("d_32", 0);
  131. coolStepDecrementButtons.addItem("d_8", 1);
  132. coolStepDecrementButtons.addItem("d_2", 2);
  133. coolStepDecrementButtons.addItem("d_1", 3);
  134. for (Object o:coolStepDecrementButtons.getItems()) {
  135. Toggle t = (Toggle) o;
  136. t.setCaptionLabel(t.getName().substring(2));
  137. }
  138. coolStepDecrementButtons.showBar();
  139. coolStepDecrementButtons.moveTo(runTab);
  140. coolStepMinButtons = controlP5.addRadioButton("coolStepMin", 600, 180);
  141. controlElements.add(coolStepMinButtons);
  142. coolStepMinButtons.addItem("s_1/2", 0);
  143. coolStepMinButtons.addItem("s_1/4", 1);
  144. for (Object o:coolStepMinButtons.getItems()) {
  145. Toggle t = (Toggle) o;
  146. t.setCaptionLabel(t.getName().substring(2));
  147. }
  148. coolStepMinButtons.showBar();
  149. coolStepMinButtons.moveTo(runTab);
  150. trinamicButton = controlP5.addButton("trinamicLogo", 1.0, 750, 40, 200, 100);
  151. trinamicButton.setImage(TMCLogo);
  152. trinamicButton.moveTo(runTab);
  153. controlElements.add(trinamicButton);
  154. motionControlButton = controlP5.addButton("mcLogo", 1.0, 750, 150, 200, 100);
  155. motionControlButton.setImage(MCLogo);
  156. motionControlButton.moveTo(runTab);
  157. controlElements.add(motionControlButton);
  158. }
  159. void speed(int theSpeed) {
  160. if (!settingStatus) {
  161. int speed = (int) theSpeed;
  162. println("setting speed to "+speed);
  163. sendCommand("S"+speed);
  164. }
  165. }
  166. void run(int value) {
  167. if (!settingStatus) {
  168. println("button pressed");
  169. if (running) {
  170. println("stopping motor");
  171. sendCommand("s");
  172. running = false;
  173. }
  174. else {
  175. println("starting motor");
  176. sendCommand("r");
  177. running = true;
  178. }
  179. }
  180. }
  181. void enabled(int value) {
  182. if (!settingStatus) {
  183. println("enabled: "+value);
  184. sendCommand("e"+value);
  185. }
  186. }
  187. void microstepping(int value) {
  188. if (!settingStatus) {
  189. println("microstepping: "+value);
  190. sendCommand("m"+value);
  191. }
  192. }
  193. void stallguardthreshold(int value) {
  194. if (!settingStatus) {
  195. println("stall guard threshold: "+value);
  196. sendCommand("t"+value);
  197. }
  198. if (value==sgtSlider.max()) {
  199. sgtPlus.lock();
  200. }
  201. else {
  202. sgtPlus.unlock();
  203. }
  204. if (value==sgtSlider.min()) {
  205. sgtMinus.lock();
  206. }
  207. else {
  208. sgtMinus.unlock();
  209. }
  210. }
  211. void sgtplus(int value) {
  212. sgtSlider.setValue(sgtSlider.value()+1);
  213. }
  214. void sgtminus(int value) {
  215. sgtSlider.setValue(sgtSlider.value()-1);
  216. }
  217. void sgfilter(int value) {
  218. if (!settingStatus) {
  219. println("filter: "+value);
  220. sendCommand("f"+value);
  221. }
  222. }
  223. void current(float value) {
  224. if (!settingStatus) {
  225. int realValue=(int)(value*1000.0);
  226. println("current: "+((float)realValue/1000.0)+" = "+realValue);
  227. sendCommand("c"+realValue);
  228. if (activeTab!=null && "run".equals(activeTab.name())) {
  229. motorCurrentBox.setValue(value);
  230. }
  231. }
  232. }
  233. void coolStepUpper(int value) {
  234. coolStepMax=value;
  235. if (!settingStatus) {
  236. sendCommand("Ku"+value);
  237. }
  238. }
  239. void coolStepLower(int value) {
  240. coolStepMin = value;
  241. if (!settingStatus) {
  242. sendCommand("Kl"+value);
  243. }
  244. }
  245. void setCoolStepIncrement(int value) {
  246. if (!settingStatus) {
  247. println("cool step increment :"+value);
  248. sendCommand("Ki"+value);
  249. }
  250. }
  251. void setCoolStepDecrement(int value) {
  252. if (!settingStatus) {
  253. println("cool step decrement :"+value);
  254. sendCommand("Kn"+value);
  255. }
  256. }
  257. void setCoolStepMin(int value) {
  258. if (!settingStatus) {
  259. println("cool step minimum :"+value);
  260. sendCommand("Km"+value);
  261. }
  262. }
  263. void coolStepActive(int value) {
  264. if (!settingStatus) {
  265. coolStepActive = (value!=0);
  266. sendCommand(coolStepActive? "K+":"K-");
  267. }
  268. }
  269. void setCurrent(int current) {
  270. currentSlider.setValue((float)current/1000.0);
  271. }
  272. void setDirection(int direction) {
  273. if (!settingStatus) {
  274. if (direction<0) {
  275. println("back");
  276. sendCommand("d-1");
  277. }
  278. else {
  279. sendCommand("d1");
  280. }
  281. }
  282. }
  283. void trinamicLogo(float value){
  284. if (value!=0) {
  285. link(trinamicUrl);
  286. }
  287. }
  288. void mcLogo(float value) {
  289. if (value!=0) {
  290. link(mcUrl);
  291. }
  292. }