3D Printing Supply Estimator

By ctherouxNo Comments

A GCode Analyzer for 3D printing is now available. This on-line tool estimates the amount of filaments required and the cost to print a 3D object. Give the filament type, customize some parameters if needed and upload the GCode files. Dual extrusion is supported. The current version is beta. Click on 3d printing GCode analyzer to give it a spin.

3D Printing, GCode

Accessing a serial port from a web server

By ctherouxNo Comments

On most Linux distribution, it is impossible to access a serial port (ex. /dev/ttyS0) from a web server such as Apache or lighttpd using a cgi. Simply add the user under which the web server runs (www-data for example) to the group dialout. To do so, use vigr from the command line and add the user on the dialout group line. Such a line will typically look like:

dialout:x:20:myuser,www-data
Raspberry PI, Ubuntu, Ubuntu 11.04, Ubuntu 11.10, Ubuntu 12.04, Unix, Wheezy

Script listing all the keys on a memcache server

By ctherouxNo Comments

This script lists all the keys on a memcache server.

#!/bin/bash
nc localhost 11211 > /tmp/$$.1 <<EOF
stats items
EOF
cut -d: -f2 /tmp/$$.1 | grep -v END | uniq  | sed 's/^/stats cachedump /' \ 
   | sed 's/$/ 1000/' > /tmp/$$.2
nc localhost 11211 < /tmp/$$.2 | grep -v '^END' | sort 
rm /tmp/$$.[12]
memcache, Ubuntu, Ubuntu 11.04, Ubuntu 11.10, Ubuntu 12.04, Unix

Preventing warping when printing 3D ABS objects

By ctherouxNo Comments

The biggest issue when printing 3D ABS objects is warping. As an example, this 8 cm x 8 cm bit holder is badly warped. In this example, 5 mm.

Adding disks (1.5 cm x 1 mm) at each corners prevents warping almost completely. These anti-warping disks can be easily added on the plater of Slic3r. The printing end result printing is shown on the picture below. 1 cm x 0.6 cm disks also works fine.

After trimming the disks, the end result is very good. Warping is less than 0.2 mm.

You can download the OpenScad source file along with some rendered files.

3D Printing, ABS, Prusa Mendel

VirtualBox does not run or runs slowly under Windows 8

By ctherouxNo Comments

Windows 8 comes with Hyper-V pre-installed.  If you want to run Virtual Box, you must completely uninstall Hyper-V through the “Add and Remove Programs” option from the Control Panel.  Failing doing so will result in:

  • Virtual Box will display error messages when starting up your Virtual Machine
  • You will not be able to change the number of processors in Virtual Box
  • You virtual machine will run very slowly because of the inability to increase the number of processors
  • Hardware acceleration will be disabled

Stopping the Hyper-V service is not enough.

Virtual Box, Windows, Windows 8

Cannot reach 110 Celsius with a Prusa PCB Heated Bed Mk 1

By ctherouxNo Comments

I was not able to reach 110 Celsius with a Prusa PCB Header Bed MK1. My initial installation was with the PCB traces down with a borosilicate glass on top of it. I found out that installing it with the traces up as show below resolved the issue. Nevertheless, the thermistor does not read the real printing area temperature since it is underneath the PCB. There is a 15 Celsius offset and the glass is slightly offsetted.  These are small inconveniences.  The bed is getting hot pretty fast and is able to reach 110 Celsius.

3D Printing, Prusa Mendel

G-Code commands supported by Marlin

By ctherouxNo Comments

The G-Code commands supported by Marlin 3D printing firmware are:

Implemented Codes
G0 G1
G1 Coordinated Movement X Y Z E
G2 CW ARC
G3 CCW ARC
G4 Dwell S or P
G10 retract filament according to settings of M207
G11 retract recover filament according to settings of M208
G28 Home all Axis
G90 Use Absolute Coordinates
G91 Use Relative Coordinates
G92 Set current position to cordinates given

RepRap M Codes
M0 Unconditional stop. Wait for user to press a button on the LCD (Only if ULTRA_LCD is enabled)
M1 Same as M0
M104 Set extruder target temp
M105 Read current temp
M106 Fan on
M107 Fan off
M109 Wait for extruder current temp to reach target temp.
M114 Display current position

