Posts

Showing posts from June, 2008

Moving code from ESP8266 to ESP32

Image
A while ago I made a mashup of Dan Royer's code CNC 2 Axis Demo with my own code for trapezoidal motion stepper and servo control for ESP8266.

I assumed porting the code to the ESP32 would be trivial, and that was true for the most part: changes like library name being Wifi.h instead of Wifi8266.h were not a problem. UDP now does not like multicharacter writes but you can use print instead. So far so good.

However, when it came to the interrupt code I was stuck with the stepper interrupt causing an exception sometimes. And to make things weirder, the servo interrupt worked flawlessly (both of them had the IRAM_ATTR directive if you ask me).

Going little by little, I could narrow down the culprit to a floating point operation during the interrupt, that would cause problems sometimes but not always. Browsing around I found this post. Where the solution was simple: do not use floats within the interrupt routines but doubles. The reason was the float calculation would be performed by…

Shopping list problem

Image
Definitely this has been the most challenging problem I've found on the Code Jam practice site. It asks you to determine the optimal selection of what to buy where. With a couple of twists: the cost of going from one place to another is factored in; plus a rule that forces you to drive back home whenever you're buying perishable goods.

The approach that worked for me was to first consider the different combinations of articles from different shops, just to obtain the list of shops to visit for each instance. Each one of list of shops to visit is a traveling salesman problem (perishable rule just changes the cost of some of the links).

Combine both costs, the article's prices at selected shops and the transportation costs to determine how much each realization will amount. The minimum case is the answer you're looking for.

The main problem I faced with the large set is that unless the code is quite efficient (and mine was not) it will take a long long time to finish the ca…

Google Code Jam '08

Image
I've just got a notice about the new edition of Google Code Jam. I guess if you like challenges it is a place to go. I've spent part of the evening solving the "Alien Numbers" problem just to discover how rusted I am. It was fun though, and it was satisfying to make it right (though not very fast I would say).

Single data packet TCP

Image
For Ethernet enabled devices I've used in the past (and I was happy with) the cores from Rabbit Semiconductor. They offer a lot of data and program memory and a royalty-free TCP/IP stack.

Not in the same league but still surprisingly useful is the Ethernet shield I've bought from Nuelectronics (a UK-based company). The shield plugs-in nicely on an Arduino board and it can easily allow you to create a simple network appliance.

In the picture I have my sample system that using a DS18B20 digital temperature sensor offers the temperature reading as a web page.

All the code used is the sample code and TCP/IP library provided by Nuelectronics. I had some minor trouble with my setup as I am using the so-called parasitic power on the temperature sensor and a few lines of code where added to the original code to make it work. The symptom of the problem is that I was getting +85.00 C no matter what the temperature was. The cause was that the sensor did not get enough power from the 1-wir…

Kudos to Canon

Image
I dumped my old Epson color printer, an Epson Stylus Photo Color 830, after playing any trick to get a decent printing performance for quite a while (I failed). As we needed a new printer at home I searched and browsed around and I settled with Canon's IP4300 that also had good Linux support.

Unfortunately that model was no longer available (I learned this at the computer shop) so it was not an option. I guessed the next model, Canon's IP4500 won't be that different. It was cool as it could do duplex printing automatically.

I was wrong: While the printer worked like a charm ("New" is the best printer brand!) I was disappointed to discover there was not Linux driver. And when I tried the IP4300's driver it did not work at all.

Time to go to the Ubuntu forums: There I was referred to a Canon's portal. In there I downloaded and install a couple of .deb files and next I restarted cups. I connected the printer's USB cable to my computer and it was automagical…

Another format for arduino

Image
I've just bought another arduino board for a project. My main complaint with arduino standard board is that it is not prototype board friendly. I am afraid this was a 'feature' and not an error: This way people would have to buy special prototype boards for arduino. This was a design error that later on has survived to maintain compatibility with existing shields (thanks for shedding some light on this, David)

There are other solutions like Modern Device BBB, but the new iDuino does include the USB adapter that may power and interface to a PC your project. And iDuino kit costs less than $18 so it seems quite cost effective. The main con is that the kit includes a resonator instead of crystal.

I haven't used it yet but it seems another development to have a look at. If you plan to buy one I think you better use Fundamental Logic website instead of eBay.