Posts

Of cars and goats

Image
Some days ago, while listening to an exam exercise, I learned about an old story that happened in the early nineties. It seems it stirred quite a controversy at the time. It was about a TV show where a contestant was offered to chose one door out of three to win a car. The setup was that only behind one of the doors a car was present while the two others contained a goat. Apparently, most people value the car as the good prize but could not care less about the goat, that was the losing item. The host would open a door different than the one the contestant chose to reveal, invariably a goat. And later the host will offer the contestant to switch to the other remaining door. The controversy was about what was the best choice the contestant could do: to switch or to keep the original choice. We all agree that, initially, the contestant has one of out of three chances to win the car. However, when the host opens one of the remaining (non chosen) doors showing a goat it is not so c...

Hello Clipper, bye JTS

Image
Polygon clipping and polygon offsetting are operations that due to the multitud of cases possible are quite a difficult beast to tame. That is why I have used an external library when I have needed such a feature in a program. A few days ago, researching for a student's assignment, I learned that " clipper " library had been migrated to Java  by Tobias Mahlmann.  I had a minor trouble with one file not using UTF-8 encoding but other than that it compiled and run beautifully (not in my large display though as I am using an scale factor larger than one that messes the Java GUI layout). Another interesting detail is that the code will need Java 1.8 to compile as it uses a Lambda function in one of the Comparators used. However, I wanted to use it with some older code that was using 1.6 and the compiler was not happy with my version request, so I needed to do a small change to get rid of the Lamba function code in favor of an inner class.  Once the code was worki...

OpenSCAD kept crashing on Ubuntu 16.04 with AMD drivers

Image
After the upgrade of my computer's graphics card for a new AMD RX 460 I noticed OpenSCAD program was crashing all the time with a segmentation fault (every time I pressed F5 or F6). But the problem would only happen if I was using AMD native driver (amdgpu-pro). I saw no references online to this specific problem which was weird. I decided to buy the RX 460 as it apparently had good Linux support, so it was odd to have this kind of problem but no matter what version of the driver I was using or what version of OpenSCAD nightly build I could not use the application. I managed to get an AppImage version that worked without a problem in my system and that is what I have been using for a while. Today, I have decided to check if somehow problem could he related to my locale, so I invoked the application like this:  LC_ALL=C openscad-nightly And lo and behold, OpenSCAD is working as it should, no problem whatsoever. So it is clear that my Spanish locale was what caused the probl...

Windows 10 on vmplayer

Image
From time to time there is some software I need to use that is only available for Windows. For that I kept an old virtual machine I created ten years ago that was running Windows XP and served me well over the years. But the last instance of software in point was the latest Netfabb  Standard 2017, that is only available as a 64bit Windows version. So I grabbed a Windows 10 ISO from Microsoft Imagine shop and fed it to my virtual machine. After some time I got a new virtual machine running Windows 10, or almost. I could see networking was not working nor was audio. I could see many people reporting different problems with various virtualisation tools and Windows 10 but it was not clear what my problem was, so after following several wrong paths I realized the system was complaining about not having a driver for the hardware found. I checked on the configuration file and I could see the network device was "vlance" and I replaced it for "e1000" and the latter was e...

Lots of changes at once and one OpenSCAD bump

