Posts

Showing posts from December, 2009

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…

Happy New Year and other stuff

Image
This year has been an exciting one on the technology side but it is been a crappy year for most economies of the world. I keep my fingers crossed for a better 2010 on all fronts.
As you can see in the picture of the right, the Kindle DX has an annoying "feature" of showing the full media box of PDF files instead of the crop box. That means you have to recreate the PDF file if you want to get rid of these elements only useful for the print house. The problem they create is that some of the screen real state is wasted on them, making the rest of the page smaller.
My verdict about Kindle DX screen size is that it is too small for viewing A4 or US letter PDF documents comfortably but most PDF formatted books will be ok tough.
January issue of Circuit Cellar magazine will carry an article I authored. It is an Arduino-based project for a three axis stepper motor PC interface. Please note simultaneous use of several axis was not desired nor implemented. Popular stepper motor driving…

Hack-a-watch

Image
Latest development system for Texas Instruments "wireless" micro-controller comes in the form of a watch. Yes, a regular watch that can track several variables besides the time passing.
Besides the watch, the kit includes an USB RF interface and a USB emulator for software debugging. The watch itself includes a 3-axis accelerometer together with temperature, pressure and battery-level measurements.
At $49 it is a steal. No wonder they are out of stock. There is a wiki too.

Ultrasound ranging on Arduino

Image
I've recently bought a sonar circuit for distance and temperature measurements. Actually you need to know the temperature if you want to get an accurate distance measurement as it affects sound's propagation speed.

Less than $20 shipped, the URM37 unit is compact and full of interesting features: It has a dual interface as it can use RS-232 levels or TTL levels. Be careful because it defaults to RS-232 and these voltage levels can damage many 5V devices, including Arduino inputs.
It has several operating modes but I've used the serial interface. URM37 library comes with a modified software serial port library that allows you not to use any two available digital pins to interface with the sensor. This way arduino hardware serial port is free to be used for code uploading.
Another cool feature of the sensor is that it can control a RC servo so you can mount the sensor in a mobile platform to get the distance measurement at different angles.

Excellence in Teaching award

Image
I've been granted an Excellence in Teaching award from the local government. Among other things lecturing in English (or other foreign languages) and having high-marks on student surveys of teaching were topics assessed.

Now it is time to look around and thank all the people that made this possible: from my colleagues who share an interest on teaching to my students who keep on asking questions. From all of them I learn a lot every day.

I'm also grateful for my University and government that through various programs have supported different visits and stays at foreign universities.

And last, but not least, to my dear family and friends who have always been there for me.

For all of these I'm grateful.

Enable USB Networking on Kindle DX

The first thing is why in hell you may want to do this? Or even what the hell is this usb networking thing?

The thing is that those who are outside of coverage of Whispernet wireless network cannot get some of the Kindle features to work. But even if you enable usb networking you are not getting back 100% of the functionality. Let me tell you some of the things I've learned:

Apparently Amazon will send you a client digital certificate to your Kindle through Whispernet (and only that way), so future orders from you Kindle can be properly authenticated as yours (so you cannot refuse payment I guess, among other things). That means that even if you get your Kindle to access the Internet (ie enabling USB networking) you won't be able to register it to your account (though no error message is presented to the user).

So what USB networking can serve for? Well, enabling USB networking allows you to connect to the Kindle as a network device and to access its Linux system for doing change…

Got Kindle!

Though it's been one of the most difficult items to buy, I finally manage to get my Kindle DX. In a previous post I detailed the different failed attempts, but finally at the third one I've got my Kindle DX delivered.
Incidentally I discovered that my first buy from Amazon was stolen and being already used in USA. How did I learn that? Easier than you may think: When you buy a Kindle form Amazon (unless it is a gift for another person) it is registered automatically to you account. Next you can manage your Kindle from Amazon's website. One of the things you can do is to check the status of the documents that have been delivered through Whispernet and those that are still pending.
There is a default "Thank you letter" that is delivered to each customer. As Amazon sent me two Kindles (first shipment was lost, replacement shipment arrived) I had got two Kindles registered on my account. Each one had different email address and to my surprise I could see that that the…

Postgresql UTF-8 weirdness

I was recently moving data from a Postgresql version 8.0 database to a 8.4 on a new server. The database dump was made on a UTF-8 system and it was moved to another system using the same encoding. However I was getting some errors when trying to recover the data. Several encoding errors where poping out. A closer inspection revealed that those were indeed a few encoding-rule violations. For some odd reason some data fields ended up with bad data, some double-byte characters had the first byte missing (it was 0xc2 in my case).

I solved the problem creating a small filter program to add the missing byte of these characters from the database dump. Not very nice but it worked. Why the problem developed in the first place I do not know.


#include <stdio.h>

main() {
int a,c;
while((c=getchar())!= EOF)
{
if(c>0xe0) continue;
if(c>0xc0) {
a=getchar();
if(a>0x7f) putchar(c); putchar(a);
} else if(c<=0x7f) putchar(c);
}
return(0);
}