Showing posts with label Video. Show all posts
Showing posts with label Video. Show all posts

2017/05/12

A remote controlled AC power switch with visual monitoring capability

As a 3D printing and electronics hobbyist, I recently developed a device to help me remotely monitor my print and cut off power to my printer in case it starts making spaghetti.

Different Flavors of 3D Printed Spaghetti

Spaghetti Making Videos:
https://youtu.be/YS6gH66_7yE
https://youtu.be/87gsL-Luvis

2016/10/27

2016/09/15

App Inventor 2 - Add Play / Pause Feature To The Song Player App.

This post is the continuation of my 2 previous posts on AI2 (see below links).

Learning Android Programming Through MIT App Inventor 2
http://wei48221.blogspot.tw/2016/09/learning-android-programming-through.html#more

App Inventor 2 - How to Duplicate Project
http://wei48221.blogspot.tw/2016/09/app-inventor-2-how-to-duplicate-project.html#more

In "Learning Android Programming Through MIT App Inventor 2", I created a simple App. which plays back a song when the image (which represents a button) on the screen is touched. In this post, I want to add the start -> pause -> start (resume) feature. That's, when the image is touched for the 1st time, the App. will play back the song. When the image is touched again, the playback is paused. The playback is resumed when the image is touched again.

Below is a simple flow chart showing the entire process.




2016/09/07

Learning Android Programming Through MIT App Inventor 2

To me, the most difficult part in doing Android programming is in knowing details such as which libraries to be included, which functions to be invoked, what parameters to pass, etc..

While searching for ways to solve my problem, I came across a video called "Convert App Inventor to Java" (https://www.youtube.com/watch?v=FqNTc4DVYW8). I found that the way Derek converted his App. made with App. Inventor into Java seemed like a good solution.

This is a quick summary of how I created an App. using App Inventor 2 and re-wrote it in Java using Android Studio 2.2.

The App. that I made using App Inventor 2 is a very simple App. that plays back a song whenever I click on the picture on the screen. The detail on how to build this App. can be found at http://www.appinventor.org/content/CourseInABox/Intro/courseinabox.

The MIT App Inventor 2 is available for free at http://ai2.appinventor.mit.edu/.

App. developed using MIT App. Inventor 2

2016/08/28

Collection of Python Programming Tips

Below is a list of Python programming tips which I consider useful for a newbie like me. More will be added to the list as I venture further into this language.

Sending / Reading E-Mail

Raspberry Pi - How to email CPU temperature using python
http://wei48221.blogspot.tw/2016/08/raspberry-pi-how-to-email-cpu.html

How to programmatically read e-mails from the Gmail server using Python and IMAP protocol
http://wei48221.blogspot.tw/2016/08/how-to-programmatically-reads-e-mail.html

String

Python: How to determine whether a substring is in a different string
http://stackoverflow.com/questions/7361253/python-how-to-determine-whether-a-substring-is-in-a-different-string

Converting integer to string in Python?
http://stackoverflow.com/questions/961632/converting-integer-to-string-in-python

Formatting

How to print without newline or space?
http://stackoverflow.com/questions/493386/how-to-print-without-newline-or-space

On-Line Learning Resources

Learn Python The Hard Way
https://learnpythonthehardway.org/book/preface.html

Learn Python Through Public Data Hacking

Delete File 

Python Delete/Remove a File If Exists On Disk
https://www.cyberciti.biz/faq/python-delete-remove-file-if-exists-on-disk/

2016/07/29

Collection of Raspberry Pi tips

As a newbie to Raspberry Pi, here is a collection of Raspberry Pi related info. which I find very useful.

SD Card related

Removing Raspberry Pi partitions from SD card under Windows 7
http://brucesbraindump.blogspot.tw/2013/04/removing-raspberry-pi-partitions-from.html

How to check the free space of SD card
https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=38417

2016/07/15

Eagle PCB - The importance of setting ground plane clearance

This is a quick summary of my finding while debugging the motor control board.

Symptoms:

- The LM317T failed to generate the intended 12V output voltage (it only outputs 1.5V ~ 1.6V). The chip functions normally after it's removed from the board;

- The motor keeps spinning even without PWM input from the timer (according to my design, the motor should not spin without PWM input).

Troubleshooting:

After double checking the schematic and testing the component (LM317T) removed from the board, I thought the problem was with the PCB board itself so I took a new board and soldered the LM317T with 2 resistors and the power cables for testing. As the output of LM317T was still around 1.5V ~ 1.6V, I decided to increase the voltage from 12V to 24V to see if it will change anything. At this moment I noticed there were sparks coming out from the point where the red wire is connected to the board (see below video and photo).







It's when I realize there is a short between the Power and the Ground Plane.

Here is the setting used to generated the ground plane of the board, the clearance (Isolate) is set to 0 (dumb dumb).


Isolate = 0.012".


Isolate = 0.016".


Isolate = 0.024".


Sparkfun recommends setting the value for Isolate to 0.012". I think I will go with 0.016" or even 0.024" (where possible) for extra safety.


Now the cause of the problem is identified, time to get back to Eagle to modify the ground plane clearance and fix some issues found in the board. Life is fun!! :-)

