Posts

Showing posts from 2016

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 do to …

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.conf #----…

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 and …

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 used (an…

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 I alre…

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 on 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 addressto 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 the Internet t…

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 protected, as some of…

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 when …

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 using…

On placing a tag on an area

Image
The common approach I have used in the past for locating a tag on a given 2D shape has been to use the centroid location. For convex parts there is a very good solution. However, when the shape is not convex the centroid location may be outside of the shape surface.



Whenever the tags are intended to identify a shape it might be a problem is the label falls outside of the shape, even more so when multiple shapes are packed together, as user may not be able to be sure which label belongs to which part.

One idea of fixing that is to make sure the tag location is always inside the part, and for that purpose I have evolved through for different algorithms, trying to find the best result.

Algorithm 1 If centroid is within the shape area, then just use that. When it is outside (concave shape) then an horizontal sweep is done in 10% increments, at the centroid height, looking for a spot within the shape area. If that is not found, then same approach is repeated with a vertical sweep at the ce…

A cheap idea for thermal imaging

Image
Sometimes I needed to check how heat was distributed on a surface. A cool but expensive way is to use a thermographic camera. I do not have one at hand.

But an ongoing project uses thermochromic ink. That is an ink that becomes transparent once a temperature threshold is reached. It goes from a certain color to no color at all. So if you paint a piece of cloth and place it on a given surface you can do the measurement of temperature at each point.

The following pictures show the heating process of a certain aluminium heated bed. My sample cloth was not large enough to cover the whole bet but you get the idea.

 Heat sources start to show as whiter areas. 
 Now heat spreads a bit more.
 Reaching the temperature threshold at many points
For best results a glass on top would make sure the cloth is making contact with the whole surface evenly (top left corner was not having a good contact which explains the apparent colder temperature).

Dropcutter oddities

A while ago I decided to implement the drop-cutter algorithm as part of an ongoing software project. I found very interesting Anders Wallin website and his Opencamlib software. But the project I was working on was java-based.

Once I had a working implementation I realized that while most of the output made sense, there were a few odds points that were clearly wrong.

In a nutshell, the idea of drop-cutter algorithm is that it works by simulating a tool is being dropped till it touches the 3D model whose tool-path we are trying to obtain.  Using such a tool-path on a CNC machine equipped with the same tool, will render a geometrically accurate copy of the model.

The algorithm checks, for each XY tool location, which is the highest Z-axis value that causes a contact point between the tool tip and the object's 3D model. We use a triangular mesh for our models (STL files).  Three types of checks are performed:

Whether the tool tip touches a triangle's vertex.Whether the tool tip tou…

Hephestos 2 heated bed

Image
Since I got a beta version of Hephestos 2 from BQ before its launch, I have been using that printer more and more. After the initial annoyance about doing things on a certain way (like heating the extruder before performing a home move on an axis) I have got used to these details and I do not care anymore.

And with a few exceptions were a part bottom failed to stick to the bed (nothing that a bit of hairspray could not fix) the printer has been delivering consistently quality prints. Z-axis became a bit noisy on long moves but I have no other complaints.

However,  all the time I have been using PLA or Filaflex on a cold bed. There is no provision for a heated bed add-on so I had a look around for a stand-alone temperature controller.  I have found a simple pcb unit with display that controls a relay for a heating load up to 20A. Not sure how long that relay could last but for less than $5 I am going to give it a try.


Next the bed, I do like aluminium beds with power resistors epoxied …

SDR-Art

Image
I am working on an Art project that requires some radio-reception capability on a Raspberry Pi. I available online. But given the local nature of the data I need to treat this time I have to use a local receiver.
have used in the past some interesting website that feature an SDR device whose reception is

One suitable device I found very inexpensive are DVB-T USB dongles originally intended for watching Digital TV on a computer. These dongles can be had for less than $10 on eBay. The good thing is that the chipsets employed are Linux supported and there is a bunch of usefulsoftware that can use them as a Software Defined Radio (SDR).

What is SDR? Well, basically it can act as a multipurpose radio scanner for many different purposes as spectrum usage recorder, amateur radio receiver or just listening to FM radio or airplane ADS-B transponders. For that latter purpose there is a cool program called dump1090 that will receive and decode the messages of the airplanes' transponders rea…

4xiDraw: Another pen plotter

Image
After watching a video of a new pen plotter made by Evil Mad Scientist we wanted to have a similar device.



And having a 3D printer at hand plus some CAD software like Onshape or Fusion 360 it was a good exercise to design the whole thing.



As usual the process was not completely straightforward, as initially it was more about copying the model we saw but as things were coming together some new ideas were explored. So while the first mock-up was based entirely on laser-cut parts (some of them glued together to make them thicker as the crappy laser I have access to is really depth limited as it is low-power).  Why laser-cut? Well because it was faster (or so it was supposed, but don't get me started on that).


Once the first model was put together several ideas pop up: First, motors are in the way of carriage motion and reduce a bit carriage travel along smooth rods. Second, motors require another part that could be fused with the machine feet and rods support. Third, the initial belt…

Software I2C for Arduino

Image
While the Wire library allows you to get I2C working right off the bat with Arduino, there are times when the built-in Wire library does not do it. For some people this happens because they need to do a repeated start condition or to receive a large number of bytes, tasks that seemed to be not possible with Wire library. But for me the problem this time is a bit odd: I had to overcome the limitation of each I2C device to have a different address.

It turns out that I am using a magnetic encoder chip that responds to a given address that cannot be changed. Because I want to be able to access at least two similar encoders from on Arduino board I find myself in the unlikely situation where I have to use two different I2C buses, one per device. However, I2C interface was designed to do the exact opposite thing, allowing several devices to communicate over the same bus (provided each one had a different address of course).

As second detail I have been interested is to speed up the communica…

Crome 49 broke PDF viewing in Mavericks

A recent update of Chrome brought me some trouble with various web content, including PDF viewing. Apparently some change in how layers are handled makes the viewing of PDF content almost impossible: you see some bars of the underlying PDF file but only as a flicker while you scroll down the document, as if some black layer was on top of it.

A quick check online revealed that many people using OSX versions before El Capitan were complaing about exactly that same thing.  And while Google seemed not to be offering a solution at the moment (and upgrading to El Capitan was not something I would like to do right now) some users suggested that disabling hardware acceleration in the browser would help.

However, disabling hardware acceleration might solve this issue but create other problems with other content or just degrade browsing performance, so I did not want to go that way either.

Finally, another user suggested the install of a browser extension (in fact replacing Chrome's built-i…

A couple of ideas for right corners with 20x20 extrusions

Image
Some aluminium extrusions are quite convenient for building various types of structures. Manufacturers usually have a lot of choices when it comes to making unions. However, you not always have the time to wait for a part to be shipped to make a connection. Other times it can be done more cheaply and easily if you can use a drill.

For certain 20x20 profiles, I have used an M6 screw to make right angle joints. The inside hole of the extrusion needs to be tapped and an additional hole will help for tightening the screw with an allen tool:


Corner by misan on Sketchfab
Other times the profile is so tight that no screw can fit in the inside channel, so then this other approach can be used:


Corner2 by misan on Sketchfab
My original CAD had the screws with a distinct color but that was lost in translation :-(

If you clic on the images below you can have a look at the same model in Autodesk A360 Image viewer (unfortunately it only works for a month).


Testing another brushless motor

Image
For my closed-loop control project I considered brushless motors to be a superior choice but the lack of affordable models in the marketplace let me down a bit.

I was able to find some cheap models on eBay but those were lacking of built-in encoder and my attempt to add them one was a bit of a mess: the optical disk and sensor require better alignment that my poor skills could provide, so it ended up not being reliable. On the other hand, most DIY can get a small part 3D printed and my previous tests with magnetic encoders encourage me to use them more often. So I took some time to tinker with a motor from Nidec and how I could get an encoder attached in a simple way.

The end result is what you can see in the picture below, that just consist of a 3D printed part with three fingers that attach to the back of the motor's plastic cover notches.
You can see in the picture below the hole in the plastic box through which a small plastic part holds the magnet to the motor's shaft (a …

Windows 10: Upgrade if you can

Image
Since 2000 I am on a Windows-free diet. But that does not mean that I am totally ignoring Windows,
after all, it is what most people use. So I have a few computers still running XP, Windows 7 and Windows 8.1. Last week a couple of my laptops offer me the chance to upgrade to Windows 10.

A few weeks a friend bought himself a nice Bang & Olufsen laptop equipped with Windows 10. My friend is a long-time Windows sufferer and he seemed to be quite happy with the latest Windows version. So I decided to bite and try the upgrade by myself.

My first system was two years old Toshiba laptop with an i5 and 8 GB of RAM. I started the upgrade and everything went smoothly though terribly slow, the whole process taking perhaps ten hours (not sure exactly how long as I went to bed, bored of waiting. And I do not think download speed is to blame here as I have fast Internet connection at home (apparently a bit more than 2 GBytes are downloaded).

My second system was an older, low performance AMD-b…

Wifi DC motor controller?

Image
A few days ago I was talked on G+ by my friend Mauro Manco with an idea that was a bit weird at first: we all have heard about ESP8266 SoC that can bring Wifi happiness to out Arduino projects for a few dollars.

What Mauro suggested is that this same unit might handle the servo code I have written for an Arduino. That was in part possible by the release of an SDK that allow us to program it the same way as a regular Arduino, so code-wise, programs are compatible. In a few attempts Mauro managed to get my code to compile happily for the ESP.  But he wanted me to try it out so he was as kind as sending me a NodeMCU board to my home so I could give it a try.



It just arrived at noon and I could not resist to give it a try, as usual not without some minor problems. The first one was that the NodeMCU did not show up as a serial port in my Macbook. I tried installing the CH340 driver to no avail. After using a magnifying lenses I realised that the USB to serial adapter on my board it was rea…