diff --git a/docs/assignments/fabxiao/dc_motor_toshiba.zip b/docs/assignments/fabxiao/dc_motor_toshiba.zip new file mode 100644 index 0000000000000000000000000000000000000000..7e2f420a0b29a13f657e1bd15eea3de71a9be6e7 Binary files /dev/null and b/docs/assignments/fabxiao/dc_motor_toshiba.zip differ diff --git a/docs/assignments/fabxiao/dc_motor_toshiba_traces.zip b/docs/assignments/fabxiao/dc_motor_toshiba_traces.zip new file mode 100644 index 0000000000000000000000000000000000000000..fecf599fbe6711c48451a682ecedaab7371b77a1 Binary files /dev/null and b/docs/assignments/fabxiao/dc_motor_toshiba_traces.zip differ diff --git a/docs/assignments/fabxiao/xiao_motor/xiao_motor.ino b/docs/assignments/fabxiao/xiao_motor/xiao_motor.ino new file mode 100644 index 0000000000000000000000000000000000000000..b67d28aaaf396ba05867a7e914f6ce9e7f73a4b3 --- /dev/null +++ b/docs/assignments/fabxiao/xiao_motor/xiao_motor.ino @@ -0,0 +1,33 @@ +//Fab Academy 2023 - Fab Lab León +//Motor +//Adrianino +//Fab-Xiao RP2040 +const int switch1Pin = 1; // switch 1 +const int motor1Pin = 26; // H-bridge pin 0 (in2) +const int motor2Pin = 27; // H-bridge pin 1 (in1) + +void setup() { + // set the switch pins as input pins and activate their internal pull up resistors + // so they are not in a floating state because their default state is now HIGH + pinMode(switch1Pin, INPUT); + + + // set H-bridge pins as outputs: + pinMode(motor1Pin, OUTPUT); + pinMode(motor2Pin, OUTPUT); + } + +void loop() { + // if switch1 is pressed, (=LOW because the unpressed 'pulled up' state is HIGH) + + if (digitalRead(switch1Pin) == HIGH) { + analogWrite(motor1Pin, 255); // set pin 1 of the H-bridge to 50% using PWM + analogWrite(motor2Pin, 0); // set pin 2 of the H-bridge to low state + } + // if neither of the switches are pressed, the motor will stand still + else + { + digitalWrite(motor1Pin, 0); // set pin 1 of the H-bridge low + digitalWrite(motor2Pin, 255); // set pin 2 of the H-bridge low + } + } diff --git a/docs/fabxiao.html b/docs/fabxiao.html index 8b1a9610ccf9fe658f31c2b949a8b715e599af87..4af4a6e51eed593cdc23a6984c15924d6d08cd99 100644 --- a/docs/fabxiao.html +++ b/docs/fabxiao.html @@ -109,6 +109,7 @@ <ul class="actions"> <li><a href="#outputs" class="button primary">Outputs</a></li> <li><a href="#servo" class="button">Servo motor</a></li> + <li><a href="#motor" class="button">DC motor</a></li> <li><a href="#oled" class="button">OLED</a></li> <li><a href="#rgb" class="button">RGB LED</a></li> </ul> @@ -912,6 +913,64 @@ void loop() { <p><video controls width="100%"; max-width="800"><source src="images/fabxiao/servo.mp4" type="video/mp4"></video></p> + <h2><a id="motor"></a>DC motor</h2> + <p>To control a DC motor we will use an H bridge, such as the <a href="https://www.digikey.es/en/products/detail/TB67H451FNG%2cEL/264-TB67H451FNGELCT-ND/11568783"><b>Toshiba TB67H451FNG.</b></a> With this driver we can control all types of motors through <b>PWM signals.</b> </p> + + <li><b>Connection and schematic</b></li> + <p>In this case, being a component without a module, I create my own. I design and manufacture a small board where I solder the Toshiba TB67H451FNG driver, a 1uF capacitor, a 10uF capacitor and with the flat connectors where there is no room for mistakes when connecting it. It includes two traces to feed with the 5V and ground. I use two digital output of the XIAO RP2040 GPIO 26 (Arduino pin 26) and GPIO 27 (Arduino pin 27).</p> + + <span class="image main"><img src="images/fabxiao/xiao_26.jpg" alt="" /></span> + + <p>Here you can find the design in Eagle and the PNG's to create the board.</p> + + <p><a href="assignments/fabxiao/dc_motor_toshiba.zip"><b>- Motor Schematic + Board</b></a> + <p><a href="assignments/fabxiao/dc_motor_toshiba_traces.zip"><b>- Motor traces and interior</b></a></p> + + <p><img src="images/fabxiao/xiao_27.jpg" width="50%"; max-width="700" /></p> + + <li><b>Programming</b></li> + <p>Here you will find the programming to use a servo motor. Here you can find the Arduino file to download.</p> + + <p><a href="assignments/fabxiao/xiao_motor/xiao_motor.ino"><b>- Arduino Motor</b></a> + + + <pre><code>//Fab Academy 2023 - Fab Lab León +//Motor +//Adrianino +//Fab-Xiao RP2040 +const int switch1Pin = 1; // switch 1 +const int motor1Pin = 26; // H-bridge pin 0 (in2) +const int motor2Pin = 27; // H-bridge pin 1 (in1) + +void setup() { + // set the switch pins as input pins and activate their internal pull up resistors + // so they are not in a floating state because their default state is now HIGH + pinMode(switch1Pin, INPUT); + + + // set H-bridge pins as outputs: + pinMode(motor1Pin, OUTPUT); + pinMode(motor2Pin, OUTPUT); + } + +void loop() { + // if switch1 is pressed, (=LOW because the unpressed 'pulled up' state is HIGH) + + if (digitalRead(switch1Pin) == HIGH) { + analogWrite(motor1Pin, 255); // set pin 1 of the H-bridge to 50% using PWM + analogWrite(motor2Pin, 0); // set pin 2 of the H-bridge to low state + } + // if neither of the switches are pressed, the motor will stand still + else + { + digitalWrite(motor1Pin, 0); // set pin 1 of the H-bridge low + digitalWrite(motor2Pin, 255); // set pin 2 of the H-bridge low + } + }</code></pre> + + <p><video controls width="100%"; max-width="800"><source src="images/fabxiao/motor_xiao.mp4" type="video/mp4"></video></p> + + <h2><a id="oled"></a>OLED</h2> <p>For this example I am going to use an OLED with an I2C communication module. In my case, I bought it through Amazon from AZDelivery, here is the <a href="https://www.amazon.com/AZDelivery-Display-Arduino-Pixels-Module/dp/B07F5JKXD9/ref=sr_1_7?dchild=1&keywords=128+x+64+OLED&qid=1601808816&sr=8-7"><b>link.</b></a> This company has a multitude of very interesting tutorials, including that of the <a href="https://www.az-delivery.de/en/products/1-3-zoll-display-kostenfreies-e-book?_pos=3&_sid=180149b80&_ss=r"><b>OLED module with I2C.</b></a></p> diff --git a/docs/images/fabxiao/xiao_26.jpg b/docs/images/fabxiao/xiao_26.jpg new file mode 100644 index 0000000000000000000000000000000000000000..dbcb70d4e5af2b62b7cbfbfe00beb1735f2128ca Binary files /dev/null and b/docs/images/fabxiao/xiao_26.jpg differ diff --git a/docs/images/fabxiao/xiao_27.jpg b/docs/images/fabxiao/xiao_27.jpg new file mode 100644 index 0000000000000000000000000000000000000000..494908b0575fc3c37e083a7cd511a960c4151d9b Binary files /dev/null and b/docs/images/fabxiao/xiao_27.jpg differ