Custom M Codes
M17 Enable/Power all stepper motors
M18 Disable all stepper motors; same as M84
M20 List SD card
M21 Init SD card
M22 Release SD card
M23 Select SD file (M23 filename.g)
M24 Start/resume SD print
M25 Pause SD print
M26 Set SD position in bytes (M26 S12345)
M27 Report SD print status
M28 Start SD write (M28 filename.g)
M29 Stop SD write
M30 Delete file from SD (M30 filename.g)
M31 Output time since last M109 or SD card start to serial
M42 Change pin status via gcode
M80 Turn on Power Supply
M81 Turn off Power Supply
M82 Set E codes absolute (default)
M83 Set E codes relative while in Absolute Coordinates (G90) mode
M84 Disable steppers until next move, or use S to specify an inactivity timeout, after which the steppers will be disabled. S0 to disable the timeout.
M85 Set inactivity shutdown timer with parameter S. To disable set zero (default)
M92 Set axis_steps_per_unit same syntax as G92
M114 Output current position to serial port
M115 Capabilities string
M117 display message
M119 Output Endstop status to serial port
M140 Set bed target temp
M190 Wait for bed current temp to reach target temp.
M200 Set filament diameter
M201 Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000)
M202 Set max acceleration in units/s^2 for travel moves (M202 X1000 Y1000) Unused in Marlin!!
M203 Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in mm/sec
M204 Set default acceleration: S normal moves T filament only moves (M204 S3000 T7000) im mm/sec^2 also sets minimum segment time in ms (B20000) to prevent buffer underruns and M20 minimum feedrate
M205 advanced settings: minimum travel speed S=while printing T=travel only, B=minimum segment time X= maximum xy jerk, Z=maximum Z jerk, E=maximum E jerk
M206 set additional homeing offset
M207 set retract length S[positive mm] F[feedrate mm/sec] Z[additional zlift/hop]
M208 set recover=unretract length S[positive mm surplus to the M207 S*] F[feedrate mm/sec]
M209 S<1=true/0=false> enable automatic retract detect if the slicer did not support G10/11: every normal extrude-only move will be classified as retract depending on the direction.
M220 S- set speed factor override percentage
M221 S- set extrude factor override percentage
M240 Trigger a camera to take a photograph
M301 Set PID parameters P I and D
M302 Allow cold extrudes
M303 PID relay autotune S sets the target temperature. (default target temperature = 150C)
M400 Finish all moves
M500 stores paramters in EEPROM
M501 reads parameters from EEPROM (if you need reset them after you changed them temporarily).
M502 reverts to the default “factory settings”. You still need to store them in EEPROM afterwards if you want to.
M503 print the current settings (from memory not from eeprom)
M999 Restart after being stopped by error
3D Printing, GCode, Marlin

Enable the TRIM command on Mountain Lion for SSD drives

By ctherouxNo Comments

To know if TRIM is enabled for a particular drive, open “System Profiler” and search for the “TRIM enable” information in the “Serial ATA sub-tree”.

If TRIM is not enabled, the easiest way to enable it is to:

  1. Download Trim Enabler
  2. Install “Trim Enabler”
  3. Run ”Trim Enabler” and enable TRIM
  4. Power off your computer and power it on again
  5. Start “System Profiler” and look if TRIM is enabled as described above

Be aware that some SSD does not support TRIM.

MAC OS X, Mountain Lion

Building a Prusa Mendel Iteration 2 3D Printer

By ctherouxNo Comments

It is not obvious to choose and get a 3D printer. There is quite a lot a choices on the market which can be divided in two categories: pre-assembled and kits. Pre-assembled printers are expensive. Kits can be a quite a challenge to assemble as per many testimonials on the web.

I was fortunate enough to attend a 3D printer building workshop given by Voxel Factory. Each participant build his own fully functionnal Prusa Mendel 3D printer in a week-end! Yes, in two days not weeks. Since then, I have printed not only bunnies (I have printed one!) but useful pieces such as filament holders, Raspberry PI plate, Raspberry PI cases, Arduino cases, Dremel tool holders, etc.

If you decide to assemble your own 3D printer, it worth doing it with someone who has experience. 3D printing needs some know how and experience. Expect to see my tricks and tips posted on this blog.

3D Printing

Ralink RT5572 based WiFi Usb Dongle setup on Ubuntu 12.04

By ctheroux12 Comments

