Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ChopperConfiguration.pde « TMC26XMotorTest « processing « TMC26XMotorTester « examples « TMC26XStepper « libraries « Arduino_1.x.x « ArduinoAddons - github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2fc2a16620a3a8d1c174bda4e5d8903c57242b45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/*
 TMC26XMotorTest.pde - - TMC26X Stepper Tester for Processing
 
 Copyright (c) 2011, Interactive Matter, Marcus Nowotny
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:
 
 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.
 
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
 
 */

Slider constantOffSlider;
Slider blankTimeSlider;
Toggle randomOffTimeToggle;
RadioButton ChopperModeButtons;
//for constant off time chopeer
Slider fastDecaySlider;
Slider sineWaveOffsetSlider;
Toggle currentComparatorToggle;
//for spread chopper
Slider hysteresisStartSlider;
Slider hysteresisEndSlider;
Numberbox motorVoltageBox;
Numberbox motorCurrentBox;
Numberbox motorResistanceBox;
Numberbox motorInductanceBox;

RadioButton hysteresisDecrementButtons;

PImage spreadChopperImage;

void setupChooperConfig() {
  //add input fields for the various motor parameters
  motorVoltageBox = controlP5.addNumberbox("motorvoltage",12.0,20,40,100,20);
  motorVoltageBox.setCaptionLabel("Motor Voltage (V)");
  motorVoltageBox.setMultiplier(0.025);
  motorVoltageBox.setMin(0);
  motorVoltageBox.setMax(40.0);
  motorVoltageBox.moveTo(configureTab);
  
  motorCurrentBox = controlP5.addNumberbox("motorcurrent",0.5,140,40,100,20);
  motorCurrentBox.setCaptionLabel("Motor Current (A)");
  motorCurrentBox.setMultiplier(0.025);
  motorCurrentBox.setMin(0.46);
  motorCurrentBox.setMax(1.7);
  motorCurrentBox.moveTo(configureTab);
  
  motorResistanceBox = controlP5.addNumberbox("motorresistance",2,260,40,100,20);
  motorResistanceBox.setCaptionLabel("Motor Resistance (Ohm)");
  motorResistanceBox.setMultiplier(0.1);
  motorResistanceBox.setMin(0);
  motorResistanceBox.setMax(250);
  motorResistanceBox.moveTo(configureTab);
  
  motorInductanceBox = controlP5.addNumberbox("motorinductance",2,380,40,100,20);
  motorInductanceBox.setMultiplier(0.1);
  motorInductanceBox.setMin(0);
  motorInductanceBox.setMax(250);
  motorInductanceBox.setCaptionLabel("Motor Inductance (mH)");
  motorInductanceBox.moveTo(configureTab);
  // add a vertical slider for speed  
  constantOffSlider = controlP5.addSlider("constantoff", 1, 15, 1, 20, 80, 400, 20);
  constantOffSlider.setCaptionLabel("Constant Off Time");
  constantOffSlider.setSliderMode(Slider.FIX);
  constantOffSlider.moveTo(configureTab);

  blankTimeSlider =  controlP5.addSlider("blanktime", 0, 3, 2, 20, 120, 400, 20);
  blankTimeSlider.setCaptionLabel("Blank Time");
  blankTimeSlider.moveTo(configureTab);

  hysteresisStartSlider =  controlP5.addSlider("hysteresisstart", 0, 8, 2, 20, 160, 400, 20);
  hysteresisStartSlider.setCaptionLabel("Hysteresis Start");
  hysteresisStartSlider.moveTo(configureTab);

  hysteresisEndSlider =  controlP5.addSlider("hysteresisend", -3, 12, 2, 20, 200, 400, 20);
  hysteresisEndSlider.setCaptionLabel("Hysteresis End");
  hysteresisEndSlider.moveTo(configureTab);

  hysteresisDecrementButtons =controlP5.addRadioButton("decrement", 20, 240);
  hysteresisDecrementButtons.addItem("fastest", 0);
  hysteresisDecrementButtons.addItem("fast", 1);
  hysteresisDecrementButtons.addItem("medium", 2);
  hysteresisDecrementButtons.addItem("slow", 3);
  hysteresisDecrementButtons.showBar();
  hysteresisDecrementButtons.moveTo(configureTab);

  spreadChopperImage = loadImage("hysteresis.png");
}

void drawChopper() {
  if (activeTab!=null && configureTab.equals(activeTab)) {
    image(spreadChopperImage, 200, 400);
  }
}

void constantoff(int theValue) {
  if (!settingStatus) {
    if (theValue>0 && theValue<16) {
      println("Constant off "+theValue);
      sendCommand("cO"+theValue);
    } 
    else {
      println("invalid blank time of "+theValue);
    }
  }
}

void blanktime(int theValue) {
  if (!settingStatus) {
    if (theValue>=0 && theValue<=3) {
      println("blank time "+theValue);
      sendCommand("Cb"+theValue);
    }
  }
}

void hysteresisstart(int start) {
  if (!settingStatus) {
    if (start>=1 && start<=8) {
      println("hystereis start "+start);
      sendCommand("Cs"+start);
    }
  }
}

void hysteresisend(int end) {
  if (!settingStatus) {
    if (end>=-3 && end<=12) {
      println("hystereis end "+end);
      sendCommand("Ce"+end);
    }
  }
}

void setHysteresisDecrement(int theValue) {
  if (!settingStatus) {
    if (theValue>=0 && theValue<=3) {
      println("Hysteresis decrement "+theValue);
      sendCommand("Cd"+theValue);
    } 
    else {
      println("cannot set decrement to "+theValue);
    }
  }
}

void setHystDecrement(int value) {
  if (value>=0 && value<=3) {
    hysteresisDecrementButtons.activate(value);
  } 
  else {
    println("this is no proper hysteresis decerement value: "+value);
  }
}

void motorcurrent(float value) {
  if (activeTab!=null && "default".equals(activeTab.name())) {
    currentSlider.setValue(value);
  }
}