Month: November 2014

HeeksCNC error: operands to ?: have different types “wchar_t” and “wxString”

I was compiling HeeksCNC as explained here:
https://code.google.com/p/heekscnc/wiki/DebianPackagesBuild

But when compiling it fails with this error message:

HeeksCNC.cpp:1402:46: error: operands to ?: have different types "wchar_t*" and "wxString"

I fixed it casting with (wxString):

$ vi src/HeeksCNC.cpp

From:
filename = (wxGetenv(wxT("XDG_CONFIG_HOME"))?wxGetenv(wxT("XDG_CONFIG_HOME")):wxFileName::GetHomeDir() + wxT("/.config")) + wxT("/heekscnc/") + resource;

To:
filename = (wxGetenv(wxT("XDG_CONFIG_HOME"))? (wxString) wxGetenv(wxT("XDG_CONFIG_HOME")):wxFileName::GetHomeDir() + wxT("/.config")) + wxT("/heekscnc/") + resource;

Now it compiles fine!

Installing HeeksCAD in Debian 8.0

Just follow these instructions:
https://code.google.com/p/heekscad/wiki/BuildDebianPackages

And replace libwxgtk2.8-dev by libwxgtk3.0-dev as explained below.

First, download source code, compile and install libarea:

$ sudo apt-get install subversion build-essential debhelper cmake libboost-python-dev
$ svn checkout http://libarea.googlecode.com/svn/trunk/ libarea
$ cd libarea/
$ dpkg-buildpackage -b -us -uc
$ cd ..
$ sudo dpkg -i libarea*.deb python-area*.deb

Install dependences libraries for heekscad:

$ sudo apt-get install liboce-visualization-dev libwxgtk3.0-dev libgtkglext1-dev python-dev

Download heekscad source code:

$ svn checkout http://heekscad.googlecode.com/svn/trunk/ heekscad

Edit debian/control replacing libwxgtk2.8-dev dependence by libwxgtk3.0-dev:
$ cd heekscad/
$ vi debian/control
Rename libwxgtk2.8-dev to libwxgtk3.0-dev

Finally compile and install heekscad:

$ dpkg-buildpackage -b -us -uc
$ cd ..
$ sudo apt-get install wx3.0-i18n
$ sudo dpkg -i *heeks*.deb

Como cuidar do mandril porta-pinça (collet) do seu CNC

Se seu CNC usa um mandril porta-pinça, também chamado de engate rápido, ou collet (termo inglês), então você precisa tomar alguns cuidados com ele para garantir a qualidade da fresagem.

A primera dica é limpar bem seu collet usando WD40, pois o óleo ou graxa que vem de fábrica no seu collet pode reduzir o atrito dela com a broca. Além disso graxa ressecada no seu collet pode contribuir para o desalinhamento (runout) da broca.

Após terminar seu trabalho você deve limpar seu collet antes de guarda-lo, evitando assim que detritos de metal, poeira ou gotas do líquido refrigerante (usado para resfriar a peça sendo fresada) fiquem presos no collet. Use uma pequena brocha de latão para limpa-lo. Verifique atentamente se não ficou nada encrustado nas lacunas do collet, mante-las livre é muito importante, uma vez que elas devem se expandir ou contrair para prender bem as brocas.

Se você notar sulcos, ranhuras ou deformações no seu collet, então pode estar na hora de troca-lo. Para evitar estes problemas é sempre bom tomar cuidado no manuseio e principalmente na hora de instala-lo e na inserção da broca.

Fonte: http://www.mmsonline.com/articles/be-kind-to-to-your-collets

Testing CC3200-Launchxl board with NuttX compiling on Linux

I decided to test my CC3200-Launchxl board and after pluging the board on USB it reports:

usb 3-2: new full-speed USB device number 4 using xhci_hcd
usb 3-2: New USB device found, idVendor=0451, idProduct=c32a
usb 3-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 3-2: Product: USB  JTAG/SWD
usb 3-2: Manufacturer: FTDI
usb 3-2: SerialNumber: cc3101

Nice, but it didn’t create a ttyUSB serial interface. Fortunately I discovered this trick!

