Yaesu G-250 Controller
This project intends to build a system to replace the yaesu g-250 rotor controller.
Components and supplies
1
Alphanumeric LCD, 20 x 4
4
Toggle Switch, Toggle
8
Relay (generic)
3
Resistor 10k ohm
1
Arduino Yun
2
Low Voltage Transformer, Class II
Tools and machines
1
Soldering iron (generic)
1
Solder Wire, Lead Free
Apps and platforms
1
Arduino IDE
Project description
Code
code v1.0
c_cpp
For now this code only permits rotor local control. Azimuth input's from software will be implemented in future.
1/* 2 * Yaesu G-250 antenna controller 3 * Created July 2021 4 * 5 * bragofsky 2021 6 */ 7 8#include <Wire.h> 9#include <LiquidCrystal_I2C.h> 10 11//definições LCD 12#define endereco 0x27 13#define colunas 20 14#define linhas 4 15 16//Objeto LCD 17LiquidCrystal_I2C lcd(endereco, colunas, linhas); 18 19//Definição PIN's I/O 20const int PIN_RELAY_CW = 7; 21const int PIN_RELAY_CCW = 11; 22const int PIN_BUTTON_CW = 8; 23const int PIN_BUTTON_CCW = 9; 24const int PIN_BUTTON_LR = 10; 25const int PIN_POT = A0; 26 27 28void setup() { 29 30 Serial.begin(9600); //Iniciar porta serie arduino 31 pinMode(PIN_RELAY_CW, OUTPUT); //definição pin output relé CW 32 pinMode(PIN_RELAY_CCW, OUTPUT); //definição pin output relé CCW 33 pinMode(PIN_BUTTON_CW, INPUT); //definição pin input botão CW 34 pinMode(PIN_BUTTON_CCW, INPUT); //definição pin input botão CCW 35 pinMode(PIN_BUTTON_LR, INPUT); //definição pin input botão Local/Remote 36 37 lcd.init(); // INICIA A COMUNICAÇÃO COM O DISPLAY 38 lcd.backlight(); // LIGA A ILUMINAÇÃO DO DISPLAY 39 40 lcd.setCursor(2, 0); 41 lcd.print("Rotor Controller"); 42 lcd.setCursor(0, 1); 43 lcd.print("Mode:"); 44 lcd.setCursor(0, 2); 45 lcd.print("Status:"); 46 lcd.setCursor(0, 3); 47 lcd.print("Azimuth:"); 48 49 50 51} 52 53int buttonState(int BUTTON){ //Verifica o estado do botão recebido como argumento 54 55 int buttonstate = 0; 56 57 buttonstate = digitalRead(BUTTON); 58 //Serial.println(buttonstate); 59 if(buttonstate == HIGH) 60 return 1; 61 else 62 return 0; 63} 64 65void relayOnOff(int RELAY, int STATE){ // Controla relé mediante o estado e porta recebidos como argumento 66 67 if(STATE == 0) 68 digitalWrite(RELAY,HIGH); // turn the relay ON 69 else 70 digitalWrite(RELAY,LOW); // turn the relay OFF 71 72} 73 74int readpot() { //Ler o valor do potenciometro do motor e converter para azimute, serve para limitar o fim e inicio do movimento 75 76 int potVal; 77 int angle; 78 79 potVal = analogRead(PIN_POT); 80 //Serial.print("potVal : "); 81 //Serial.print(potVal); 82 angle = map(potVal,20,880,0,359); 83 //Serial.print(", angle: "); 84 //Serial.println(angle); 85 //delay(500); 86 return potVal; 87} 88 89int azimuthVal(){ //Retornar o valor de azimute do motor 90 91 int potVal; 92 int angle; 93 94 potVal = analogRead(PIN_POT); 95 angle = map(potVal,20,880,0,359); 96 return angle; 97} 98 99int readserial(){ //Ler a porta serie, retirar os dois primeiros caracteres e converter o valor para inteiro 100 101 char output[2]=""; 102 int softazimuth, j=0, i=0; 103 104 while (Serial.available() > 0) { 105 106 String input = Serial.readString(); 107 108 for(i=0; i<=sizeof(input);i++){ 109 if(isDigit(input[i])){ 110 output[j++]=input[i]; 111 } 112 } 113 softazimuth=atoi(output); 114 } 115 return softazimuth; 116} 117 118void loop() { 119 120 if (azimuthVal() >=0 && azimuthVal() <=90){ 121 lcd.setCursor(12, 3); 122 lcd.print(" NE"); 123 } 124 125 if (azimuthVal() >=91 && azimuthVal() <=180){ 126 lcd.setCursor(12, 3); 127 lcd.print(" SE"); 128 } 129 if (azimuthVal() >=181 && azimuthVal() <=270){ 130 lcd.setCursor(12, 3); 131 lcd.print(" SW"); 132 } 133 134 if (azimuthVal() >=271 && azimuthVal() <=359){ 135 lcd.setCursor(12, 3); 136 lcd.print(" NW"); 137 } 138 139 if (azimuthVal() >=100){ 140 lcd.setCursor(9, 3); 141 lcd.print(azimuthVal()); 142 } 143 144 if (azimuthVal() <=99 && azimuthVal() >=10){ 145 lcd.setCursor(9, 3); 146 lcd.print("0"); 147 lcd.print(azimuthVal()); 148 } 149 150 if (azimuthVal() <=9 && azimuthVal() >=0){ 151 lcd.setCursor(9, 3); 152 lcd.print("00"); 153 lcd.print(azimuthVal()); 154 } 155 156 157 if(buttonState(PIN_BUTTON_LR) == 1){ //Local mode 158 159 lcd.setCursor(6, 1); 160 lcd.print("Local "); 161 162 if(buttonState(PIN_BUTTON_CW) == 1 && buttonState(PIN_BUTTON_CCW) == 0){ 163 164 if(readpot() >= 879) 165 relayOnOff(PIN_RELAY_CW,0); 166 else 167 relayOnOff(PIN_RELAY_CW,1); 168 169 lcd.setCursor(8, 2); 170 lcd.print("Moving CW "); 171 172 } 173 174 else if(buttonState(PIN_BUTTON_CCW) == 1 && buttonState(PIN_BUTTON_CW) == 0){ 175 176 if(readpot() <= 20) 177 relayOnOff(PIN_RELAY_CCW,0); 178 else 179 relayOnOff(PIN_RELAY_CCW,1); 180 181 lcd.setCursor(8, 2); 182 lcd.print("Moving CCW"); 183 } 184 185 else if (buttonState(PIN_BUTTON_CCW) == 0 && buttonState(PIN_BUTTON_CW) == 0){ 186 relayOnOff(PIN_RELAY_CW,0); 187 relayOnOff(PIN_RELAY_CCW,0); 188 lcd.setCursor(8, 2); 189 lcd.print("Stopped "); 190 191 } 192 } 193 else if(buttonState(PIN_BUTTON_LR) == 0){ //Remote mode 194 195 lcd.setCursor(6, 1); 196 lcd.print("Remote"); 197 198 //do nothing for now 199 } 200}
Downloadable files
Wiring scheme v1.0
This scheme covers manual control only
Wiring scheme v1.0

wiring.png
wiring.png

Comments
Only logged in users can leave comments