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.

ChopperConfiguration.pde 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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 constantOffSlider;
  21. Slider blankTimeSlider;
  22. Toggle randomOffTimeToggle;
  23. RadioButton ChopperModeButtons;
  24. //for constant off time chopeer
  25. Slider fastDecaySlider;
  26. Slider sineWaveOffsetSlider;
  27. Toggle currentComparatorToggle;
  28. //for spread chopper
  29. Slider hysteresisStartSlider;
  30. Slider hysteresisEndSlider;
  31. Numberbox motorVoltageBox;
  32. Numberbox motorCurrentBox;
  33. Numberbox motorResistanceBox;
  34. Numberbox motorInductanceBox;
  35. RadioButton hysteresisDecrementButtons;
  36. PImage spreadChopperImage;
  37. void setupChooperConfig() {
  38. //add input fields for the various motor parameters
  39. motorVoltageBox = controlP5.addNumberbox("motorvoltage",12.0,20,40,100,20);
  40. motorVoltageBox.setCaptionLabel("Motor Voltage (V)");
  41. motorVoltageBox.setMultiplier(0.025);
  42. motorVoltageBox.setMin(0);
  43. motorVoltageBox.setMax(40.0);
  44. motorVoltageBox.moveTo(configureTab);
  45. motorCurrentBox = controlP5.addNumberbox("motorcurrent",0.5,140,40,100,20);
  46. motorCurrentBox.setCaptionLabel("Motor Current (A)");
  47. motorCurrentBox.setMultiplier(0.025);
  48. motorCurrentBox.setMin(0.46);
  49. motorCurrentBox.setMax(1.7);
  50. motorCurrentBox.moveTo(configureTab);
  51. motorResistanceBox = controlP5.addNumberbox("motorresistance",2,260,40,100,20);
  52. motorResistanceBox.setCaptionLabel("Motor Resistance (Ohm)");
  53. motorResistanceBox.setMultiplier(0.1);
  54. motorResistanceBox.setMin(0);
  55. motorResistanceBox.setMax(250);
  56. motorResistanceBox.moveTo(configureTab);
  57. motorInductanceBox = controlP5.addNumberbox("motorinductance",2,380,40,100,20);
  58. motorInductanceBox.setMultiplier(0.1);
  59. motorInductanceBox.setMin(0);
  60. motorInductanceBox.setMax(250);
  61. motorInductanceBox.setCaptionLabel("Motor Inductance (mH)");
  62. motorInductanceBox.moveTo(configureTab);
  63. // add a vertical slider for speed
  64. constantOffSlider = controlP5.addSlider("constantoff", 1, 15, 1, 20, 80, 400, 20);
  65. constantOffSlider.setCaptionLabel("Constant Off Time");
  66. constantOffSlider.setSliderMode(Slider.FIX);
  67. constantOffSlider.moveTo(configureTab);
  68. blankTimeSlider = controlP5.addSlider("blanktime", 0, 3, 2, 20, 120, 400, 20);
  69. blankTimeSlider.setCaptionLabel("Blank Time");
  70. blankTimeSlider.moveTo(configureTab);
  71. hysteresisStartSlider = controlP5.addSlider("hysteresisstart", 0, 8, 2, 20, 160, 400, 20);
  72. hysteresisStartSlider.setCaptionLabel("Hysteresis Start");
  73. hysteresisStartSlider.moveTo(configureTab);
  74. hysteresisEndSlider = controlP5.addSlider("hysteresisend", -3, 12, 2, 20, 200, 400, 20);
  75. hysteresisEndSlider.setCaptionLabel("Hysteresis End");
  76. hysteresisEndSlider.moveTo(configureTab);
  77. hysteresisDecrementButtons =controlP5.addRadioButton("decrement", 20, 240);
  78. hysteresisDecrementButtons.addItem("fastest", 0);
  79. hysteresisDecrementButtons.addItem("fast", 1);
  80. hysteresisDecrementButtons.addItem("medium", 2);
  81. hysteresisDecrementButtons.addItem("slow", 3);
  82. hysteresisDecrementButtons.showBar();
  83. hysteresisDecrementButtons.moveTo(configureTab);
  84. spreadChopperImage = loadImage("hysteresis.png");
  85. }
  86. void drawChopper() {
  87. if (activeTab!=null && configureTab.equals(activeTab)) {
  88. image(spreadChopperImage, 200, 400);
  89. }
  90. }
  91. void constantoff(int theValue) {
  92. if (!settingStatus) {
  93. if (theValue>0 && theValue<16) {
  94. println("Constant off "+theValue);
  95. sendCommand("cO"+theValue);
  96. }
  97. else {
  98. println("invalid blank time of "+theValue);
  99. }
  100. }
  101. }
  102. void blanktime(int theValue) {
  103. if (!settingStatus) {
  104. if (theValue>=0 && theValue<=3) {
  105. println("blank time "+theValue);
  106. sendCommand("Cb"+theValue);
  107. }
  108. }
  109. }
  110. void hysteresisstart(int start) {
  111. if (!settingStatus) {
  112. if (start>=1 && start<=8) {
  113. println("hystereis start "+start);
  114. sendCommand("Cs"+start);
  115. }
  116. }
  117. }
  118. void hysteresisend(int end) {
  119. if (!settingStatus) {
  120. if (end>=-3 && end<=12) {
  121. println("hystereis end "+end);
  122. sendCommand("Ce"+end);
  123. }
  124. }
  125. }
  126. void setHysteresisDecrement(int theValue) {
  127. if (!settingStatus) {
  128. if (theValue>=0 && theValue<=3) {
  129. println("Hysteresis decrement "+theValue);
  130. sendCommand("Cd"+theValue);
  131. }
  132. else {
  133. println("cannot set decrement to "+theValue);
  134. }
  135. }
  136. }
  137. void setHystDecrement(int value) {
  138. if (value>=0 && value<=3) {
  139. hysteresisDecrementButtons.activate(value);
  140. }
  141. else {
  142. println("this is no proper hysteresis decerement value: "+value);
  143. }
  144. }
  145. void motorcurrent(float value) {
  146. if (activeTab!=null && "default".equals(activeTab.name())) {
  147. currentSlider.setValue(value);
  148. }
  149. }