$ sudo modprobe ftdi_sio
$ sudo echo 0451 c32a > /sys/bus/usb-serial/drivers/ftdi_sio/new_id

Now the ttyUSB interface is created:

$ dmesg
...
usbcore: registered new interface driver usbserial
usbcore: registered new interface driver usbserial_generic
usbserial: USB Serial support registered for generic
usbcore: registered new interface driver ftdi_sio
usbserial: USB Serial support registered for FTDI USB Serial Device
ftdi_sio 3-2:1.0: FTDI USB Serial Device converter detected
usb 3-2: Detected FT2232C
usb 3-2: Number of endpoints 2
usb 3-2: Endpoint 1 MaxPacketSize 64
usb 3-2: Endpoint 2 MaxPacketSize 64
usb 3-2: Setting MaxPacketSize 64
usb 3-2: FTDI USB Serial Device converter now attached to ttyUSB0
ftdi_sio 3-2:1.1: FTDI USB Serial Device converter detected
usb 3-2: Detected FT2232C
usb 3-2: Number of endpoints 2
usb 3-2: Endpoint 1 MaxPacketSize 64
usb 3-2: Endpoint 2 MaxPacketSize 64
usb 3-2: Setting MaxPacketSize 64
usb 3-2: FTDI USB Serial Device converter now attached to ttyUSB1

Then I decide to compile NuttX for this board:

$ git clone git://git.code.sf.net/p/nuttx/git nuttx
$ cd nuttx/nuttx
$ cd tools
$ ./configure.sh cc3200-launchpad/nsh
$ cd ..
$ make menuconfig
$ make
$ cp nuttx.bin /tmp

Now is time to flash nuttx.bin in the board. First you need to put the board in bootloader mode. You need to remove the jumpers from TCK and from SOP2, then connect TCK to SOP2 using a female header wire, just connect an end of wire to TCK pin (pin nearest to TCK label) and another end of wire to pin SOP2 (pin nearest to number 2 label at SOP area). Press RESET button and execute:

# ./cc3200prog /dev/ttyUSB1 /tmp/nuttx.bin 
Open UART /dev/ttyUSB1
open UART success
Getting storage list
Bootloader Version: 4
Unable to open file dll/rbtl3101_132.dll
Silicon version ES1.32 or higher
Unable to open file dll/rbtl3100s.dll
Load common boot command for PG1.33 or higher
erasing file "/sys/mcuimg.bin"
deleting file "/sys/mcuimg.bin"
erase file completed
Downloading file "/sys/mcuimg.bin" with size 54460
Open operation failed

Hmm, I need these *.dll (although its name, it is not a Windows DLL), these files are inside energia-0101E0013-*.tgz package:

$ cp -r energia-0101E0013/hardware/tools/lm4f/bin/dll .

Lets try again:

# ./cc3200prog /dev/ttyUSB1 /tmp/nuttx.bin 
Open UART /dev/ttyUSB1
open UART success
Getting storage list
Bootloader Version: 4
Silicon version ES1.32 or higher
Bootloader version is 2, 1, 4, 0
It's a CC3200 device: PG1.33 or higher
Switch UART pinmux to APPS
Switch to NWP bootloader complete
Load common boot command for PG1.33 or higher
Bootloader version is 2, 0, 4, 0
BlockSize is 4096, number of blocks is 16
erasing 13 blocks starting from  0
erasing file "/sys/mcuimg.bin"
deleting file "/sys/mcuimg.bin"
erase file completed
Downloading file "/sys/mcuimg.bin" with size 54460
..............
Download complete

After resetting the board, NuttX will start and you will see it on ttyUSB1 (115200 8n1):

CC3200 init                                                                  
                                                                             
NuttShell (NSH)                                                              
nsh>

You can remove the wire connected to TCK and SOP2 pins. Also you can return with TCK jumper, but please don’t return SOP2 jumper, otherwise NuttX will not boot from external flash.

An easy way to classify accelerometer vibration

I developed an Android solution to identify if a vehicle is stopped with the engine turned off, or stopped with engine turned on or if it is moving.

Instead of working with all three axis separately I decided to calculate the magnitude of the vector using the formula:

magnitude = sqrt(x^2 + y^2 + z^2);

This way if the device is stopped in the right position (Z axis is aligned to gravity force) the magnitude will be “9,8…”. This is exactly the value of gravity force.

I retrieved 1000 samples with the device stopped on the floor and when plotting a histogram I noticed that the magnitude values are concentrated in discretes positions (9,82.. 9,86.. 9,78.. 9,85.. etc). Also I noticed these positions may vary slightly from device to device, but it always will concentrate in 4 or 5 positions.

Then I decided to add up all occurrences of each individual magnitude from these 1000 samples (it is like creating a vector that represents the histogram). Now I could to identify all 4 more frequent magnitudes.

If the device is in movement the magnitude values for these 1000 samples will be distributed almost equally, but yet at least 4 or 5 magnitudes will surpass all the others. If I add up these four more frequent magnitudes I could to classify the type of vibration.

Historic memories: how to create a DOS executable in the EDIT.COM

This is an old trick I used to do in the EDIT.COM of DOS to impress my friends. I discovery that some binary instructions could be represented in the text editor.

This is the sequence to create an executable that prints the ALAN name:

ALT 180 // 180 = B4h = mov AH
ALT 02  // 2
ALT 178 // 178 = B2h = mov DL
A       // C
ALT 205 // 205 = CDh = INT
!       // ! = 33 = 21h
ALT 178 ...
L
ALT 205
!
ALT 178
A
ALT 205
!
ALT 178
N
ALT 205
!
ALT 180 // mov AH
L       // L = 4Ch 
ALT 205 // INT 21 => exit to DOS
!

This will generate this binary file sequence:

B4 02 B2 43 CD 21 B2 4C CD 21 B2 41 CD 21 B2 55
CD 21 B2 44 CD 21 B2 49 CD 21 B2 41 CD 21 B4 4C
CD 21

This assembly instructions are equivalent to assembly instruction:

MOV AH,02 ; To select subfunction 2, move the appropriate number, 2, to AH.
MOV DL,”A” ; In the interrupt list, it says that the character to output should be
INT 21h ; in register DL. So we move the character to DL.
; Finally when all the registers are set as required, we call the interrupt.

MOV AH,4Ch ; Select the subfunction
INT 21h ; Select a return value (optional but recommended)
; Call the DOS interrupt.

Using Blender to develop for 3D Printer

I’m developing a new project with more complex shapes and I need tight control over all meshes as accurate as possible. Initially I was planing to use FreeCAD, but my FreeCAD’s skill is limited.

Then I decide to test Blender to 3D printing. Fortunately since version 2.67 Blender has a native 3D Printing Toolbox. The Blender toolbox is useful to analyze your object before sending it to printer, this way you will save time and money.

I started reading this tutorial:
http://vdorchester.hubpages.com/hub/How-To-Make-Models-For-3D-Printing

First thing you need to do is enable the 3D Print toolbox addon. It is not enabled by default, but it is just a preference checkbox. Easy, en?

A useful tutorial is this from Shapeways: http://www.shapeways.com/tutorials/prepping_blender_files_for_3d_printing

I still learning about using Blender for 3D Printing, but I decided to post these links here to help other people willing to use Blender.

Another good video tutorial: http://cgcookie.com/blender/2013/02/04/modeling-3d-printing-shapeways/

How to print to Makerbot Replicator 2X using open-source tools

I’m trying to print on Makerbot Replicator 2X using open-source software instead using Makerware software.

Initially I used Cura: http://software.ultimaker.com with Cura_Makerbot_standard_profile.ini. You just need to select File -> Open Profile and choose Cura_Makerbot_standard_profile.ini.

Unfortunately Cura 14.09 in my Debian Jessie/sid is not able to detect and communicate with Replicator2X over serial port (ttyACM0). Then I decided to “Save GCode …” and then convert this saved myfile.gcode to myfile.x3g that can be read by Replicator2X from SD Card.

$ gpx -g -m r2x myfile.gcode myfile.x3g

It “barely workes”. I noticed the object is printed more to right side of build bed. Then my suggestion is to put the object more to left side of Cura bed before saving the gcode file.

Conclusion: this approach is not mature enough, but could work if you really care about using only open-source software to control your Makerbot Replicator 2X.