Components and supplies
Arduino Nano R3
Dual H-Bridge motor drivers L298
Tools and machines
3D Printer (generic)
Apps and platforms
Arduino IDE
Processing
Project description
Code
ROTOR_DC.pde
java
Processing Code
1import processing.serial.*; 2import controlP5.*; 3 4Serial magistrala; 5ControlP5 cp5; 6PFont font; 7 8PImage background; 9PImage dial; 10float heading; 11float headrad; 12float strefaMartwa = 285.0; 13float fAzTemp = 0.0; 14float fAzPos = 0.0; 15String sAzPos = ""; 16float fAzSpeed = 0.0; 17float[] fDataUART= {}; 18float fSetAzSpeed = 0.0; 19int iSetAzSpeed = 0; 20String sSetAzSpeed = "0"; 21int iBorderX, iBorderY, iBorderW, iBorderH, iGateMaps; 22 23void setup() 24{ 25 magistrala = new Serial(this, "/dev/UKF_ROTATOR", 4800); 26 magistrala.bufferUntil('\n'); 27 font = loadFont("DejaVuSans-20.vlw"); 28 background(0); 29 dial = loadImage("dial.png"); 30 31 cp5 = new ControlP5(this); 32 33 size(1100, 600); 34 35 cp5.addButton("LEFT") 36 .setPosition(20, 345) 37 .setSize(175, 60) 38 .setFont(font) 39 .setColorBackground(color(255, 0, 0)); 40 41 cp5.addButton("STOP") 42 .setPosition(20, 255) 43 .setSize(360, 80) 44 .setFont(font) 45 .setColorBackground(color(255, 0, 0)); 46 47 cp5.addSlider("AzSpeed") 48 .setRange(1, 100) 49 .setFont(font) 50 .setHandleSize(20) 51 .setCaptionLabel("") 52 .setSize(220, 30) 53 .setPosition(160, 200); 54 55 cp5.addButton("RIGHT") 56 .setPosition(205, 345) 57 .setSize(175, 60) 58 .setFont(font) 59 .setColorBackground(color(255, 0, 0)); 60 61 cp5.addButton("MAPA") 62 .setPosition(20, 500) 63 .setSize(175, 60) 64 .setFont(font) 65 .setColorBackground(color(255, 0, 0)); 66 67 frameRate(100); 68 magistrala.bufferUntil ( '\n' ); 69 70 STOP(); 71} 72 73void draw() { 74 background(0); 75 image(dial, 525, 25, 550, 550); 76 77 //ramka statusu 78 fill(0, 80, 220); 79 rect(10, 110, 380, 75, 7); 80 textFont(font, 24); 81 82 //ramka prdkoci 83 fill(240, 240, 0); 84 rect(10, 195, 380, 40, 7); 85 textFont(font, 24); 86 87 //ramka prdkoci 88 fill(240, 240, 0); 89 rect(10, 245, 380, 170, 7); 90 textFont(font, 24); 91 92 //ruchoma ramka 93 fill(0, 0, 255); 94 rect(iBorderX, iBorderY, iBorderW, iBorderH, 0); 95 96 //tekst 97 fill(255, 255, 255); 98 textFont(font, 32); 99 text("RADIO ROTOR CONTROLER", 10, 30); 100 textFont(font, 24); 101 text("CALLSIGN: SP9MX", 10, 65); 102 textFont(font, 24); 103 text("OPERATOR: MATEUSZ", 10, 95); 104 textFont(font, 24); 105 text("ACT AZIMUTH:", 15, 140); 106 sAzPos = nf(fAzPos, 0, 1); 107 text(sAzPos, 305, 140); 108 text("ACT ROT SPEED:", 15, 170); 109 if (fAzSpeed < 0) 110 sAzPos = nf(-fAzSpeed, 0, 0); 111 else sAzPos = nf(fAzSpeed, 0, 0); 112 text(sAzPos, 305, 170); 113 fill(0, 0, 0); 114 textFont(font, 24); 115 text("SET SPEED:", 15, 225); 116 117 //promie wodzcy 118 stroke(255, 0, 0); 119 strokeWeight(4); 120 float pi =3.1415; 121 float radian = - pi*(fAzPos/180); 122 float x = 800-275*sin(radian); 123 float y = 300-275*cos(radian); 124 line(800, 300, x, y); 125 126 //strefa martwa rotora 127 //pocztek 128 stroke(0, 0, 255); 129 strokeWeight(1); 130 float radian2 = - pi*((strefaMartwa-15)/180); 131 float x2 = 800-275*sin(radian2); 132 float y2 = 300-275*cos(radian2); 133 line(800, 300, x2, y2); 134 float radian3 = - pi*((strefaMartwa+15)/180); 135 float x3 = 800-275*sin(radian3); 136 float y3 = 300-275*cos(radian3); 137 line(800, 300, x3, y3); 138 139 fSetAzSpeed=cp5.getController("AzSpeed").getValue(); 140 iSetAzSpeed = (int)fSetAzSpeed; 141 println(fDataUART); 142} 143 144void LEFT() 145{ 146 magistrala.write(str(iSetAzSpeed)); 147 iBorderX = 15; 148 iBorderY = 340; 149 iBorderW = 185; 150 iBorderH = 70; 151} 152 153void STOP() 154{ 155 magistrala.write("0"); 156 iBorderX = 15; 157 iBorderY = 250; 158 iBorderW = 370; 159 iBorderH = 90; 160} 161 162void RIGHT() 163{ 164 magistrala.write(str(-iSetAzSpeed)); 165 iBorderX = 200; 166 iBorderY = 340; 167 iBorderW = 185; 168 iBorderH = 70; 169} 170 171void importDataUART() 172{ 173 fAzTemp = fDataUART[0]; 174 fAzSpeed = fDataUART[1]; 175 fAzPos = fDataUART[2]; 176} 177 178void MAPA() 179{ 180 if (iGateMaps == 0) 181 { 182 iGateMaps=1; 183 dial = loadImage("dx.png"); 184 } 185 else if (iGateMaps == 1) 186 { 187 iGateMaps=0; 188 dial = loadImage("dial.png"); 189 } 190} 191 192void serialEvent(final Serial s) 193{ 194 fDataUART = float(splitTokens(s.readString())); 195 redraw = true; 196 importDataUART(); 197} 198
rotor.ino
c_cpp
Arduino NANO V3
1const int iAzStepperRev = 200; 2String sMotorSpeed = ""; 3int motorSpeed = 0; 4int stepCount = 0; 5float fAzStepperPos = 0; 6int iAzStepperTemp = 0; 7float fAzStepperTemp = 0; 8float fMotorSpeed = 0; 9int iMotorSpeed = 0; 10unsigned long previousTimeStepper = millis(); 11unsigned long previousTimeSend = millis(); 12long timeIntervalStepper = 8; 13long timeIntervalSend = 100; 14 15void AZ_StepperRelase() 16{ 17 digitalWrite(2, LOW); 18 digitalWrite(3, LOW); 19 digitalWrite(4, LOW); 20 digitalWrite(5, LOW); 21 digitalWrite(10, LOW); 22 digitalWrite(11, LOW); 23} 24 25void setup() { 26 Serial.begin(4800); 27 pinMode(2, OUTPUT); 28 pinMode(3, OUTPUT); 29 pinMode(4, OUTPUT); 30 pinMode(5, OUTPUT); 31 pinMode(10, OUTPUT); 32 pinMode(11, OUTPUT); 33} 34 35void PrintValues(float &fAzTemp, float &fMotorSpeed, float &fAzPos) 36{ 37 Serial.print(iMotorSpeed, 1); 38 Serial.write('\ '); 39 Serial.print(fMotorSpeed, 1); 40 Serial.write('\ '); 41 Serial.println(fAzPos, 1); 42} 43 44 45void MoveStepper() 46{ 47 int iAzStepperPos = analogRead(A7); 48 fAzStepperPos = map(iAzStepperPos, 0 , 1023, 0, 8790); 49 fAzStepperPos = fAzStepperPos / 10.0; 50 fAzStepperPos = fAzStepperPos - 236.5; 51 fMotorSpeed = motorSpeed; 52 if (fMotorSpeed < 0) 53 iMotorSpeed = map(-fMotorSpeed, 0, 100, 100, 255); 54 else 55 iMotorSpeed = map(fMotorSpeed, 0, 100, 100, 255); 56 57 if (Serial.available() > 0) 58 sMotorSpeed = Serial.readString(); 59 motorSpeed = sMotorSpeed.toInt(); 60 61 if (motorSpeed > 0) { 62 analogWrite(11, iMotorSpeed); 63 analogWrite(10, iMotorSpeed); 64 digitalWrite(2, LOW); 65 digitalWrite(3, HIGH); 66 digitalWrite(4, LOW); 67 digitalWrite(5, HIGH); 68 } 69 else if (motorSpeed < 0) { 70 analogWrite(11, iMotorSpeed); 71 analogWrite(10, iMotorSpeed); 72 digitalWrite(2, HIGH); 73 digitalWrite(3, LOW); 74 digitalWrite(4, HIGH); 75 digitalWrite(5, LOW); 76 } 77 else if (motorSpeed == 0) 78 AZ_StepperRelase(); 79} 80 81void Safety() 82{ 83 if ((fAzStepperPos < -60.0 && motorSpeed > 0) || (fAzStepperPos > 270.0 && motorSpeed < 0)) 84 sMotorSpeed = "0"; 85} 86 87void loop() 88{ 89 unsigned long currentTime = millis(); 90 91 //master loop 92 Safety(); 93 MoveStepper(); 94 95 //task 1 - send frame 96 if (currentTime - previousTimeSend > timeIntervalSend) 97 { 98 previousTimeSend = currentTime; 99 fAzStepperTemp = map(analogRead(A6), 0, 1023, -55, 155); 100 PrintValues(fAzStepperTemp, fMotorSpeed, fAzStepperPos); 101 } 102} 103
rotor.ino
c_cpp
Arduino NANO V3
1const int iAzStepperRev = 200; 2String sMotorSpeed = ""; 3int motorSpeed 4 = 0; 5int stepCount = 0; 6float fAzStepperPos = 0; 7int iAzStepperTemp = 8 0; 9float fAzStepperTemp = 0; 10float fMotorSpeed = 0; 11int iMotorSpeed = 0; 12unsigned 13 long previousTimeStepper = millis(); 14unsigned long previousTimeSend = millis(); 15long 16 timeIntervalStepper = 8; 17long timeIntervalSend = 100; 18 19void AZ_StepperRelase() 20{ 21 22 digitalWrite(2, LOW); 23 digitalWrite(3, LOW); 24 digitalWrite(4, LOW); 25 26 digitalWrite(5, LOW); 27 digitalWrite(10, LOW); 28 digitalWrite(11, LOW); 29} 30 31void 32 setup() { 33 Serial.begin(4800); 34 pinMode(2, OUTPUT); 35 pinMode(3, OUTPUT); 36 37 pinMode(4, OUTPUT); 38 pinMode(5, OUTPUT); 39 pinMode(10, OUTPUT); 40 pinMode(11, 41 OUTPUT); 42} 43 44void PrintValues(float &fAzTemp, float &fMotorSpeed, float 45 &fAzPos) 46{ 47 Serial.print(iMotorSpeed, 1); 48 Serial.write('\ '); 49 Serial.print(fMotorSpeed, 50 1); 51 Serial.write('\ '); 52 Serial.println(fAzPos, 1); 53} 54 55 56void 57 MoveStepper() 58{ 59 int iAzStepperPos = analogRead(A7); 60 fAzStepperPos = 61 map(iAzStepperPos, 0 , 1023, 0, 8790); 62 fAzStepperPos = fAzStepperPos / 10.0; 63 64 fAzStepperPos = fAzStepperPos - 236.5; 65 fMotorSpeed = motorSpeed; 66 if 67 (fMotorSpeed < 0) 68 iMotorSpeed = map(-fMotorSpeed, 0, 100, 100, 255); 69 70 else 71 iMotorSpeed = map(fMotorSpeed, 0, 100, 100, 255); 72 73 if (Serial.available() 74 > 0) 75 sMotorSpeed = Serial.readString(); 76 motorSpeed = sMotorSpeed.toInt(); 77 78 79 if (motorSpeed > 0) { 80 analogWrite(11, iMotorSpeed); 81 analogWrite(10, 82 iMotorSpeed); 83 digitalWrite(2, LOW); 84 digitalWrite(3, HIGH); 85 digitalWrite(4, 86 LOW); 87 digitalWrite(5, HIGH); 88 } 89 else if (motorSpeed < 0) { 90 91 analogWrite(11, iMotorSpeed); 92 analogWrite(10, iMotorSpeed); 93 digitalWrite(2, 94 HIGH); 95 digitalWrite(3, LOW); 96 digitalWrite(4, HIGH); 97 digitalWrite(5, 98 LOW); 99 } 100 else if (motorSpeed == 0) 101 AZ_StepperRelase(); 102} 103 104void 105 Safety() 106{ 107 if ((fAzStepperPos < -60.0 && motorSpeed > 0) || (fAzStepperPos 108 > 270.0 && motorSpeed < 0)) 109 sMotorSpeed = "0"; 110} 111 112void loop() 113{ 114 115 unsigned long currentTime = millis(); 116 117 //master loop 118 Safety(); 119 120 MoveStepper(); 121 122 //task 1 - send frame 123 if (currentTime - previousTimeSend 124 > timeIntervalSend) 125 { 126 previousTimeSend = currentTime; 127 fAzStepperTemp 128 = map(analogRead(A6), 0, 1023, -55, 155); 129 PrintValues(fAzStepperTemp, fMotorSpeed, 130 fAzStepperPos); 131 } 132} 133
ROTOR_DC.pde
java
Processing Code
1import processing.serial.*; 2import controlP5.*; 3 4Serial magistrala; 5ControlP5 6 cp5; 7PFont font; 8 9PImage background; 10PImage dial; 11float heading; 12float 13 headrad; 14float strefaMartwa = 285.0; 15float fAzTemp = 0.0; 16float fAzPos 17 = 0.0; 18String sAzPos = ""; 19float fAzSpeed = 0.0; 20float[] fDataUART= {}; 21float 22 fSetAzSpeed = 0.0; 23int iSetAzSpeed = 0; 24String sSetAzSpeed = "0"; 25int 26 iBorderX, iBorderY, iBorderW, iBorderH, iGateMaps; 27 28void setup() 29{ 30 31 magistrala = new Serial(this, "/dev/UKF_ROTATOR", 4800); 32 magistrala.bufferUntil('\ 33'); 34 35 font = loadFont("DejaVuSans-20.vlw"); 36 background(0); 37 dial = loadImage("dial.png"); 38 39 40 cp5 = new ControlP5(this); 41 42 size(1100, 600); 43 44 cp5.addButton("LEFT") 45 46 .setPosition(20, 345) 47 48 .setSize(175, 60) 49 .setFont(font) 50 .setColorBackground(color(255, 51 0, 0)); 52 53 cp5.addButton("STOP") 54 .setPosition(20, 55 255) 56 .setSize(360, 80) 57 58 .setFont(font) 59 .setColorBackground(color(255, 0, 0)); 60 61 cp5.addSlider("AzSpeed") 62 63 .setRange(1, 100) 64 .setFont(font) 65 .setHandleSize(20) 66 .setCaptionLabel("") 67 68 .setSize(220, 30) 69 .setPosition(160, 200); 70 71 cp5.addButton("RIGHT") 72 73 .setPosition(205, 345) 74 75 .setSize(175, 60) 76 .setFont(font) 77 .setColorBackground(color(255, 78 0, 0)); 79 80 cp5.addButton("MAPA") 81 .setPosition(20, 82 500) 83 .setSize(175, 60) 84 85 .setFont(font) 86 .setColorBackground(color(255, 0, 0)); 87 88 frameRate(100); 89 90 magistrala.bufferUntil ( '\ 91' ); 92 93 STOP(); 94} 95 96void draw() { 97 98 background(0); 99 image(dial, 525, 25, 550, 550); 100 101 //ramka statusu 102 103 fill(0, 80, 220); 104 rect(10, 110, 380, 75, 7); 105 textFont(font, 24); 106 107 108 //ramka prdkoci 109 fill(240, 240, 0); 110 rect(10, 195, 380, 40, 7); 111 textFont(font, 112 24); 113 114 //ramka prdkoci 115 fill(240, 240, 0); 116 rect(10, 245, 380, 170, 117 7); 118 textFont(font, 24); 119 120 //ruchoma ramka 121 fill(0, 0, 255); 122 123 rect(iBorderX, iBorderY, iBorderW, iBorderH, 0); 124 125 //tekst 126 fill(255, 127 255, 255); 128 textFont(font, 32); 129 text("RADIO ROTOR CONTROLER", 10, 30); 130 131 textFont(font, 24); 132 text("CALLSIGN: SP9MX", 10, 65); 133 textFont(font, 134 24); 135 text("OPERATOR: MATEUSZ", 10, 95); 136 textFont(font, 24); 137 text("ACT 138 AZIMUTH:", 15, 140); 139 sAzPos = nf(fAzPos, 0, 1); 140 text(sAzPos, 305, 140); 141 142 text("ACT ROT SPEED:", 15, 170); 143 if (fAzSpeed < 0) 144 sAzPos 145 = nf(-fAzSpeed, 0, 0); 146 else sAzPos = nf(fAzSpeed, 0, 0); 147 text(sAzPos, 148 305, 170); 149 fill(0, 0, 0); 150 textFont(font, 24); 151 text("SET SPEED:", 152 15, 225); 153 154 //promie wodzcy 155 stroke(255, 0, 0); 156 strokeWeight(4); 157 158 float pi =3.1415; 159 float radian = - pi*(fAzPos/180); 160 float x = 800-275*sin(radian); 161 162 float y = 300-275*cos(radian); 163 line(800, 300, x, y); 164 165 //strefa martwa 166 rotora 167 //pocztek 168 stroke(0, 0, 255); 169 strokeWeight(1); 170 float radian2 171 = - pi*((strefaMartwa-15)/180); 172 float x2 = 800-275*sin(radian2); 173 float 174 y2 = 300-275*cos(radian2); 175 line(800, 300, x2, y2); 176 float radian3 = - pi*((strefaMartwa+15)/180); 177 178 float x3 = 800-275*sin(radian3); 179 float y3 = 300-275*cos(radian3); 180 line(800, 181 300, x3, y3); 182 183 fSetAzSpeed=cp5.getController("AzSpeed").getValue(); 184 185 iSetAzSpeed = (int)fSetAzSpeed; 186 println(fDataUART); 187} 188 189void LEFT() 190 191{ 192 magistrala.write(str(iSetAzSpeed)); 193 iBorderX = 15; 194 iBorderY 195 = 340; 196 iBorderW = 185; 197 iBorderH = 70; 198} 199 200void STOP() 201{ 202 203 magistrala.write("0"); 204 iBorderX = 15; 205 iBorderY = 250; 206 iBorderW 207 = 370; 208 iBorderH = 90; 209} 210 211void RIGHT() 212{ 213 magistrala.write(str(-iSetAzSpeed)); 214 215 iBorderX = 200; 216 iBorderY = 340; 217 iBorderW = 185; 218 iBorderH = 70; 219} 220 221void 222 importDataUART() 223{ 224 fAzTemp = fDataUART[0]; 225 fAzSpeed = fDataUART[1]; 226 227 fAzPos = fDataUART[2]; 228} 229 230void MAPA() 231{ 232 if (iGateMaps == 0) 233 234 { 235 iGateMaps=1; 236 dial = loadImage("dx.png"); 237 } 238 else if 239 (iGateMaps == 1) 240 { 241 iGateMaps=0; 242 dial = loadImage("dial.png"); 243 244 } 245} 246 247void serialEvent(final Serial s) 248{ 249 fDataUART = float(splitTokens(s.readString())); 250 251 redraw = true; 252 importDataUART(); 253} 254
Downloadable files
Example electrical connection in Fritzing
Example electrical connection in Fritzing
Example electrical connection in Fritzing
Example electrical connection in Fritzing
Documentation
Small gear wheel
Small gear wheel
Bearing bracket
Bearing bracket
Height lock, second element
Height lock, second element
Motor DC holder
Motor DC holder
20x20 profile cover
20x20 profile cover
Small bearing holder, second element
Small bearing holder, second element
Height lock, first element
Height lock, first element
Small bearing holder
Small bearing holder
Big gear wheel
Big gear wheel
LPDA Antenna holder
LPDA Antenna holder
Clutch, second element
Clutch, second element
LPDA Antenna holder
LPDA Antenna holder
20x20 profile cover
20x20 profile cover
Small bearing holder, second element
Small bearing holder, second element
Height lock, second element
Height lock, second element
Small bearing holder
Small bearing holder
Big gear wheel
Big gear wheel
Clutch, first element
Clutch, first element
Motor DC holder
Motor DC holder
Height lock, first element
Height lock, first element
Bearing bracket
Bearing bracket
Small gear wheel
Small gear wheel
Clutch, second element
Clutch, second element
Comments
Only logged in users can leave comments
Anonymous user
2 years ago
Hello! Nice project! Can u help me with start windows, there I must to change com port settings?
jeepmanct
2 years ago
Curious what I would need to do to be able to use Wifi rather than direct connect to PC and be able to access it via a webpage for rotation?