The WiFi USB dongles based on the newest RT5572 chip set do not work out of the box on Ubuntu.  Unex DNUR-V72, D-Link DWA-160 Rev B and TP-Link TL-WDN3200 dongles are based on this chipset.

You will need to compile the source code of the driver to make it work.  Do not leave this page!  This involves only a few easy steps.

1. Save this page’s link.  You will have to reboot and come back to it.

2. Un-plug the WiFi USB dongle from your computer.

3. Reboot your computer.

4. Download the driver’s source code from the manufacturer website. Alternatively, you can download a version of this file from this site. Files have been already edited. Steps 9, 10 and 11 are then unnecessary. Note that the filename is slightly different (DPO_RT5572_LinuxSTA_2.6.0.1_20120629_EDITED.tar.bz2.bz2).

5. Open a terminal window.

6. Change to the directory that contains the driver’s source code downloaded previously.  For example,

cd /home/myuser/Downloads

7. Extract the source code.  You might need the modify the file name since Mediatek may publish newer source code.  For example (there is two bz2 extensions!),

tar xvf DPO_RT5572_LinuxSTA_2.6.0.1_20120629.tar.bz2.bz2

8. Change to the source code directory

cd DPO_RT5572_LinuxSTA_2.6.0.1_20120629

9. Edit the file os/linux/config.mk.  Set to y the two variables HAS_WPA_SUPPLICANT and HAS_NATIVE_WPA_SUPPLICANT_SUPPORT.  Your file shall shows

# Support Wpa_Supplicant
# i.e. wpa_supplicant -Dralink
HAS_WPA_SUPPLICANT=y
# Support Native WpaSupplicant for Network Maganger
# i.e. wpa_supplicant -Dwext
HAS_NATIVE_WPA_SUPPLICANT_SUPPORT=y

10. Edit the file os/linux/usb_main_dev.c. Add a line containing MODULE_LICENSE(“GPL”);. This line is important. The position of the line is important. Your file shall shows

MODULE_DESCRIPTION("RT2870 Wireless Lan Linux Driver");
MODULE_LICENSE("GPL");
#ifdef CONFIG_STA_SUPPORT
#ifdef MODULE_VERSION

11. Edit the file common/cmm_mac_usb.c and add the lines “#define usb_buffer_alloc(a, b, c, d) usb_alloc_coherent(a, b, c, d)” and “#define usb_buffer_free(a, b, c, d) usb_free_coherent(a, b, c, d)“. The position of the lines is important. Your file shall shows

#ifdef RTMP_MAC_USB

#define usb_buffer_alloc(a, b, c, d) usb_alloc_coherent(a, b, c, d)
#define usb_buffer_free(a, b, c, d) usb_free_coherent(a, b, c, d)

#include        "rt_config.h"

12. In the same directory as step #8, compile the driver’s source code. Type the following command:

sudo make

13. Install the driver. Type the following command:

sudo make install

14. Plug your WiFi USB dongle.
15. After a few seconds, you should see an interface called ra0 if you type the following command:

sudo ifconfig

16. Configure your connection as you would normally do.

Linux, Ubuntu, Ubuntu 11.04, Ubuntu 11.10, Ubuntu 12.04, WiFI

2.4 GHz WiFi channels

By ctherouxNo Comments
Channel Center Frequency (GHz)
1 2.412
2 2.417
3 2.422
4 2.427
5 2.432
6 2.437
7 2.442
8 2.447
9 2.452
10 2.457
11 2.462
12 2.467
13 2.472
14 2.484

each having a 22 MHz channel width

WiFI

Recording a terminal session under Linux

By ctherouxNo Comments

It is possible to record a terminal session under Linux with ttyrec. It also records vi, emacs, etc. sessions.

Fisrt, install ttyrec

sudo apt-get install ttyrec

To start recording a session:

ttyrec

To replay a session recording:

ttyplay ttyrecord
Linux, Raspberry PI, Ubuntu, Ubuntu 11.04, Ubuntu 11.10, Unix, Wheezy

A step by step guide to setup a Bluetooth keyboard and mouse on the Raspberry PI

By ctheroux34 Comments