References

Using EAGLE: Board Layout
https://learn.sparkfun.com/tutorials/using-eagle-board-layout/finishing-touches

TUTORIAL on how to add a ground plane to a pcb in the Cadsoft Eagle layout editor.
http://www.pcbway.com/project/share/TUTORIAL_on_how_to_add_a_ground_plane_to_a_pcb_in_the_Cadsoft_Eagle_layout_editor_.html

2016/07/07

Single channel 12V / 24V, 5A(?) brush DC motor control board with H/W select-able PWM sources

This board is design for the DIY Filament Extruder (click here to see the project).

3 of this board are needed to control the speed of the 3 motors of the filament winder assembly (under construction).

The board is of the same size as Arduino Uno. The position of the 4 holes on the board match the locations of the 4 holes on the Arduino Uno board.




Theoretically, the board can handle 12V or 24V DC motor with maximum current of 5A. Will need to test it to see if it could actually handle it.

Run "run length-freq-ri" in Eagle PCB to see the length and maximum current for each trace.


Note, Cu thickness = 0.035mm = 13.78mil (~1 oz copper, 14mil = 1 oz copper).

Demo Videos

DC 12V/24V Brush Motor Speed Control with Arduino Uno


DC 12V/24V Brush Motor Speed Control with 555 Timer


Note,

This board doesn't have built-in mechanism to control the rotation direction of the motor. In order to control the rotation direction, a Double Pole Double Throw (DPDT) Switch needs to be installed between the PWM_OUT and the Motor for the User to manually control the direction.

Next Steps

- Have the board manufactured by a PCB house;
- Develop a H-bridge DC motor speed and direction control board using MOSFETs.

References

Eagle QuickTip: Measure Trace Length (and more)
https://blog.adafruit.com/2012/02/13/eagle-quicktip-measure-trace-length-and-more/

Simplest Method to Make a Motor Turn Off, Turn On, Go Forwards, and Go Backwards
http://www.robotroom.com/DPDT-Bidirectional-Motor-Switch.html

2016/06/21

Interfacing a RC transmitter with a computer

This post is about how to interface a RC transmitter for plane / boat / car with a computer. The purpose of doing so is to use the RC transmitter to control the games / simulators running on the interfaced computer. For this post, I will be using DEVO 7E and RX601, but this post is applicable to any RC transmitter and receiver pair that works with Servo motor similar to the one shown below.

DEVO 7E Transmitter and RX601 Receiver
3-wire Servo 

How it works?

An Arduino Uno board is used to take in the PWM signals from the PWM outputs of the receiver. The PWM signals are then processed by the software running on the Arduino Uno board to come out with the control signals to be fed to the computer connected to the Arduino Uno board via a USB cable. The computer treats the input signals as from a connected joystick and the signals are used to control the games / simulators running on the computer.

The PWM waveforms

Before a program can be made to process the PWM signals, we need to know how they look. The photo below shows the division of the channels on the RX601 receiver.

The waveform of the PWM output of each channel on the receiver are shown below.










Code

#include "UnoJoy.h"

int tmp;
unsigned long time_now;

