Jump to content

YAKP - Yet Another Kontrol Panel


c4ooo

Recommended Posts

As some of you know, I have wonted to build a control panel for a long while, and have even write my own KSP plugin + openGL application for it. 

Recently I have started building it and have finished the frame and cut out the wooden panels to fit on the frame. The panels aren't really "mounted" in the sense that i will still have to take them off to make cutouts for the switches, as well as paint them.IMG_6240.JPG

The two big holes in the middle are for a laptop and a monitor. The laptop will serve as the multifunctional display / guidance computer while the monitor will display the video output from the PC running KSP, serving as the cockpit window.

Edited by c4ooo
Link to comment
Share on other sites

  • 2 weeks later...
  • 4 months later...

I have started wiring the electronics for the panel. I will try to make a post for each area of the panel. 

Power:

Due to the number of LEDs I have planned to use, as well as the LCD monitor I needed to power, I knew I had to use an external PSU. One of my first thoughts was to use an ATX PSU. They are very powerful, easy to come by, and provide like 3 different voltages (as well as a standby 5v), plus can be turned on/off by shorting a PSU_ON signal to ground. Instead of having a simple on/off toggle, I thought it would be cool to have a "push to start" button and a "toggle kill" switch. Since I needed something to "store" the on state after the push button was depressed, I decided to use a relay. When the "push to start" is pressed, the standby line is used to close a relay. When the really closes, it shorts the PSU_ON to ground, turning the PSU on. As the PSU turns on, it starts outputting 5v, which keeps the relay closed even after the "push to start" button is opened. Finally, the "toggle kill" is used to cut the 5V going to the relay, allowing the PSU to be turned off. Throwing in a couple LEDs and I get this circuit: 

OCxWC4w.png

The two diodes before the relay are needed since you can't short the 5V and STB lines together. They are both 5V, but are generated by different circuits in the PSU. (And also, I forgot to draw the rays coming off of the "on LED" :( )

The wired up circuit looks like this. You can see the ATX header on the left.

KufmWm8.jpg

And here is the push button and switch from the front: 4hSCjaQ.jpg

Edited by c4ooo
Link to comment
Share on other sites

  • 3 weeks later...

FUEL (analog displays):

Next I decided to work on the analog displays. The displays I used where 5 volt voltmeters that you can get off of ebay. disassembling the meter, I took measured the faceplate design and recreated it in CAD. From there, I added marking and added text labels.

 tTI7Dah.png

I wasn't sure if I wanted the text to be horizontal or curved on the G and VERT meters so I made two variants. Then I printed out the designs and glued the paper to the faceplate. I also drilled some holes in the meter housing for LEDs, these will be used for warning lights later. This was the final result: 

yiqIRvs.png

Finally I wired up all the negative sides of the meters to ground and the positive sides to the PWM pins on the arduino. Controlling them is easy, all calcculations are done on the PC, the arduino simply recieves 8 bytes and uses them to set the pulse width for the 8 meters in a for() loop.

Link to comment
Share on other sites

  • 3 weeks later...

Input Matrix:

I planned to have around 40 input switches in my control panel. Having a separate MCU pin per switch would not only be a pain to wire, but also make me quickly run out of MCU pins. The solution is to use a matrix. A matrix allows a grid of devices to be wired into a series or rows and columns, and "scanned" one column at a time. Thus instead of having 40 wires, I can instead have 5 row and 8 column (for 13 total) wires. The idea is that you send current down a single row at a time and see then read the side to see which switches are on, then send current down the next row. This is a little bit reversed in my setup, but I will explain why later. Having 6 rows 7 columns would technically allow be more switches for the same amount of wires, but having 8 column wires allows me to easily read all the pins at once using the PIN register. If you want a good explanation read here: https://www.dribin.org/dave/keyboard/one_html/

Now, switches need either pull down or pull up resisters. For an input matrix, using pull down resisters makes more sense. However, most MCUs have internal pull up, not pull down pins. This means that the output has to sink current from the input. This is kinda backwards and makes less logical sense, but it works on the amels. Here is the schematic: Qmf9I3W.png

Notice how there's a diode per switch. The diodes prevent ghosting (see above link), but in my setup they also prevent a HIGH (ignore) from flowing from the output to the input. 

To read the middle vertical row of switches, I can output HIGH/LOW/HIGH. This allows the current from the 5v to sink through the middle vertical row, but not through any of the other rows. If the switch is open, the 5v can't sink to ground, and the input port reads HIGH for that switch. If the switch is closed, the 5v sinks to ground the output port, and the switch reads LOW. Wired up, it ends up looking kinda neat: loCIznM.png

 

Input Matrix part 2: code

First we set up the ports we need to use:

  DDRD = 0b11111111; //38,X,X,X,18,19,20,21
  DDRA = 0b00000000;
  PORTA = 0b11111111; //29,28,27,26,25,24,23,22

1) First we set the direction (DDR) register of bank to 0b11111111, this sets pins 38 ,18, 19, 20, and 21 to output mode. This bank will have the output pins we use to select which row of switches we read. 

2) Then we set direction (DDR) register of bank to 0b00000000, this sets pins 29, 28, 27, 26, 25, 24, 23, and 22 to input mode. This bank will have the input pins we use to read the switches.

3) Then we set the output (PORT) register of bank to 0b11111111, this starts outputing 5V to the pins through the pull up resisters.

Steps 2 and 3 is like setting INPUT_PULLUP mode for all the pins in bank A.

Then, this is how we read the switches:

PORTD = 0b11111110;  delay(10);
switches[0] = PINA;
PORTD = 0b11111101;  delay(10);
switches[1] = PINA;
PORTD = 0b11111011;  delay(10);
switches[2] = PINA;
PORTD = 0b11110111;  delay(10);
switches[3] = PINA;
PORTD = 0b01111111;  delay(10);
switches[4] = PINA;

Using PORTD, we set LOW one pin at a time. This "activates" the corresponding row. Then we read the states of the 8 switches in that row using PINA. The delay() part is kinda needed becouse, do to the length of the wire (some switches are up to a meter away from the arduino!), or do to capacitance, or do to black magic, the wire that selects the row may "ring" for a bit before it actually goes LOW/HIGH. This will cause weirdness like reading row 1 into switches[0] and switches[1] while also reading row 2 into switches[1] and switches[2].

Edited by c4ooo
Link to comment
Share on other sites

  • 3 weeks later...
This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...