Don't let the Magic Smoke out! This guide on electronics will make sure that you don't turn yourself into a human circuit and let out your magic smoke. It will also make sure you understand the key electrical components needed to have your robot run efficiently and effectively. Let us journey through the sea of electrons.
When you first look at a robot, you immediately notice the tangle of wires that seem to be protruding from every orifice that the robot has. It may confuse you. It may startle you. It may release a little bit of magic smoke from your head. Know ye that this is true for those who have not put in the work and sacrifice of learning the ways of wires. Know ye that this guide will be the catalyst for your transformation as we go through each piece of electronical device and bring new light to the dark corners of your mind. We will bring light to the seemingly ever lasting night.
Everything living has a control mechanism that regulates all the other mechanisms in the body. This would be the brain of a human. Although robots are not living, humans are trying to get as close as possible to recreate the human brain. The roboRIO is one of these artificial brains. Through the use of both digital(returns 0 or 1 based on whether power is going to it) and analog(returns a number based on voltage) outputs, it is possible to create simple and reasonably complex control schemes. It is also important to note that the roboRIO connects to a computer via an Ethernet cable. The RoboRIO is also imaged through a USB cable that connects to the USB port on the roboRIO. Look below at the diagram to see the placement of these ports.
Speed Controllers(Your best buds)
A speed controller is one of the most important electronic devices to get familiar with because it controls the motors that move your robot. It is possible to move motors without speed controllers, but you will be unable to control the direction of which the motor moves unless you reverse the polarity of the wires(switching the negative and positive currents by switching the black and red wires). Listen to this aphorism. The key concept about a speed controller is that it is programmable. Through sending specific currents to the speed controller though code, you can control the direction of which the motor spins.
There are various types of speed controllers which you can use to program motors, however; it is important to consider the type of speed controller because there are some motors that only work with specific speed controllers. For example, the REV Spark Max motors that we used on our robot could only be controlled by REV Spark MAX Speed controllers.
Solenoids and Pneumatic Control
A solenoid is basically a switch that controls the flow of air through pneumatic tubing. Controlling air through a robot can do a surprising amount of things due to the amount of Linear and Vertical force that is applied with direct air pressure(PSI).
To set up a solenoid electronically:
Get and a solenoid. This can be a double or single solenoid. The only difference between the two things is that the double solenoids can go forward and backwards while single solenoids can only go one direction.
Get a pneumatic control module(PCM)
This is a programmable interface which controls the state of the solenoid. The red and black wires on the solenoid plug into the red and black labeled ports on the PCM. This labeled ports on the PCM are the numbers that you will use when constructing a solenoid object in code.
Make sure the solenoid is connected to the tubing that will control the direction of air flow.
This can be a complicated subject to wrap your head around, so I going to try to make this as easy as possible. Can wiring is really referencing to a specific data port known as the CAN bus port. This port is specifically known for organizing the order of the electronic devices connected to the roboRIO so you can find them via programming and the Phoenix firmware interface.
Tracing the CAN: The first step to CAN bus wiring is realizing that yellow and green are the colors used for ground and signal. In the roboRIO section, the diagram shows where the placement of these wires are. Because of the only single port for CAN on the roboRIO, all of the connections made from this port to other ports MUST all lead back to the roboRIO. This is done with a technique known as Daisy Chaining.
Daisy Chaining:As you look at the picture below, you may realize that there are CAN ports on pretty much every controller device. The Power Distribution Board has a CAN port. The PCM has a CAN port. Certain speed controllers have a CAN port. The key to Daisy chaining is that you need to have each device connected to each other through one signal. The diagram below will attempt to explain how you link these wires together.
Limit Switches, Relays, and Things
Limit Switches: Think of a limit switch as a gate that controls whether electric current can travel through it based on whether the "lever" is pushed down or not. Even without programming a limit switch, there are a lot of things that you do by shutting current on and off on the robot using some physical mechanism. If you want to program it to be able to read its state(whether its on or off), plug it into one of the DIO ports on the roboRIO. This port number will become the number which you will use to create the limit switch object in code.
Relays: Relays are basically nothing more than fancy limit switches that are completely controlled by code instead of being able to interacted with mechanically. Using a relay gets rid of the reliance of a physical force needed to turn the state on or off. We used a relay to control the state of a vacuum. Coding a relay should be pretty simple, and if you are not able to get the code to switch the relay off or on, then check to see if your relay is working or not. This happened to our team and changing the relay ended the frustration that we were having getting our code to work.