void setup(){

  setupPins();
  setupUnoJoy();
}

void loop(){
  // Always be getting fresh data

  dataForController_t controllerData = getControllerData();
  setControllerData(controllerData);
}

void setupPins(void){
  // Set all the digital pins as inputs
  // with the pull-up enabled, except for the
  // two serial line pins

  for (int i = 2; i <= 12; i++){
    pinMode(i, INPUT);
    digitalWrite(i, HIGH);
  }
  pinMode(A4, INPUT);
  digitalWrite(A4, HIGH);
  pinMode(A5, INPUT);
  digitalWrite(A5, HIGH);

  // RX601 Receiver CH1 Input,
  pinMode(A0, INPUT);
 
}

dataForController_t getControllerData(void){

  //  Set up a place for our controller data
  //  Use the getBlankDataForController() function, since
  //  just declaring a fresh dataForController_t tends
  //  to get you one filled with junk from other, random
  //  values that were in those memory locations before

  dataForController_t controllerData = getBlankDataForController();

  //  Since our buttons are all held high and
  //  pulled low when pressed, we use the "!"
  //  operator to invert the readings from the pins
  //  The section below is not used in our application.
  //---------------------------------------------------------------
  controllerData.triangleOn = !digitalRead(2);
  controllerData.circleOn = !digitalRead(3);
  controllerData.squareOn = !digitalRead(4);
  controllerData.crossOn = !digitalRead(5);
  controllerData.dpadUpOn = !digitalRead(6);
  controllerData.dpadDownOn = !digitalRead(7);
  controllerData.dpadLeftOn = !digitalRead(8);
  controllerData.dpadRightOn = !digitalRead(9);
  controllerData.l1On = !digitalRead(10);
  controllerData.r1On = !digitalRead(11);
  controllerData.selectOn = !digitalRead(12);
  controllerData.startOn = !digitalRead(A4);
  controllerData.homeOn = !digitalRead(A5);
  //--------------------------------------------------------------

  // Get the input from CH1 of RX601

  while (digitalRead(A0) == LOW) {}
  time_now = micros();
  while (digitalRead(A0) == HIGH) {}
  tmp = micros() - time_now;
  controllerData.leftStickX = tmp >> 2;
  //Serial.println(tmp);

  while (digitalRead(A1) == LOW) {}
  time_now = micros();
  while (digitalRead(A1) == HIGH) {}
  tmp = micros() - time_now;
  controllerData.leftStickY = tmp >> 2;
  //Serial.println(tmp);

  while (digitalRead(A2) == LOW) {}
  time_now = micros();
  while (digitalRead(A2) == HIGH) {}
  tmp = micros() - time_now;
  controllerData.rightStickX = tmp >> 2;
  //Serial.println(tmp);

  while (digitalRead(A3) == LOW) {}
  time_now = micros();
  while (digitalRead(A3) == HIGH) {}
  tmp = micros() - time_now;
  controllerData.rightStickY = tmp >> 2;
  //Serial.println(tmp);

  // And return the data!
  return controllerData;
}

Demo Video

Click here to play the demo video on Youtube.


For more about how to prepare Arduino Uno for the above application, please refer to the posts mentioned in the reference section below.

References

How to use Unojoy with Arduino Uno

How to turn Arduino Uno into HID Keyboard - Part 2 of 2

How to turn Arduino Uno into HID Keyboard - Part 1 of 2
http://wei48221.blogspot.tw/2016/06/arduino-uno-hid-keyboard-joystick-part.html

---------------------------------------------------------------------------------------------------------------------

Buying Info.

I've prepared a kit that contains one Arduino Uno board pre-configured and pre-loaded with the necessary software and accessories (see below photos for the included items). Please e-mail me if you want to order or have any questions.

Price: US$30 per kit;
Shipping: Free shipping for order over US$50 to most major countries (please contact me to see if free shipping is applicable to your location);
Tax and tariffs: To be paid by the buyer;
Item location: Taipei, Taiwan;
Items included:
- 1 x Arduino Uno board;
- 1 x USB cable;
- 6 x Jumping wires with connectors.


The photo below shows how to connect the RX601 with the Arduino Uno board.