Fighting with computers

Computers are not always friendly.

Thursday, September 04, 2014


Today, after a long wait, I made my mind to shopping for a brand-new MacBook Air. I went to the Apple store in my city before the summer but I did not like what I was told: They will make me a nice discount for being a university professor but only if I was billed personally. I wanted the machine to be invoiced to my university that would slash the discount seriously. It did not matter that my university was a leading public university in the country. I left the shop shocked and empty handed.

After checking with some colleagues it seems that is Apple's usual policy, though nobody was able to explain why. Anyway, after doing some taxes math I saw it was still more convenient for me to charge the bill to my personal expenses account I hold with my employer so I went for it.

These is more or less my experience today at the Apple Store in Valencia.

Apple rep1 (at the door): How can we help you today Sir?
Me: I would like to buy a MacBook Air.
Apple rep1: Do you have it reserved?
Me: No, I don't. But I do know the model I want. Do you mean I need to make a reservation for a unit?
Apple rep1: No Sir. I did not say you need to book a unit in advance.
Me: I just heard you asking me if I have it reserved ... (odd awkward moment)

Apple rep1: Please come with me so my colleague will handle your order. (We are guided to the MacBook Pro 15" area and we are told to wait there for the representative that will help us next, and so we do).

Apple rep2: (After asking as our names) What can I do for you?
Me: I want to bay an i7 MacBook Air with 8GB of RAM and 512 GB of storage. I want the order to be invoiced to my [employer who is a local] university.
Apple rep2: We'll let me check if we can do that, as the university counter should come here for such an order with the tax number.
(After a while he is back and confirms we can proceed) But now the discount will be much lower than if you were buying the unit personally.
Me: I acknowledge that but insist I want the invoice to be to the name of my university:
Apple rep2: Unfortunately my colleagues that handle business accounts are already off and I am afraid I won't be able to get your university taxes number. Do you have it by any chance?
Me: Of course I have it, it is ******.
Apple rep2: Ah, ok then. Please give company name and address. Would you pay credit card or cash?
Me: I would pay credit card.
Apple rep2: Ok, hold down and I'll be right back.
... one minute or two later ...
Apple rep3: Congratulations on your new MacBook Air. Now my colleague will proceed with the billing.
(Some conversation about the university takes place now, as Apple rep2 is a graduate from my university but I do not think that is relevant to this post).
Apple rep3: These are the details of the transaction (and repeats all my company data). Is that ok?
(he has been frantically using the inch-thick iphone-based device they use as a terminal for a while and eventually produces a ticket which hands over to me).
Me: What is the invoice number? (nothing like invoice number text appears on the ticket).
Apple rep2: (pointing at a barcode) That is it.
Me: Ok thank you very much.
Apple rep2: Would you like to configure your new laptop in the shop?
Me: No, thanks, I will do that at home.
We both say good-bye and I leave the shop with my laptop in a bag.

I really did not like the feeling in the shop. It felt like unless you make clear you know nothing about computers and they do not know how to handle you. I do own several Apple computers I have bought over the years though I am not an Apple fanboy. I think next time I am buying an Apple computer I will buy it online as half of my interactions with the shop representatives were kind of telling me that buying might not be possible at all. I am not asking for pushy salesman but a bit of a profesional salesman would help, even if they are not in their twenties but know the ropes.

As for the Air, what can I say? It is a light but powerful beautiful machine.

Friday, August 15, 2014

Reading binary STL files in Java

I liked the source code from MaskedRetriever user on github and I assumed it would work ok. It seems it was an attempt to create a self-contained tool for 3D printing but somehow it was left at an early stage. But I liked the fact that source code was documented.

My needs were to read STL files and to slice them. As usual you need to get familiar with the different classes involved but it took me not much to get it going. I stripped most of the classes as I was not interested on 3D printing nor on having a GUI for such a tool. However, as soon as I draw the output of the slice process I noticed something was wrong.

While the proper slice looked smooth like the image below:

What I was obtaining was a bit of a mess, though the general ideal was correct. As it was my first attempt I was not sure where the error might be.
After a few tests I realized that the same code would work ok if STL file was ASCII-based but it will fail as above if a binary STL was used instead. 

I had a look at the code and I could see reading a binary STL file involved obtaining float values out of 32-bit IEEE 754 encoded values on the file. It seemed it was there when error was made in the conversion.

Googling around I realized there was a library function in Float class called intBitsToFloat that will turn the 32 bit number into the proper float value. I only needed to get that 32 bit number out of the four bytes read from the file, easy peasy ... or not?

Well, if that were C, and you have b[0..3] unsigned chars, the expression could be something like 
 b[3]<<24 | b[2]<<16 | b[1]<<8 | b[0]  

However Java language considers byte data-type as a signed 8-bit field (-128 to 127). And there is a nasty effect with the sign extension that may make you waste a fair amount of time. In summary, the C version won't work if negative values are involved, and they are most of the time (half of the time I would say). So one way of obtaining the proper 32 bit number in Java would be a bit longer : 

 (b[3]<<24)&0xff000000 | (b[2]<<16)&0xff0000 | (b[1]<<8)&0xff00 | b[0]&0xff  

Tuesday, August 05, 2014

More on delta 3D printers

It's been quite busy around here lately. Still, I have managed to build a couple of delta 3D printers with heated beds and develop a couple of ideas that seemed worth trying.

One of these ideas is the use of a heated bed. While I can see that some people are moving away from ABS to use just PLA plastic, I do not see how I can use a PLA-only solutions for environments where temperature can be high, like inside of a car or near a hotend or heated bed.

Two different types of extrusions and carriages were tested: wheeled carriages over the extrusion resulted in a quieter and more accurate system than rails. But the IGUS guides used had quite play by design. After watching the videos of them working I am not sure they are a good choice for this particular use, though printed parts do not look bad after all.

While Johan pioneered the use of force sensing resistors on the bed for probe-less bed detection, I was not pleased with the additional cost these FSR sensors would add, so I turned to the same idea Brook did with the metal Printrbot Simple: the use of inductive proximity detectors (as I am using aluminum heated beds). As I wanted to add the sensor to the effector and to use magnetic couplings instead of Traxxas ball joints, I designed a few new parts.

I am very happy with these plastic parts for creating a Kossel Mini using 2020 extrusions. And the guys from Mecaduino provided me a set of parts for making a Kossel Mini using their metal parts (however I did print some plastic parts to use magnetic coupling and inductive proximity probe with it too.

With the magnetic couplings, with I liked more than ball joints, as they have zero slop, if you set the acceleration too high (in my case higher than 1500mm/s^2) the rods will fall apart on any fast movement, that will never happen with a ball joint. I am using 10mm steel balls and 6mm-diameter 8mm-long N35 magnets. I guess stronger magnets will allow you higher effective accelerations.

The second innovation I have been testing is the auto-calibration firmware I mentioned in a previous post by Rich Catell. While the first time I used in a 3DR printer with a mechanical switch the firmware converged quickly, these two other printers gave me hell and did not converge to a valid calibration all the time. Maybe part of the problem was due to not so accurate build of these deltas but another reason could be associated with the way measurements are performed. Once I switched to the median filter code by Brad Hopper the results of auto-calibration improved notably on both printers. 

Now it seems I am getting good prints from both printers and start to feel a bit more confident about this type of printer, so I guess I am venturing in a new type quite soon: Ingentis/Eustathios are next.

Sunday, May 11, 2014

Mobile data services for Japan visitors

On the occasion of a trip to Japan, I had to look for a way to stay connected while on the go. Though most hotels will offer free wifi to guests, having an Internet connection while trying to navigate the city is most welcome. And if you are to believe the claim, Tokyo is the most populated city of the world. It certainly has an impressive public transportation system with many different companies just for the light trains and underground systems.

Google Maps seems to be properly in synch with local companies schedules and provided accurate results on how to go from point A to point B within the city. But to be able to use it you need Internet mobile access. And this is where Japan seems a bit odd for the visitor: It seems you cannot buy a prepaid voice or data SIM card unless you are Japanese. Maybe I am missing something here but that was what I learned from my online search.

One notable exception seems to be B-mobile VISITOR SIM, which offered pre-paid data service SIM card.

Fortunately, what you cannot buy, you can rent. So there are a handful of companies that can rent you a SIM card provided you are carrying an unlocked phone. Or else you can rent a phone too, this way you are certain the phone is going to play nice with the SIM card. But what surprised me the most was the availability of mobile wifi hot-stops, that will get their Internet from 4G or WiMAX networks and will offer wifi connectivity to all the devices within a few meters of the unit. This mobile hotspot is similar size of a cellphone and with a battery that will last for a few hours of operation.

In the end, we were lucky because the Japanese hospitality of our friends provided us both, a voice SIM card and a mobile wifi/WiMAX device for free. That meant the whole family was able to be online all the time using the wifi hotspot. I totally can recommend this type of service even if you have to pay for it as it worked nicely not only in the cities but also in our Shinkansen rides.

Finally, another service worth mentioning are public wifi networks. The one I used was Wi2, that offered one day of free wifi for VISA card holders. I used the free service to log on the Internet on arrival during our ride on the Narita Express train that connects the airport with the city.  It may not work everywhere but it worked for us and it did not cost us a dime.

Saturday, March 29, 2014

Viewing g-code files in Linux and OSX

Working with CNC machines and 3D printers and developing CAM software myself I need a tool to quickly display the 3D view of any g-code file generated. For a while I have been using EMC2 software on Linux and Pleasant3D in OSX. The former was a bit picky about certain commands that were not understood that would prevent the displaying of a file completely. The latter is ok, but being oriented to 3D printers, it is not very convenient when handling files of several square feet. It works but your viewing ability and angles are a bit limited.

After a bit of searching and playing with several potential candidates I have settled with version 0.2.3 of OpenSCAM that I had used in the past on Windows but somehow was not available at the time for OSX or Linux (or I was lazy enough not to try to compile it from the sources myself). Current version worked nicely in OSX and gave me some minor problems in Ubuntu Linux, that could be solved by installing libv8-dev library and doing a soft link. And I really liked the software provides a machining-time estimate, which is great when you are developing different CAM strategies and want to compare them time-wise. 

Other tools I tried but were not up to the task were tatlin, this Python-based viewer and this online tool. Don't get me wrong these tools are ok but have a 3D printer orientation so they are a bit out of the water if fed with other type of g-code. 

Thursday, March 27, 2014

Delta 3D printers

Since the presentation of the Rostock 3D printer, I have been amazed on the kind of motion that these machines make to print a part. While I have found quite hypnotic the way layers are deposited to create plastic part using fused filament fabrication, when the process is done by a delta robot instead of by a cartesian robot, the show is even more interesting.

However the Rostock was a big machine, not compatible with the space I have available at home. But when I saw Richard's 3DR printers, I thought it was a good way for me to venture into the interesting world of this type of printers. Contrary to the Rostock, the 3DR had a small footprint so I built one. But that was just part of the challenge.

Delta 3D printers use three vertical parallel carriages linked by a set of rods to a central platform where the hotend is placed. But contrary to some other printers, those vertical axis are not screw-driven but belt-driven, which allows very fast motion. As a result, Delta 3D printers can move the low-inertia effector very fast accurately. Besides, z-axis speed is no longer restricted compared to the other axis speeds, which enables operations like raising the hotend in z-axis when retracting (before a non-extruding movement).

The second part of the challenge is properly calibrating the printer. A bit more difficult that its equivalent on a cartesian bot. But this is an interesting world where smart people are creating cool innovations on a daily basis. A new feature to auto bed-leveling permits not to have to worry about bed-leveling when using a delta. This make its operation simpler but requires to have a way to detect when the head is touching the bed. Several ways have been developed to do that, like a dedicated retractable switch, proximity switches or even force sensitive resistors on the bed. But the most radical idea was to use the printer to probe itself in order to create its own calibration data.  Just run "G30 A" command and wait your printer to create its own calibration values.


Tuesday, March 11, 2014

Of pumps and stepper motors

I have been quite busy lately due to several factors. One of them things not working out as expected. Of course every failure is a learning opportunity and this case, my chance to get familiar with the world of hydraulics and fluid dynamics. As a Computer Scientist, you do not get any training on that matter (other than maybe learning about fans for cooling down electronic parts).

I have been working for more than a year on a project where the least I was expecting was to have trouble with what it is eating a lot of my time lately: pushing a viscous fluid in a precise, controlled-way, from a container to the printing area of a 3D-printer we have designed and successfully built as part of our research project.

If you are familiar with 3D printing, you can think of us trying to create a reliable paste extruder. There are many open paste extruder designs out there, but many are designed for not so viscous pastes or liquids. Others can handle viscous fluids but only a very small amount of it (ie. syringe-based ones). And one effect I have learned is the more viscous the fluid the less likely is to move through a narrow tube. And every inch of tube will increase the need of output pressure in your pump.

Another thing I have learned is that pressurized tubes and 3D printed parts are not a good match, so it is difficult to create your own pump. Or more exactly, it is difficult to achieve a good performance level (ie pressure) with your 3D printed parts.

So I kind of gave up and looked around for pump manufacturers, but those that have small pumps could not work with the viscosity levels I needed. After getting some help from an hydraulics professor, the nice people from Food Technology department came to the rescue and lend us a mono pump that worked great with our material. The only problem being that the pump was powered by a 1CV AC motor driven by a variable frequency drive (VFD) to allow the user select different speeds.

But what we needed was a pump that can start and stop on a dime and that we can precisely control the material flow. That is was not possible with the setup of our pump. So our next step is to replace that motor with an stepper motor we can control.

In the previous blog entry I was visiting a company in Rome helping them out to put to work their home-built CNC machine. They have used powerful nema34 motors.

I thought I could use similar steppers, reaching up to 12.5 Nm of torque, to move a mono pump. The only current problem is that we run out of funds. So I am now in the process of piecing together the paperwork for a funding round to see if we can put the thing together and finally finish our research project successfully.

Till then, most of what I can show does not look pretty: