Arduino DEV – using a MOSFET to control a DC Motor

Using a MOSFET to control a DC Motor

There is a current limit of 40ma for an Arduino pin. So how can we control circuits that require larger currents such as motors or even mains circuits? There are three key ways of doing this and they each have their own advantages and disadvantages:

Relays – mechanical or solid-state. This is the easiest way of controlling mains circuits – where simple on/off control is required. Solid-sate relays are typically used where safe operating conditions preclude mechanical action that may create sparks. Opto-isolators are often used to further isolate the mains circuit from the low-level circuit.
Where mains circuits are being varied (for example a light dimmer) then a triac can be used often in conjunction with an opto-isolator. They can be used for on-off switching too.
The simplest circuit for motor control is the use of a transistor. It’s possible to use a transistor (BJT or a MOSFET) but the MOSFET applies infinitesimal load on the driving circuit so it has a clear advantage.

Using the supplied MOSFETs to drive a DC motor

Without going into the complexities of the MOSFET we can treat it as a switch. If we apply a potential to the Gate it will switch the current through the Source/Drain junction. So we connect the gate to the Arduino through a 220 ohm current limiting resistor to protect the Arduino. Then we connect the motor to the external power supply and the Drain of the MOSFET. We complete the circuit by connecting up the grounds. In this case the MOSFET controlling the motor is driven from Arduino Pin 9.

Circuit


/*

Speed up the motor

This example shows how to control the speed of a DC motor an LED on pin 9 using the analogWrite() function. This example based on the Arduino Example Fade sketch but modified to use timing instead of the delay() function

*/

int turns = 0; // how fast the motor runs

int turnAmount = 1; // how many turns the motor makes

unsigned long currentTime;

unsigned long loopTime;

void setup() {

// declare pin 9 to be an output:

pinMode(9, OUTPUT);

currentTime = millis();

loopTime = currentTime;

}

void loop() {

currentTime = millis();

if(currentTime >= (loopTime + 20)){

// set the speed of pin 9:

analogWrite(9, turns);

// change the turnings for next time through the loop:

turns = turns + turnAmount;

// speed up or slow down the motor

if (turns == 0 || turns == 255) {

turnAmount = -turnAmount ;

}

if (turns == 0) {

delay(5000);

}

loopTime = currentTime; // Updates loopTime

}

// Other processing can be done here

}

http://www.oddwires.com/using-a-mosfet-to-control-a-dc-motor/

VirtualBox: Cannot Register the Hard Drive Because a Hard Drive with UUID Already Exists

Failed to open the hard disk xxxx.
Cannot register the hard disk xxxxxxxx because a hard disk xxxxxx with UUID …… already exists

Virtualbox registra un identificativo univoco dell’hd e non ci permette di utilizzare una copia dello stesso file per un altra macchina virtuale.
Per poterlo utilizzare cambiamo l’UUID con il seguente programma e quindi possiamo utilizzare il nostro disco su un altra VM

vboxmanage internalcommands sethduuid hd.vdi

Apple OSX Make an ISO from the Install.app

# ==============================================================
# 10.9. Make an ISO from the Install.app
# ==============================================================
# Mount the installer image
hdiutil attach /Applications/Install\ OS\ X\ Mavericks.app/Contents/SharedSupport/InstallESD.dmg -noverify -nobrowse -mountpoint /Volumes/install_app

# Convert the boot image to a sparse bundle
hdiutil convert /Volumes/install_app/BaseSystem.dmg -format UDSP -o /tmp/Mavericks

# Increase the sparse bundle capacity to 8GB to accommodate the packages
hdiutil resize -size 8g /tmp/Mavericks.sparseimage

# Mount the sparse bundle for package addition
hdiutil attach /tmp/Mavericks.sparseimage -noverify -nobrowse -mountpoint /Volumes/install_build

# Remove Package link and replace with actual files
rm /Volumes/install_build/System/Installation/Packages
cp -rp /Volumes/install_app/Packages /Volumes/install_build/System/Installation/

# Unmount the installer image
hdiutil detach /Volumes/install_app

# Unmount the sparse bundle
hdiutil detach /Volumes/install_build

# Resize the partition in the sparse bundle to remove any free space
hdiutil resize -size `hdiutil resize -limits /tmp/Mavericks.sparseimage | tail -n 1 | awk ‘{ print $1 }’`b /tmp/Mavericks.sparseimage

# Convert the sparse bundle to ISO/CD master
hdiutil convert /tmp/Mavericks.sparseimage -format UDTO -o /tmp/Mavericks

# Remove the sparse bundle
rm /tmp/Mavericks.sparseimage

# Rename the ISO and move it to the desktop
mv /tmp/Mavericks.cdr ~/Desktop/Mavericks.iso

Publishing a RTMP stream from avconv to RTMP Server Wowza using the following command

To publish a RTMP stream from avconv you can use the following command;

avconv -i http://10.0.0.101:2004/bysid/10 -acodec libfaac -acodec libfaac -b:a 96k -vcodec libx264 -filter:v yadif -b:v 900k -preset superfast -threads 4 -bt 2500 -qcomp 0.7 -f flv rtmp://127.0.0.1/live/myStream

This makes a RTMP stream available at rtmp://127.0.0.1/live/myStream .

You can play the stream in VLC using the following link http://127.0.0.1:1935/live/myStream/playlist.m3u8