Image
In order to get my new 4k display connected to my Linux box at work I had to replace the graphics card (actually I was replacing none but the motherboard's one). For the 3840x2160 resolution I selected a cheap ATI board that apparently had decent Linux support, the $100 board RX460. First problem was my computer did show nothing on the new screen, that was fixed connecting the old one and using the BIOS to switch default video to the new card. Then Ubuntu 14.04 would boot but failed to recognize the new card, which makes sense as the driver was not install. However I would get graphics working using the software rendered (frame buffer). When looking for the Linux drivers I realized I would need to upgrade to Ubuntu 16.04, something I wanted to do for a while but kept leaving for a rainy day. One colleague at work mentioned to me he have had quite a good experiencing upgrading a couple of systems from 14.04 to 16.04 so I was set to do it then, now that it was supposed to be easy...

Wifi watching

Image
Like train spotting, bird watching, I guess that wifi watching could become a thing, or so could be if you use this nice app for your Android phone. I avoid the term wardriving because it assumes you drive a vehicle and it has a dubious or evil aim (or may be that is only my interpretation). I was touched by the work of these artists that visited and gave a talk at our campus a year ago. So I just went out for running an errand and grabbed nearly 900 different SSIDs around the block. The Wifi Collector app will grab both access point information plus geographical location using the phone location services. Data can later be exported as a CSV file or KML file to be used with Google Earth as the image here shows. While I did not uncover any political message or funny stuff on the SSIDs names on the surroundings, I guess it can be another way of catching and reviewing your walks (runs?) around the city.  I will use this app more than once just for a new way of perceiving the ...

Spark on a Printrbot Simple Metal

Image
One dry winter day I noticed a spark jumped from my finger when toughing the metal plate of a Printrbot Simple metal printer. Next time I tried to use that printer the hot-end would ram into the print bed so I had to stop the printer immediately. I remembered the spark incident and I assumed damage was done due to that static discharge. On to find a solution. Printrbot forums showed several entries about damaged sensors and how to replace them. Others had to replace both the inductive proximity sensor plus the Printrboad control electronics too. But one thing I noticed is that my inductive sensor was apparently working, as the LED will lit when approaching a metal part to it. After testing with M119 command, I realized that as odd as it might seem, now my printer thought the signal on Z-MIN end-stop was reversed. So it was triggered when the LED was off and open when the LED was lit. That was pretty odd but as the sensor seemed to be working I set my path to modify the firmware confi...

More on STM32

Image
After testing different choices, I have come to test a package called Platformio that runs over Atom editor. Atom is a multiplatform code editor that looks a bit like Sublime but it is open source and they claim highly hackable. The nice thing about PlatformIO is that it looks like a nice IDE that can handle a good portion of embedded processors from Arduino variants, to ESP8266 and ESP-32 to many ARM variants from NXP, ST, Atmel, etc. For the f103c8t6 board I am using I can use the config details above in platformio.ini file in the project folder and it all works nicely on one of my Macs, the one using El Capitan. Unfortunately, my laptop is still running Mavericks and for that it seems there is not a libusb available that plays nicely with ST-Link programmer/debugger dongle. Now I am going to target my dcservo code for this Cortex M3 processor.

STM32 or the pain I have been avoiding for quite a while

Image
If you follow the blog you know I use Arduino IDE for quite a while and I am quite fond of the eco- system as it usually makes things simple. With some effort, same environment works for other beefier processors like ESP8266 or even STM32. But what usually kept me away from the various ARM offerings, with the exception of mbed on-line compiler for Nucleo boards has been the commitment level manufacturers seem to ask from engineers before they can start to think using their wonderful hardware. So far my point has been that life is to short to go through so many manuals and datasheets. Recently, an American maker told me he was about to build a piece of hardware using a STM23F103C8T6 core to mimic my dcservo project I built around Arduino and other processors (even around a Maple Mini with a similar STM32 processor in fact). He would welcome any help on the software side of things so I had to have a look at how I could help and ventured into the wild west of development tools for t...

Make a heated bed with 9 calibration points.

Image
Most likely you have learned that the new Prusa i3 from Prusa Research is including a nice self-calibration feature based on the special heated bed they use. That bed features a grid of nine disks that can be detected by an inductive sensor that moves with the hotend carriage. These spots double as bed leveling and XY geometry calibration. While the bed is flat an covered by a special (PEI) film to improve adhesion, the spots can be easily replicated if using an aluminium bed as my video below shows. Nine inserts of 8mm steel rod can be used by doing nine holes of the same diameter on the aluminium bed. The interesting feature is that steel is detected further away than the surrounding aluminium so the same algorithm should work if you build your bed like this. In fact you can just place the aluminium sheet on top of your existing heated bed (though doing so may increase bed weight needlessly). According to the calibration source code these are the locations of each poi...

Installing PIL on OSX

Image
I have got some messages about installing PIL library on a Mac assuming it is a Windows-only library. It is not. I have never used Python Image Library before, but when I designed 4xiDraw drawing machine I used one Inkscape plug-in that was intended for laser engraving. I hacked it just a bit to make it work with my machine. The plug-in itself is a simple two-file thing you need to copy to your ~/.config/Inkscape/extensions/ but the PIL library may be a bit of a challenge on some systems. It is important to use 0.91 version of Inkscape as the plugin will not work with an older version. Other than that it should work in Windows, OSX and Linux. What worked for me are the following commands on an opened terminal session: sudo easy_install pip sudo pip install pillow

Reaching your Pi over your network

Image
There are multiple ways of learning what is the IP address your Raspberry Pi is obtaining from a router. The most obvious one is to use the router's DHCP client list. Another one is to use a HDMI display as your RPi will report its IP address while booting. The former requires administrative access to the router, which may not be possible on certain networks and the latter is only possible if you can connect the display to the RPi and you have a display available. What I am going to propose requires no special rights over the network gear not any additional hardware. One of the things you can do over a network is to broadcast a message (in fact this is the foundation of the DHCP protocol for a computer to find a suitable DHCP sever over the network without previous knowledge of it). Sending a UDP broadcast message allows any other system on the network to hear it. And if that message is received each receiver knows immediately the sender's IP address. So here is what I...

First experience with RPi3

Image
I am working on a project that required some computing power and commanding an Arduino UNO running GRBL. Things have changed quite a bit from original plan, so because radio reception was awful, the original plan of using dump1090 with a USB dongle had to be ditched. Of course I only learned that once I have it working nicely on the Raspberry Pi 3. Plan B would be to use the Ethernet network interface. Once that was working we realized it was not possible on our target installation. Plan C was to use wifi. And while it is really simple to get it working with stock Jesse, I found a way to waste my time when I added spaces in between variables and equal signs in /etc/wpa_supplicant/wpa_supplicant.conf . So now you have been warned. # Include files from /etc/network/interfaces.d: source-directory /etc/network/interfaces.d auto lo iface lo inet loopback iface eth0 inet manual auto wlan0 allow-hotplug wlan0 iface wlan0 inet dhcp wpa-conf /etc/wpa_supplicant/wpa_supplicant....

My Printrbot experience

Image
While some friends were waiting for their first Printrbot off Kickstarter I had already built one with the parts Brook Drumm posted on Thingiverse. That was quite a while ago. It was a cute little machine that I sold to a fellow reprapper. Last year , while I was working on a closed-loop DC motor controller for replacing the steppers of our 3D printers, Brook Drumm offered to help and sent me a free Printrbot Simple Metal, fully assembled to be used as a testbed printer for such type of motion control. I had a difficult time trying to convince the taxman that the printer was really a gift and eventually I had to gave in and pay some custom taxes although that was not really a product I was buying and the sender was charging me no money for that. I was surprised of how compact the thing appeared and how smooth and solid all the axis moved. However, the 3d printer was not intended to be used as a 3d printer and the first thing I had to do was to partially disassemble a brand new unit...

Stepper-motor speed profile generation

Image
My 4xiDraw project has been a source of inspiration for other projects. A while ago I mentioned how to add wireless connectivity to a serial-based device, but for a subject I teach I wanted to get a bit deeper on the details about stepper motor timing generation for trapezoidal (or any other) speed profile. While this functionality is implemented in every CNC or 3D printer controller software, most of them are based on GRBL development, which is efficient but not easy to grasp on a first look. There are many different but related algorithms working together there. Just by chance I bought a Wemos D1 board that replaces the Arduino UNO Atmega 328 by an ESP8266 but keeps the UNO form factor. It was a weird proposal but I bought anyway as we all know that anything that stamps wifi on it makes it a better product. I have used the ESP8266 in the past, through the Arduino IDE, but I have never needed to achieve any realtime operation. But once I checked that CNCshield board could be ...

G-code over wifi

Image
In the past I tried a Bluetooth link for sending g-code wirelessly to a 3D printer. It works ok but it seems a bit slow so eventually small stops happen while printing (buffer empties). Wifi was an expensive option at the time so I forgot about it. Recently, the availability of the excellent ESP-link firmware together with NodeMCU/ESP12E boards for less than $5 painted a different scenario and while I was not on an immediate need of it I decided to give it a try during my summer holidays. That firmware could be used with smaller and cheaper ESP8266 boards but I have found much more convenient to use (as they include their own voltage regulator) the so-called Nodemcu, just $1 more or so. These boards pack a 32bit SoC with 4Mbytes of flash and, lately, they are even supported through the Arduino IDE. In order to keep the printer still usable through USB connected to a computer I patched Marlin so I could use an additional serial port for the wifi connection. The problem was that ...

Eavesdropping your own wifi network

Image
I was recently ask by a friend about how certain P2P wireless cameras can be accessed from a cellphone with no router configuration. I had no idea about those cameras or its so-called P2P-thing whatever that was that tricked your home router so your camera can be accessed using a mobile app. Of course if both the wifi camera and the cellphone belong to the same LAN there is a simple answer, but when they belong to different networks and there are one or more routers in between things may get murkier, specially when one or more of these routers are broadband routers (marketing-talk for NAT boxes). The problem of reaching one host on the Internet from another is: to figure out its IP address to be able to connect to it (this is where firewalls may be a problem for your communication) However, if a device is connected to a home network with Internet access, it is most likely served by one of these broadband routers, that will block any connection attempt that might come from...

Buliding a Prusa i3 MK2

Image
I have built (or help others building) quite a few Prusa i3, from sets I sourced myself, including the self-printed parts to commercial kits from bq or Josef Prusa himself. But when I saw the latest i3 version I was surprised about the ingenuity of some its solutions. Having used kits from Prusa3D before I knew they left no details unattended, so I could understand them charging more than others. We are very happy with the i3 we built from kit so next time we needed to get some printers I had to decide between what I reckon are two good choices: bq's Hephestos 2 or Prusa i3 MK2. H2 has larger bed but it does not have a heated bed. MK2 can do more materials and can print hotter than H2, so we stayed to that. The kit comes is a box similar to the cardboard box of a mini-tower PC. There are different smaller boxes and plastic bags inside with the assorted components.  And it comes with its own set of tools (not the red box but the other tools).  Motors come well protec...

Useful uses of screen command

Image
Every now and then I am using command-line tools. I work with daily with OSX and Linux and they both have in common the availability of a powerful command line tool. The same could be said about Windows, but that would be an overstatement, as CMD.EXE provides not the efficiency level that can be achieved with other systems. But even if it could, they chose to make it different. Anyway, many times I am working over remote terminals on other's computers command line tools and one thing that may not be welcome is for a program to destroyed your temporary data or to just stop working whenever the connection is broken. If you are using a so-called broadband router you may realize than some remote terminal sessions die for no good reason. (The real reason is that after a few minutes without seeing any traffic through a TCP connection your home router will kill the connection without you knowing it). Let say you are editing a text file on a remote computer through an ssh connection ...

Painless transition to El Capitán

Image
My aging desktop computer is a 2011 iMac. When I bought it I loved the concept that would allow me a clean desktop. Truth be told and not iMac's fault, my desktop is almost always a mess despite de computer form factor. Since I upgraded it to Snow Leopard (mostly for the nee to use a newer version of Java) I have learned about some SMART error on the hard drive. Once I started to feel the pressure of certain application binaries not running because my system libraries were too old, I wanted to upgrade the system but I could not. OSX install would check the hard disk and it will refuse to upgrade if found defective. Whatever the problem my 1TB is suffering is not killing it for more than two years. And the iMac being the DIY-unfriendly that it is I keep delaying the hard disk replacing. A few months ago I found a spare USB hard disk at home and I used it to install Mavericks on it (yeah, I am not in a hurry to get next memory-hog upgrade). It all worked nicely while I keep on ...