A lot of people is having problem setting up a Bluetooth keyboard and mouse on the Raspberry PI. Things get more complicated when your wired keyboard or mouse does not work or prevent your Bluetooth dongle from working. There is hope. This step by step procedure will let you install them or at a minimum let you know what does not work. It uses only the command line interface. It is targeted for the Wheezy Debian distribution.

    • First of all, if you already tried to set them up and they do not work, start with a fresh install of the OS. This will rule out anything you have done before that would prevent this procedure from working.
    • Plug the Bluetooth dongle directly on the Raspberry PI board.
    • Boot the Raspberry PI and connect to it using SSH from another computer if possible.  Otherwise, use a wired or wireless keyboard. Logon as pi, password raspberry.
    • Switch to root
sudo bash
    • Install all the updates.  It will take a while.
apt-get update
apt-get upgrade
    • Enable dbus
update-rc.d -f dbus defaults
    • Reboot
reboot
    • Reconnect as described above. Logon as pi, password raspberry. Switch to root.
    • Install the required packages.  It will take a while.
apt-get install bluetooth bluez-utils blueman
    • Reboot and reconnect as described above. Logon as pi, password raspberry. Switch to root
    • Make sure that your Bluetooth dongle is recognized. If not, unplug it and re-plug it.
lsusb
    • Make your Bluetooth device discoverable. Refer to the device manual.
    • Make sure that your device is seen by the Raspberry PI. Take note of its MAC address (ex. 75:EF:82:69:D2:83)
hcitool scan
    • Pair the device. When requested, type a pin like 0000 and hit ENTER. If you are pairing a keyboard, type the PIN you have entered and hit ENTER on the keyboard you are pairing. If you are pairing a mouse, you also need to type a PIN of 0000 when requested and hit ENTER. This PIN might depends on the mouse manufacturer.
bluez-simple-agent hci0 75:EF:82:69:D2:83
    • Make the device trusted.
bluez-test-device trusted 75:EF:82:69:D2:83 yes
    • Connect the device. After a few seconds, your device will be usable.
bluez-test-input connect 75:EF:82:69:D2:83
  • Repeat the steps from “Make your Bluetooth device discoverable” if you need to install another device.
  • When you will reboot, the devices will reconnected automatically after a few seconds.

This procedure worked for the following devices:

  • Cambridge Radio Bluetooth dongle
  • Microsoft Bluetooth Mobile Keyboard 6000
  • Apple Bluetooth Keyboard (iPad keyboard)
  • HipStreet mini bluetooth keyboard
  • RocketFish Bluetooth Mouse
  • Razer Orochi Mouse
  • iPazzPort Bluetooth (Model KP-810-10BTT)
  • Ultra eXo mini keyboard/touchpad
Debian, Linux, Raspberry PI, Wheezy

Initializing A Wireless Connection At Boot Time

By ctherouxNo Comments

You can initialize your Raspberry PI wireless connection automatically at boot time if the instructions given in a previous post entitled How To Setup A Protected Wireless Connection Via The Command-Line worked. This is pretty straight forward. You must be root to carry out these instructions.

Save the wpa.conf file created in the previous post somewhere on the SD card you use to boot the system. For example in /root/bin/wpa.conf.

Create the following script and save it in a file called /root/bin/initWiFi for example

#!/bin/bash

/sbin/wpa_supplicant -Dwext -iwlan0 -cwpa.conf -B
/sbin/dhclient wlan0

Protect the files

chmod 700 /root/bin/initWiFi
chmod 600 /root/bin/wpa.conf

Add to the file /etc/rc.local before the last exit statement the following line

bash /root/bin/initWiFi
Debian, Raspberry PI, Wheezy

How To Setup A Protected Wireless Connection Via the Command-Line

By ctheroux1 Comment

Setting up a wireless connection via the command line may vary depending on the USB Wireless Interface you are using. These instructions also work for the Raspberry PI running Wheezy. You must be root in order to carry out these instructions.

Make sure that your wireless interface is recognized.

lsusb

Find your wireless interface name (usually wlan0).

ifconfig

Make sure that your network is visible asssuming the ESSID is broadcasted. Replace wlan0 by you wireless interface name.

iwlist wlan0 scan

or

iwlist wlan0 scan | grep ESSID

Prepare your wireless configuration file. It will wait for you to type in your wireless network password. Enter your wireless network password an hit ENTER.

wpa_passphrase Replace-with-your-ESSID > wpa.conf

Find out which wireless driver you are using. The drivers are listed in the drivers section. The driver you are using is usually labelled “Linux wireless extensions”. The driver name is most of the time wext.

wpa_supplicant --help

