Changes for page Front I/O
Last modified by Kevin Wiki on 2024/07/07 22:48
From version
7.3
edited by Kevin Wiki
on 2024/07/05 09:31
on 2024/07/05 09:31
Change comment:
There is no comment for this version
To version
8.4
edited by Kevin Wiki
on 2024/07/06 14:56
on 2024/07/06 14:56
Change comment:
There is no comment for this version
Summary
Details
- Page properties
-
- Content
-
... ... @@ -194,7 +194,253 @@ 194 194 * Power LED P3V3 - 3.30V 195 195 * Power LED - 0.87 V 196 196 197 += Controlling top I/O LED = 198 + 199 +On the top row we have the following input/output devices in order from left to right; 200 + 201 +Left side: 202 + 203 +* physical lock 204 +* lock LED 205 +* warning/service button 206 +* warning/service LED 207 +* locate button 208 +* power LED (red & green) 209 +* fan LED (red & green) 210 +* temperature LED (red & green) 211 +* compute LED (unknown) 212 + 213 +Right side: 214 + 215 +* power LED (red & green) 216 +* fan LED (red & green) 217 +* temperature LED (red & green) 218 +* compute LED (unknown) 219 +* lock switch 220 + 221 +Each sides bank of LEDs are driven by each their PCA9554 shift register. The registers represent the following LEDs: (Note that Lock LED is only present for the LEFT side) 222 + 223 +(% border="1" %) 224 +|=(% scope="row" %)Register|1|2|3|4|5|6|7 225 +|=Device|Power LED Green|Power LED Red|Fan LED Green|Fan LED Red|Temperature LED Green|Temperature LED Red|Lock LED 226 + 227 +To control each LED we shift either a 0 to turn off or 1 to turn on. Since each device shares a single red/green LED (power LED green & power LED red) setting both to 1 at the same time will always leave it red. That is when power LED green and power LED red are both enabled, red always takes precedence. 228 + 229 +Use following script to power LEDs one at a time: 230 + 231 +{{code language="c++"}} 232 +#include <PCA9554.h> // Load the PCA9554 Library 233 + 234 +PCA9554 ioCon1(0x24); // Create an object at this address 235 + 236 +uint8_t mapIO = 0b10000000; 237 + 238 +void shiftL() { 239 + mapIO = (mapIO << 1) | ((mapIO & 0x80) >> 7); 240 +} 241 + 242 +void write() { 243 + Serial.println("writing to PCA9554 device"); 244 + 245 + for (int i = 0; i < 8; ++i) { 246 + ioCon1.digitalWrite(i, (mapIO & (1 << i)) ? 0 : 1); 247 + } 248 +} 249 + 250 +void setup() 251 +{ 252 + Serial.begin(9600); 253 + Serial.println("Setup"); 254 + 255 + ioCon1.portMode(ALLOUTPUT); 256 +} 257 + 258 +void loop() 259 +{ 260 + write(); 261 + shiftL(); 262 + 263 + delay(500); 264 +} 265 +{{/code}} 266 + 267 + 268 +Controlling middle IO strip 269 + 270 +0 = 0000 271 +1 (green) = 0001 272 +2 = 0010 273 +1 + 2 = 0011 274 +3 = 0100 275 + 276 + 277 +There are 4 words, each containing 7 data bits. They do not 278 + 279 + 280 += Controlling center LED columns = 281 + 282 +There are a total of 4 banks of addressable LED's 12 each of the total 48. 283 + 284 +|=Register Banks|=LEDs|=Count 285 +|=Bank 1|1 2 4 6 8 10 12|7 286 +|=Bank 2|3 5 7 9 11 13|6 287 +|=Bank 3|14 16 18 20 22 23 24|7 288 +|=Bank 4|15 17 19 21|4 289 + 290 +Script for writing all permutations to display: 291 + 292 +{{code language="c++"}} 293 +#include "Wire.h" // enable I2C bus 294 + 295 +byte saa1064 = 0x3B; // define the I2C bus address for our SAA1064 (pin 1 to GND) **** 296 + 297 +void setup() 298 +{ 299 + Wire.begin(); // start up I2C bus 300 +} 301 + 302 +void write(int value) { 303 + Wire.beginTransmission(saa1064); 304 + Wire.write(1); 305 + 306 + Wire.write(value); 307 + Wire.write(value); 308 + Wire.write(value); 309 + Wire.write(value); 310 + 311 + Wire.endTransmission(); 312 +} 313 + 314 +void loop() { 315 + for (int value = 0; value < 127; value++) { 316 + write(value); 317 + delay(300); 318 + } 319 +} 320 +{{/code}} 321 + 322 +Since LED positions don't map sequentially with LED number we can't address them in 10-base form, but we can define each LED in binary and use OR operator to display LEDs we want. 323 + 324 +{{code language="c++"}} 325 +#include "Wire.h" // enable I2C bus 326 + 327 +#define TCAADDR 0x70 328 +byte saa1064 = 0x3B; // define the I2C bus address for our SAA1064 329 + 330 +byte bank1; 331 +byte bank2; 332 +byte bank3; 333 +byte bank4; 334 + 335 +byte activityLED = 0b00000001; 336 +byte leds[23][4] = { 337 + {0b00000010, 0b00000000, 0b00000000, 0b00000000}, // 1 338 + {0b00000000, 0b00000010, 0b00000000, 0b00000000}, // 2 339 + {0b00000100, 0b00000000, 0b00000000, 0b00000000}, // 3 340 + {0b00000000, 0b00000100, 0b00000000, 0b00000000}, // 4 341 + {0b00001000, 0b00000000, 0b00000000, 0b00000000}, // 5 342 + {0b00000000, 0b00001000, 0b00000000, 0b00000000}, // 6 343 + {0b00010000, 0b00000000, 0b00000000, 0b00000000}, // 7 344 + {0b00000000, 0b00010000, 0b00000000, 0b00000000}, // 8 345 + {0b00100000, 0b00000000, 0b00000000, 0b00000000}, // 9 346 + {0b00000000, 0b00100000, 0b00000000, 0b00000000}, // 10 347 + {0b01000000, 0b00000000, 0b00000000, 0b00000000}, // 11 348 + {0b00000000, 0b01000000, 0b00000000, 0b00000000}, // 12 349 + {0b00000000, 0b00000000, 0b00000001, 0b00000000}, // 13 350 + {0b00000000, 0b00000000, 0b00000000, 0b00000001}, // 14 351 + {0b00000000, 0b00000000, 0b00000010, 0b00000000}, // 15 352 + {0b00000000, 0b00000000, 0b00000000, 0b00000010}, // 16 353 + {0b00000000, 0b00000000, 0b00000100, 0b00000000}, // 17 354 + {0b00000000, 0b00000000, 0b00000000, 0b00000100}, // 18 355 + {0b00000000, 0b00000000, 0b00001000, 0b00000000}, // 19 356 + {0b00000000, 0b00000000, 0b00000000, 0b00001000}, // 20 357 + {0b00000000, 0b00000000, 0b00010000, 0b00000000}, // 21 358 + {0b00000000, 0b00000000, 0b00100000, 0b00000000}, // 22 359 + {0b00000000, 0b00000000, 0b01000000, 0b00000000} // 23 360 +}; 361 + 362 +void setup() 363 +{ 364 + Serial.begin(9600); 365 + Wire.begin(); // start up I2C bus 366 + 367 + Serial.println("setting up ports"); 368 +} 369 + 370 +void tcaselect(uint8_t i) { 371 + if (i > 7) return; 197 197 373 + Wire.beginTransmission(TCAADDR); 374 + Wire.write(1 << i); 375 + Wire.endTransmission(); 376 +} 377 + 378 +void selectLeft() { tcaselect(2); } 379 +void selectRight() { tcaselect(1); } 380 + 381 +void write() { 382 + Wire.beginTransmission(saa1064); 383 + Wire.write(1); 384 + 385 + Wire.write(bank1); 386 + Wire.write(bank2); 387 + Wire.write(bank3); 388 + Wire.write(bank4); 389 + 390 + Wire.endTransmission(); 391 +} 392 + 393 +void resetBanks() { 394 + bank1 = 0; 395 + bank2 = 0; 396 + bank3 = 0; 397 + bank4 = 0; 398 +} 399 + 400 +void displayNumber(int number) { 401 + bank1 = leds[number - 1][0]; 402 + bank2 = leds[number - 1][1]; 403 + bank3 = leds[number - 1][2]; 404 + bank4 = leds[number - 1][3]; 405 +} 406 + 407 +void displayUpToNumber(int number) { 408 + for (int i = 0; i < number; i++) { 409 + bank1 = bank1 | leds[i][0]; 410 + bank2 = bank2 | leds[i][1]; 411 + bank3 = bank3 | leds[i][2]; 412 + bank4 = bank4 | leds[i][3]; 413 + } 414 +} 415 + 416 +void computeEthernetActivity() { 417 + bank1 = bank1 | activityLED; 418 +} 419 + 420 +void loop() { 421 + resetBanks(); 422 + delay(10); 423 + 424 + displayUpToNumber(15); 425 + computeEthernetActivity(); 426 + 427 + selectLeft(); 428 + write(); 429 + delay(2); 430 + 431 + selectRight(); 432 + write(); 433 + delay(1000); 434 +} 435 +{{/code}} 436 + 437 + 438 += Missing pieces, TODO = 439 + 440 +* how to control compute LED in top IO row 441 +* control warning button LED 442 + 443 + 198 198 ))) 199 199 200 200