Posts

Security policy blues

Image
  When your company's security policy starts to make your life uncomfortable, some will say they are doing a good job, while others will complain. I would rather side with the latter.  I have been using a server accessible from the Internet for years. A few weeks ago, a message warned me to update the validity of the firewall rule. Unfortunately, that task appears to be above my pay grade. More unfortunate is that the people who that warning message told me specifically to talk to if I happened not to be able to fix it myself claim they cannot do that and that I should talk to somebody else. That pleased me not.  I am sure I could waste a couple of days going back and forth and get this fixed, but it would be helpful for a short time as I am retiring soon. Alternatively, I considered other more fun solutions that required me to talk with no one else. I have developed some sort of an allergy to people telling me, "That is not my job," when I request something.  If you...

Heating up a large print bed

Image
3D printers use a heated bed to promote the adhesion of molten filament to it. Many printers have a heater and a thermistor to heat up and measure the bed temperature. Some microcontroller code creates a closed-loop regulator that keeps the bed temperature around the desired set point. The question is what to do when you have a large bed. Some manufacturers have just gone bigger: a large bed is coupled with a large heater and a thermistor (or thermocouple is used for measuring the actual temperature of the bed). Others, like the Prusa XL print bed, have actually gone smaller and composed the larger bed as a set of smaller tiles, each with an independent temperature control. That approach is more complex and expensive in terms of control. Still, it comes with the added advantage of independent control of the temperatures of different bed zones, which might have power savings consequences. From where I stand, simpler and cheaper is the way to go with our project's budget. So, I settl...

Multiple heaters on a single extruder on Duet 3

Image
 For one of my recent projects, we built a pellet-extruder 3D printer. Its hotend has four different temperature sections. That means four heaters and four thermistors to create four independent temperature control loops. So far, all my printers have had a single heater for the hotend, so this was new to me.  Handling so many temperatures required enough thermistor inputs on the control board. In my case, a Duet 3 6HC board features precisely four temperature inputs. Which seems to be enough. However, I have a heated bed (which I will describe in an upcoming post) that also needs its temperature to be monitored, so I need five temperature inputs; I am one short so far. The solution was to buy an additional Duet Expansion 1HCL board. This one features two additional temperature inputs, two additional fan outputs, and an additional high-power motor driver I will not use now. This additional board connects to the 6HC using a CAN bus interface. Its default address is 123; you can ...

Setting up a 3D printer that does not use filament

Image
  So you have a 3D printer, and you want to configure your slicer so it can create g-code for it. The most obvious data is the size of your print envelope, but a less visited problem is how to deal with pellet printers or past-based extruders. Your printer for sure can respond to your commands, so after a while, you have a good understanding of how the amount of material needed to get your desired line width at a given layer height. That ratio would be the number of steps/mm the extruder needs to print the sort of lines that you need. Now you just need to tell your favorite slicer that. If you are like me, and your favorite slicer is PrusaSlicer, please be warned that a 1200 mm cube is its maximum print envelope (that was a no-go for one of my concrete printers).  On the other hand, Cura was happy with a larger volume (but I have not asked or tested their max volume). However, I was expecting the "filament diameter" in the extruder configuration in Cura to be the number I cou...

Apple, you ruined the upgrade experience, sort of.

Image
  Given that my previous cellphone renovation was a switch from Android to iPhone, I did not expect it to go smoothly, and it did not, primarily because of the WhatsApp database export. But this time, moving from one iPhone to a newer iPhone, I expected a smooth transition. The process started nicely; the new iPhone guided me through a process to find the old one and begin transferring data. However, at a given point, I was left with the latest iPhone stuck in the process (with a non-working link that prevented the import from finishing). To make things worse, the old iPhone was asking me if it was ok to delete all data and restore it to factory defaults (which I did not want to do before I was sure all my data was safely transferred and all my apps were working correctly on the new iPhone). I could only think that calling Apple was the only choice, and I am glad I did, as they helped me sort this out. However, all that ruins the experience of a smooth transition. Even worse, they ...