Initialize the wireless interface. Make sure you replace wpa.conf, wext and wlan0 with the values related to your environment. Some error messages may be displayed. These errors might not prevent your wireless connection from working.

wpa_supplicant -Dwext -iwlan0 -cwpa.conf -B

You can check if your wireless interface is properly initialized.

iwconfig

Issue this command to get an IP address assuming you are using DHCP.

dhclient wlan0

You can install wpa_passphrase and wpa_supplicant is they are not already on your system by issuing the command

apt-get install wpasupplicant
Debian, Linux, Raspberry PI, Ubuntu, Unix, Wheezy

Masquerading or replacing outgoing SMTP email address with Postfix

By ctherouxNo Comments

Postfix can replace an outgoing email address by another one. To do so, you must perform these steps:

Add in /etc/postfix/main.cf the following line

smtp_generic_maps = hash:/etc/postfix/generic_maps

Add in hash:/etc/postfix/generic_maps a line for each email address you want to replaced.  The line shall contain the email address to replace followed by the new email address separated by a space.  For example:

user@machine-name emailaddress@domain.tld

Generate or update the map by issuing the following command

postmap /etc/postfix/generic_maps

Restart postfix by issuing the following command

service postfix restart
postfix, Ubuntu, Ubuntu 11.04, Ubuntu 11.10, Unix

Create an ext3 or an ext4 partition without a journal

By ctherouxNo Comments

Most of the time, having a journal for ext3 and ext4 partitions is pretty useful. Nevertheless, you can prevent creating a journal by adding the option ^has_journal. For example:

mkfs -t ext4 -O ^has_journal /dev/sdXn
Ubuntu, Ubuntu 11.04, Ubuntu 11.10, Unix

Initializing a brand new disk with “parted”

By ctherouxNo Comments

“parted” is a replacement for “fdisk” of Linux.  It can handle disks larger than 2 TB.  Issue this command to launch “parted” where /dev/sdL is the disk you want to initialize.

parted /dev/sdL

Create a partition table if it does not exists. For disks larger than 2 TB, you should use the gpt type. You can create such a partition table by issuing this command within “parted”. msdos is the legacy partition table type.

mktable gpt

To create a new partition, mkpart is used to do so. This parted command creates a primary ext4 partition, starting at the first cylinder to the last sector of the disk. You should align your partitions. You can use the parted command align-check to do so.

mkpart primary ext4 1 -1

Quit parted and create your partition using mkfs. For example,

mkfs -t ext4 -m 0 -O dir_index,filetype,sparse_super /dev/sdLX

You can type help to display the list of commands. You can type help followed by a command to display specific help related to this command.

Ubuntu, Ubuntu 11.04, Ubuntu 11.10, Unix

How to download Android source code

By ctherouxNo Comments

Source code of Android can be downloaded by following these steps:

$ mkdir ~/bin
 $ PATH=~/bin:$PATH
 $ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
 $ chmod a+x ~/bin/repo
 $ mkdir WORKING_DIRECTORY
 $ cd WORKING_DIRECTORY
 $ repo init -u https://android.googlesource.com/platform/manifest
 $ repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
 $ repo sync

android-4.0.1_r1 can be replaced by any version displayed in the previous step. The download process will take a while.

Android

Installing the Android Development Environment for Windows 7

By ctherouxNo Comments

This post lists the main steps in order to install an Android development environment for Windows 7.  The developement environment relies on Eclipse.

  1.  Download a JDK (7u3)  from the following page: http://www.oracle.com/technetwork/java/javase/downloads/index.html.
  2. Install the JDK
  3. Set the environment variable JAVA_HOME that points to the installation directory of the JDK
  4. Download Eclipse Classic (3.7.2)  from the following page: http://www.eclipse.org/downloads/
  5. Unzip the Eclipse package where you want to install it.
  6. Download the  SDK starter package from http://developer.android.com/sdk/index.html.
  7. Install the SDK starter package
  8. Launch Eclipse and install the ADT plug-in
    1. Select “Help > Install New Software….”
    2. Add the Indigo repository:  http://download.eclipse.org/releases/indigo
    3. Add the repository https://dl-ssl.google.com/android/eclipse/
    4. Select “Developer Tools” and click next until it gets installed
    5. When Eclipse will restart, you will have to install some SDK’s.
Android, Windows
Blue Taste Theme created by Jabox