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.