May 2007

You are currently browsing the monthly archive for May 2007.

Replacing the 16F1628 with a 16F88, that’s the next “main” step for the SirBot Project. One of the most interesting feature is the possibility to use a bootloader to self-program the chip. This prevents unplug/plug the chip from the board to the programmer, it’s way faster and, most importantly for me, this seems to be the only way to program my chips using a USB-to-serial converter, since my PIC01 programmer (as many JDM) can’t work with it . This is (IIRC my investigation) due to voltage differences: a programmer needs 12V, it can only have 5V from USB. Anyway, it can’t work and since my laptop doesn’t have any serial port, this is for me the only alternative (yes, I have a serial port on my desktop PC, but it’s not my main PC).

So, in this context, a bootloader must  be able to :

  • program my chips through the USB-to-serial converter
  • work under Linux (plaftorm independent)
  • easily integrate within the SirBot Project (if possible)
I first tried Bloader and its screamer. What I liked is the little program which blinks LEDs connected to any ports and send “Ok” through the serial link. This is helpful to ensure everything is ready. But… I couldn’t make it work using wine. I just got a “Error: type mismatch”, followed by the meaningful alert message: “13″. I tried different baudrates but always the same error.

I did not try further and switch to Tiny Bootloader. This bootloader seems to work fine with 16F88 and with Jal. More,a python script, pytbl, is available to use it: this is a great opportunity to use it within SirBot. So, let’s go… I’ve first flashed the 20MHz/115200bds hex file with my programmer. Using wine, I’m able to detect my 16F88 but… still unable to write the flash (“Could not write… Error…”). However, it works like a charm with a “real” serial port (%*$%%µ! converter). During my Bloader/Screamer exploration, it was mentioned that the baudrate configuration (9600, …, 115200) was useful when a usb-to-serial converter was involved… Heh ? Sounds interesting ! I thought: “if you took that asm file, modify it to use 20MHz xtal and 9600bds, compile the whole and put it in your 16F88, there will be a magical moment, for sure…”. And I did it… But no magical moment occured, still the same error. Ah, yes, I can remember the magical moment. It was when I compiled the asm file with MPLAB (crap, gpasm failed). It said “The file path [to the asm file] mustn’t be longer than 62 characters”…

Then I had the great idea: using VirtualBox, I’m able to run XP under Linux, attach my usb-to-serial converter, then launch TinyBootloader, then program my 16F88, then have my magical moment…

Now, what about pytbl ? It can detect the chip, but when it programs it (without errors), nothing is working anymore, even the bootloader… I’ve contacted the authort, so more on this later (I hope).

Last time, I’ve made a few test about a simple sound sensor (which I couldn’t make work, but I’m not giving up…). This time, it’s a bit more complex, since this sensor has a LM3916 dot/bar display driver:

  • at the beginning, there’s the same preamp electret mic LM386-based,
  • output is connected to the LM3916 (constructor’s schematics)

The idea is the following : this sound sensor will be used within the TweetyBot project, to detect when the birds sing loud (means “like a pig”) or soft (means “tweetering in the fresh air of the morning”). If they sing loud, the display driver will trigger high db LEDs. Using and/or gates (Master Fenyo said), I could connect the 10 LM3916 outputs to 4 input pins (2^3 < 10 < 2^4). It’s like an ADC, but levels are “steppized” (hum, I mean not continue…). Anyway, even without those considerations, the result is quite nice…


Just for the fun, this is one of my pretty birds, singing (almost) like a pig…

After determining which sound sensors should be used for the TweetyBot project, I’ve just tried to get a peak detectorworking. It should be easy to built it, but it’s not. After spending most of the sunday time on it, nothing is working…

This peak detector is quite simple:

  1. a LM386 acts as a preamp for the electret microphone
  2. a first part of a (hard-to-find and expensive) OPA2277-PA handles adjustment of the sensitivity
  3. another part of a (hard-to-find and expensive) OPA2277-PA handles comparisons and triggers the output level: 0V means “no sound”, +5V means “hey I got a sound”.

If I can get something from the LM386 output (tested with a multimeter and SirProbe), nothing from the OPA2277 output. I think this sensor must be build on a real board to avoid any contact failure, and tested with a real oscilloscope…

Yep ! I’ve just received a couple of PIC 16F88 microcontrollers. Hard to find (farnell), but finally got them.

16F88 is great compared to 16F628 because:

  • It has twice more memory (4K words)
  • It has a built-in ADC
  • and most importantly, its memory can be programmed through software, that is, it can handle a bootloader.

So I start to play. I launch the last version of ic-prog using wine, connect to my PIC01 programmer, and then try to program a bootloader (Tiny Bootloader), try to connect to it and flash a hex file… It fails. “PIC not found”… Errh ? OK, try again. Make sure the device is verified. OK. Make sure the device is correctly connected. OK. Try #2… Failed… Well, it seems starting by trying to use a bootloader isn’t what can be called a “Hello World” with this new PIC. I need the “blinking led” test. Got a program from a website. Program it. Test it. OK. It works, the LED is blinking. I then try to compile one of my own program (from SirBot). After fighting an hour to find the JAL libraries and compile the program, I try it. The PIC is supposed to echo chars, through the USART. Nothing… Nothing from the PIC…

Everythings work like a charm using a 16F628, so why not now ? Maybe because PICs are not the same :) I’ve read that “pins are compatible”, but it seems I’ve read it too fast. Looking at the specs, pins are not the same, starting by USART’s:

I should really read the specs. At least, look at the pictures…