Difference between revisions of "EDI Bootcamp"

From Mech
Jump to navigationJump to search
(12 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Welcome to the Mechatronics portion of Bootcamp!
Welcome to the Mechatronics portion of Bootcamp!


[[Media:CircuitBuildingAndProgrammingWithArduino.pdf|Circuit Building and Programming with Arduino]]
Make sure your kit has the following items:
* Arduino Uno ([http://www.sparkfun.com/products/9950])
* USB A to B cable (B has a large, square end)
* 850mAh LiPo ([http://www.sparkfun.com/products/10718])
* Sparkfun LiPo charger and 5V boost board ([http://www.sparkfun.com/products/10300])
* USB A to micro cable (micro has a tiny end)
* RC servo motor
* 3 axis accelerometer ([http://www.pololu.com/catalog/product/1246])
* 8ohm speaker ([http://www.sparkfun.com/products/10722])
* Pushbutton
* Flex sensor ([http://www.sparkfun.com/products/10264])
* Force sensitive resistor ([http://www.sparkfun.com/products/9375])
* Breadboard


[[Media:PythonProgrammingWithMu2018.pdf|Python Programming with Mu]]


[[Media:CircuitBuildingAndProgrammingWithItsyBitsyExpressMu2018.pdf|Circuit Building and Programming with the Itsy Bitsy Express M0 on Mu]]
Also available are 5mm super bight LEDs in blue, red, green, yellow and white, IR LEDs, IR sensitive phototransistors, red sensitive phototransistors, small RC servo motors, and tiny vibration motors.




These gifs are experimental, let me know if they work as a learning tool.
The Mechatronics Lab has 6 workstations, each with power supply, multimeter, function generator, oscilloscope, soldering iron, wire, wire strippers and cutters, solder, and a PC with the Arduino software installed. The white cabinets contain resistors, capacitors, potentiometers, and a variety of useful ICs.




<table>
You can learn more about the Arduino on the website [http://www.arduino.cc/]
<tr>
<td>
[[Image:stripwire_x.gif|[Wire stripping]]]
</td>
<td>
To strip a wire, use the correct wire stripping hole for your wire gauge. Our wire is 22 or 24 gauge. Scissor the wire, and pull off the insulation. If you use a stripping hole that is too small for your wire, the cutter will nick the wire and it will be more likely to break off at the nick.
</td>
</tr>


<tr>
You can download the Arduino website for PC, MAC or Linux at [http://arduino.cc/en/Main/Software]
<td>
[[Image:wirewrap_x.gif|[Connecting wires]]]
</td>
<td>
To connect two wires, place them parallel and twist around each other. Try not to allow one to twist around the other - get both to twist.
</td>
</tr>


<tr>
<td>
[[Image:twistwire_x.gif|[Making stranded wire solid]]]
</td>
<td>
To make a stranded wire solid, fan out the strands and then twist. Tin the end to make it a solid wire. (See below)
</td>
</tr>


<tr>
A nice Arduino tutorial is at [http://www.ladyada.net/learn/arduino/index.html] (uses a slightly older version of the Arduino board, but otherwise is fine)
<td>
[[Image:soldering_x.gif|[Soldering]]]
</td>
<td>
To solder, tin the tip of the soldering iron. Use the iron to heat the wire. When the wire is hot enough, add solder to the joint. The solder should wick into the joint. If it does not, the wire is not hot enough. Use more tinning on the iron tip to allow better contact with the wire.
</td>
</tr>


<tr>
<td>
[[Image:tinstranded_x.gif|[Tinning stranded wire]]]
</td>
<td>
Tin the end of a stranded wire the same way. Avoid adding too much solder or the wire will be too fat to fit into a breadboard.
</td>
</tr>


<tr>
The [[Media:NU32v2_stripchart.zip | NU32v2 Stripchart plotting tool]] is useful for plotting data on your computer.
<td>
[[Image:heatshrink_x.gif|[Using heat shrink]]]
</td>
<td>
To protect a solder connection, apply heat shrink tubing. Heat shrink tubing shrinks a little less than 50%, so make sure the tubing is a snug fit before trying to shrink. Use a hot air gun to shrink the tube. Be sure to cover the exposed wire, and part of the insulation (for strain relief). Tape is a distant second-best.
</td>
</tr>


<tr>
<td>
[[Image:wireinhole_x.gif|[Soldering a wire to a PCB]]]
</td>
<td>
To solder a wire into a PCB hole, stick the wire in the hole and tape it so it can't fall out. Heat the wire and the hole at the same time. Apply solder to the wire and hole and it should wick in. Look for the conical (volcano) shape as the solder adheres to the pad and the wire. If you get a sphere instead, it's called a "cold joint" and usually will fail.
</td>
</tr>


<tr>
Here is the code on the demo Arduino :
<pre>
<td>
[[Image:solderheaders_x.gif|[Soldering header pins to a PCB]]]
/*
</td>
Example Arduino code for NU EDI Bootcamp 2011
<td>
Stick the header pins into a breadboard. Solder the first pin. Reheat the first pin, and while still heating, move the board to be perpendicular with the header pins. Hold the board as you remove the iron to fix the board into position. Then solder the remaining pins.
</td>
</tr>


<tr>
Pins used:
<td>
0 - serial rx, hardwired on the board, so don't use it for anything else
[[Image:pluginchip_x.gif|[How to get a chip to fit in a breadboard]]]
1 - serial tx, hardwired on the board, so don't use it for anything else
</td>
2 - button
<td>
5 - pwm for blue led
Many DIP chips will not fit into a breadboard straight from the factory. Bend the pins inward to make them fit, but bend them simultaneously against a flat surface (so they will bend an equal amount.)
6 - pwm for yellow led
</td>
7 - vibration motor
</tr>
8 - speaker, for use with tone() function -> this will mess up
pwm on pins 3 and 11
9 - pwm for the rc servo
A0 - accelerometer X
A1 - accelerometer Y
A2 - accelerometer Z
A3 - flex sensor
A4 - pressure sensor
*/


</table>
// include files here
#include "pitches.h" // so that we can play notes, not used here
#include <Servo.h> // to control the rc servo motor

// define global variables here
Servo myservo;
int X, Y, Z, flex, pressure;

// setup() runs once,
// use it to initialize functions and variables
void setup() {
Serial.begin(115200); // setup the serial port to talk at 115200 baud
myservo.attach(9);
pinMode(2, INPUT); // setup pin 2 as an input for the switch
pinMode(7, OUTPUT); // setup pin 7 as an output for the vibration motor
}

// loop() runs forever,
// put your code in here
void loop() {
X = analogRead(A0); // read the value, returns 0-1023 for 0-5V
Y = analogRead(A1);
Z = analogRead(A2);
flex = analogRead(A3);
pressure = analogRead(A4);
if (digitalRead(2)) {
int pos = map(Y, 0, 1023, 0, 180); // change the full range of the sensor
// to the full range of the servo
myservo.write(pos); // pos is the angle of the servo, 0-180 degree
int freq = map(Z, 0, 1023, 31, 5000);
tone(8, freq); // 8 is the pin, freq is the frequency to play
int blue = map(flex, 0, 1023, 0, 255);
analogWrite(5, blue);
int yellow = map(pressure, 0, 1023, 0, 255);
analogWrite(6, yellow);
digitalWrite(7, HIGH); // turn on the vibration motor
}
else {
noTone(8); // turn off the sound
digitalWrite(7, LOW); // turn off the vibration motor
// if the button is not pushed, send the analong values to the computer
// divide by 2 because Stripchart can only show numbers 0-512
Serial.print(X/2);
Serial.print(" ");
Serial.print(Y/2);
Serial.print(" ");
Serial.print(Z/2);
Serial.print(" ");
Serial.print(flex/2);
Serial.print(" ");
Serial.println(pressure/2);
}
delay(20); // wait this many ms before going again
}
</pre>


The functions you can use in your code are listed at [http://arduino.cc/en/Reference/HomePage]


You can power your Arduino off USB power while testing, or using the 3.7V LiPo battery with the LiPo Charger/Booster board to go mobile. From the Boost board, connect GND to the Arduino ground, and VCC to the Arduino 5V.

'''WARNING 1''' Do not connect the USB and battery to the Arduino at the same time

'''WANRING 2''' Do not pull the battery out of the charging board by the wires, try to pull it out by the white plastic connector

Revision as of 05:01, 6 September 2018

Welcome to the Mechatronics portion of Bootcamp!

Circuit Building and Programming with Arduino

Python Programming with Mu

Circuit Building and Programming with the Itsy Bitsy Express M0 on Mu


These gifs are experimental, let me know if they work as a learning tool.


[Wire stripping]

To strip a wire, use the correct wire stripping hole for your wire gauge. Our wire is 22 or 24 gauge. Scissor the wire, and pull off the insulation. If you use a stripping hole that is too small for your wire, the cutter will nick the wire and it will be more likely to break off at the nick.

[Connecting wires]

To connect two wires, place them parallel and twist around each other. Try not to allow one to twist around the other - get both to twist.

[Making stranded wire solid]

To make a stranded wire solid, fan out the strands and then twist. Tin the end to make it a solid wire. (See below)

[Soldering]

To solder, tin the tip of the soldering iron. Use the iron to heat the wire. When the wire is hot enough, add solder to the joint. The solder should wick into the joint. If it does not, the wire is not hot enough. Use more tinning on the iron tip to allow better contact with the wire.

[Tinning stranded wire]

Tin the end of a stranded wire the same way. Avoid adding too much solder or the wire will be too fat to fit into a breadboard.

[Using heat shrink]

To protect a solder connection, apply heat shrink tubing. Heat shrink tubing shrinks a little less than 50%, so make sure the tubing is a snug fit before trying to shrink. Use a hot air gun to shrink the tube. Be sure to cover the exposed wire, and part of the insulation (for strain relief). Tape is a distant second-best.

[Soldering a wire to a PCB]

To solder a wire into a PCB hole, stick the wire in the hole and tape it so it can't fall out. Heat the wire and the hole at the same time. Apply solder to the wire and hole and it should wick in. Look for the conical (volcano) shape as the solder adheres to the pad and the wire. If you get a sphere instead, it's called a "cold joint" and usually will fail.

[Soldering header pins to a PCB]

Stick the header pins into a breadboard. Solder the first pin. Reheat the first pin, and while still heating, move the board to be perpendicular with the header pins. Hold the board as you remove the iron to fix the board into position. Then solder the remaining pins.

[How to get a chip to fit in a breadboard]

Many DIP chips will not fit into a breadboard straight from the factory. Bend the pins inward to make them fit, but bend them simultaneously against a flat surface (so they will bend an equal amount.)