Controlling unconventional 3D printers

Image
I have been working on a couple of research projects lately involving the creation of a concrete 3D printer and a large-format plastic 3D printer using a pellet extruder. Both printers have in common that their electronics are built around Duet 3 controller boards, as they give you great flexibility.  That flexibility comes at a cost, as I must learn to configure the required features. Most of the time, I can find the info I need in their manuals or user forums. Occasionally, I ask a question there, too, and I always have a useful and quick answer.  My latest challenge was to get working a four heated sections hotend. I was using a Duet 3 6HC board on that machine that features four thermistor inputs, but given that a heated bed was already using one, I was missing one thermistor input. Eventually, I had to buy a 1HCL extension board that added one motor controller and two additional thermistor inputs to the base system it connects to with a CAN bus.  I thought I could u...

A new article featured in Circuit Cellar

Image
February 2024, #403 issue of Circuit Cellar magazine features an article I wrote about Raspberry Pi Pico Programmable I/O Programming. It is an elusive topic, opening up many choices to speed up communications with many different types of hardware. Writing the article was my excuse to devote myself to learning the subject, as I might end up using it for an upcoming wireless controller for a biaxial test machine I published last year. 

These are not the droids you are looking for ...

Image
  It has been a busy year, and one of the things I have played with the most has been a few of the new AI tools, like Bard, Dall-E, Copilot, etc.  The picture on the left is, allegedly, a Raspberry Pi Pico W, but it is not even close. But it serves to illustrate my point: while sometimes you get good or decent answers, sometimes AI is just wrong.  The problem is that we use computers to get good answers, and AI is being pushed as a great tool to speed up that process, which sometimes it does splendidly. Unfortunately, it cannot be trusted.  Still, during the second half of 2023, we witnessed how AI was touted as a revolution, and it was, to a point, one of the reasons for the bull market that raised many stocks. I guess that during 2024, we will continue exploring this tools, finding out which use cases make sense and where you want to avoid using them. Meanwhile, I convinced one of the image-generating AIs to make me a suitable image to celebrate the new year (it wa...

The new Arduino UNO R4 Wi-Fi

Image
It has been a while since my last post, but life gets in the way sometimes. The UNO form factor and the claim it was a 5V board made me pay more attention this time to this new board from Arduino. Having an ESP32 for Wi-Fi support was a nice touch, so while I did not make it as a beta tester, I shelled out some cash and got a commercial unit as soon as it was launched.  It is not only the built-in Wi-Fi but lots of other goodies, but you cannot but love the led matrix display <3 My first experience with the board was in an M1 Mac, which was completely trouble-free. The second test was with a Windows 10 machine, and the results were not good: I could not upload code to the board even though it was detected and the port was correctly set. I searched around and discovered this is a known issue . Bummer :-( That error happened using the new 2.1.0 IDE, so I returned to the older version installed on my computer, which was a no-go too. So I think that is all about it with Windows so f...

So, how is the iPhone 13 going?

 After three months of use, I feel more comfortable with the iPhone. I think I only rebooted twice, and it seems pretty stable. I have not performed a thorough battery test, but I bet I could get four days of battery life with my usage. Usually, when I recharge it at night, I am around 80% of battery life; I reckon the most used day it was around 66%. So on that front, it is a strong performer, much better than any of the Samsung Galaxy models I have owned over the years (not sure how good the latest models are though).  Handling is good though it feels larger and heavier than my older Galaxy S10e. It takes excellent pictures, even in low light. For compatibility reasons, I changed the default photo/video format to HPEG and MOV files, though I guess it is optimized using HEIC. I was surprised that fingerprint detection was replaced by Face ID biometrics. That works well most of the time, though it might add a bit of lag and needs you to have your phone looking at you (which ma...

Babysitting ChatGPT

 After my initial excitement with chatGPT, I have been trying to use it in the real world. I needed to plan a certain programming task and I was expecting to get it done quickly and easily with the help of AI, but the result has been quite different.  The first big problem is that code tends to get cut with no warning sign. You get a snippet of code where part of it is missing. Sometimes it is more evident than others and when you mention that in the chat, the machine goes back to produce another snippet that many times is cut again. Not so smart or efficient. The only workaround I have found digging in the OpenAI discourse forum is to report the last line of the output so the machine can continue with (hopefully) the rest of the code. That approach seems to work better as I guess the culprit is the limitation of the maximum length of the output code. But the next problem is the code generated did not work. Sometimes the reason was quite evident like they are trying to use a d...

From Android to iOS

 Against my better judgment, I am moving away from Android and into Apple claws. The fact that Samsung has consistently priced its Galaxy line above almost anyone else is not helping. Not an Apple hater here so I thought I could give the iPhone 13 a try.  I was not eager to make such a switch as I dreaded moving all the apps to another system and keeping my data in the process. My wife did a while ago and lost all the WhatsApp messages in the process no matter how hard we tried. Meta is mostly the one to blame in my opinion.  So how was the move?  In a nutshell, not good.  I installed the Android app made by Apple to ease the transition. I selected I wanted to move all my data and apps together with WhatsApp messages. The Android and iPhone told me it would take 41 minutes, later just 22 minutes, which lasted several hours. Oddly, the Android transfer seemed to keep working at a slow pace while it looked stuck to 22 minutes on the iPhone side. Frustrated I went ...

The future of programming

Image
I am following the Advent of Code 2022 programming event. I was about to say contest, but I wonder if that would be the correct name. Anyway, AoC presents different programming challenges to the users to be solved daily from December 1st to 25th.  The humorous problem statements and quite doable problems make it a fun programming experience that does not use much of your time. But what shocked me this year was that GPT-3 was being used to solve problems at lightning speed .  Once I opened an OpenAI account, I could try how good this thing is at solving programming exercises. I see the system is powerful enough to solve many programming quizzes I wrote for my students. It even handles them if written in Spanish.  And it is not only that you get some code as a result, but you can keep asking for refinements in case the first version does not have all the required features. Of course, to provide such a level of guidance, you need to be knowledgeable about programming, but n...

Learning new Java tools

Image
 While I have been using Java for almost 30 years, every now and then, I find new things I was not aware of in the Java toolset. Sometimes it is due to new libraries/classes; other times, it is brand-new tools.  I have been using Python lately, and I have found the use of an interpreter for testing code snippets very helpful. Unfortunately, that is not something you can do with Java, right? Well, that was the case till jshell was released. But what is jshell , let us say it is a Java's REPL. Like in Python, you can have an interactive session with the language interpreter, but now using Java.  How does it work? jshell is a command line tool you can find in OpenJDK or in Oracle's JDK since JDK 9 .  Not much different than Python, right? And you can ignore the semicolon at the end of each line :-) But it is more than just a calculator; you can instantiate any type of object, and it all persists in memory the whole session. It feels great to be able to have access to al...

Enforce line separator when using Scanner class in Java

Image
Parsing the data stream from a file or a socket can be very easy using the Scanner class. However, if you need to honor a given line separator sequence, using the nextLine() method can be problematic. The reason being the nextLine() method can accept a variety of line separators (like "\r\n", "\n", or "\r"). That behavior might be ok most of the time, but sometimes you may want to be sure that the line you are reading is precisely delimited by a given line separator and only by that one. The solution that works for me is not to use nextLine() but next()  after changing the token delimiter to the desired line separator. For example, I want to get a line read from the input delimited by "\r\n" only. ...  Scanner sc = new Scanner(s.getInputStream()).useDelimiter("\r\n");  String line = sc.next(); // before this was sc.nextLine(); ... Now full lines can be read as if they were a single token as now tokens are separated by the desired line s...

Replacing my MacBook Air

 My 2013 MacBook Air is still well and kicking, all but the battery is in good condition. I replaced the battery for a random one off Amazon and it was no good. Eventually the seller refunded my money after I reported the system would just cut off when the battery indicated around 55%. My guess is the power management was poor or the dialog with the laptop's control logic was not good so battery voltage and battery capacity were not interpreted properly. Whatever the reason, I was left with a computer that could be used only when battery was over 60% and that it can shut off anytime the number was below that. The old battery only lasted for less than one hour and I was not sure whether I would be any luckier buying another battery unless it came from Apple (which was pricier).  OTOH, that laptop had served me well for almost nine years and though it was a top of the line model (that was expensive at the time) with an i7, 8GB or RAM, and a 512GB SSD, I chose to look for a new m...

Set the time of Raspberry Pi Pico W using NTP

Image
 While the new RPi Pico W does not have a battery to keep the RTC, it does have something the previous model was lacking, network connectivity. So using the built-in Wifi module it can figure out the time and date from a network server using the Network Time Protocol (NTP).  It can work with it but the MicroPython binary I am using does not include a module for that at the moment (as the binary for ESP32 does) but it should not be a big deal to use that. As usual, it was easier to say than to do, but now I have it working. Please note that if you use the Thonny program, it will adjust the Pico real-time clock without warning you. So for a while, you may think it was your code that did it when it may well it is not the case. I just recycled some code I found but I was getting errors till I figured out the right offset for my board and timezone. You may need to tweak that to adjust it to yours. try: import usocket as socket except: import socket try: import ustruct...

Testing the ESP32-C3 ...

Image
  Having used the ESP32 using both Arduino IDE and MicroPython, I have been quite happy with it. However, I have found MicroPython more stable and powerful, especially if multithreading is needed. Do not get me wrong, you can get multiple tasks in FreeRT too, but it gets tricky quickly.  ESP32 features a dual-core 240 MHz Xtensa 32-bit processor, but the ESP32-C3 changes that to a single-core 160 MHz RISC-V processor. They both keep the handy Wifi and Bluetooth interfaces and a nice collection of built-in peripherals and communication interfaces (SPI, I2C, I2S).  What I did not know was the new architecture was also supported by Micropython , which was a nice surprise. So I went on and bought one of them to give it a go. The system feels a bit less powerful than its dual-core sibling but it works nicely with Micropython nonetheless. Having fewer I/O pins available can be a problem for certain applications but I definitely recommend this device if you need a wifi-enable...

Crimpers, crimpers, crimpers, ...

 I happen to have bought a few crimpers over the years. I understand how convenient is to have a trusty connection using a crimper, but I have had trouble shelling out the hefty sum a brand-new required. Being mostly a hobbyist I had a difficult time accepting paying hundreds of dollars for a glorified set of pliers that I would use to make less than fifty contacts a year.  However, whenever I have had a hint that an affordable tool could do a reasonable job within a budget I have bought a new crimper. Most of the time to get a disappointing result, or a poor one at best. I usually deal with 2.54 mm DuPont and Molex connectors so I have bought SN-28B (actually twice by mistake), TU-190-8, and another one I bought from RS. The one from RS almost did the trick for DuPont but it crushed the top metal too flat so I needed to use some pliers so I could squeeze it into the plastic part. The two jaws did leave a small space on the side so I reckon the crimp was good but the geometry ...

The trusty ImageMagick package

Image
  Seven years ago I made a simple script to turn a pile of scanned exams into a personalized email for each student to get their marked exams. I used our photocopy machine that doubles as a scanner to create a large PDF file containing all the exams. ImageMagick's convert, identify and mogrify commands were used within the script for several massaging of the scanned pages but, years later, using WSL instead of a Linux machine, I was shown a weird error. None of the commands seemed to be able to handle a PDF file as a source anymore: identify-im6.q16: attempt to perform an operation not allowed by the security policy `PDF' @ error/constitute.c/IsCoderAuthorized/408. Luckily, I quick search lead me to a solution: just edit /etc/ImageMagick-6/policy.xml and enable PDF use, which was disabled as a safety feature as PDF can be an attack vector. More info .