Home CNC breadboard power adapter

One really nice thing about having a CNC to make PCBs at home is the ability to whip up a quick adapter board in one night. Tonight I needed two adapters for a 5.5mm barrel jack, one to go to wires and one that can plug into a breadboard. Eagle allows you to make a board without a schematic which is exactly what I needed, just draw some traces on copper and route it out on the CNC. I used 40-60 mil traces and slapped on random switches I had laying around and an LED with resistor. The boards came out to be about 1.75″x0.4″ and routed perfectly with a 0.8mm router bit. I uploaded a zip with the Eagle board files and G-Code for anyone else who wants them.

bb_jack.zip – Eagle files and G-Code

s1axter

Portable PIC development kit

Lately I’ve been moving between 3 different locations and have been trying to do contracting work related to PIC processors. It was really frustrating to have all my development tools and components only at my home office when I was away so much. The solution was to add what I needed to one portable kit to take from location to location. My first attempt was a small plastic toolbox, but that was quickly filled and always seemed to be a mess. Next I tried a plastic shoebox from home depot for $0.99. This worked well since I could see everything that was in it, however it was a pain to carry around since there was no handle and it didn’t fit into a bag nicely. The solution I came up with was a plastic parts bin with moveable seperator walls, like you can find a Harbor Freight or Home Depot. With the movable walls, you can really cram a lot of stuff into them, I was impressed with everything that I got into the bin.

  • 3 pencils
  • 1 pen
  • 6 DIP PIC micocontrollers
  • 1 DIP EEPROM
  • 1 character LCD
  • Double sided tape
  • Wire cutters
  • Spade cutters
  • Plyers
  • hobby knife
  • super glue
  • velcro squares
  • 23 row breadboard
  • Bus pirate
  • Bus pirate cable
  • Tweezers
  • 2 Antistatic bags
  • Electrical tape
  • Alligator clip wires
  • Jumper wires
  • 3×2 programming wire
  • Micro USB phone cable
  • A to B USB cable
  • Voltmeter
  • 5 PIC Microcontroller dev boards
  • 2 Prototype backboard
  • 1 9v packboard
  • 2 crystals
  • USB to serial adapter
  • Serial adapter cable
  • Serial adapter
  • 4G USB drive
  • Mini philips screwdriver
  • Mini flat blade screwdriver
  • Medium dual head screwdriver
  • PICkit3
  • 2 Mini USB cable
  • FTDI TTL serial cable
  • 4 port Mini USB hub
  • AC USB adapter
  • AC 12v adapter
  • USB to 5.5mm barrel jack connector
  • 9v battery to 5.5mm barrel jack
  • 2 Barrel jack breakout boards
Electrical parts

  • Jumper wire
  • Misc pots
  • Misc caps,
  • Buttons
  • LEDs
  • Misc resistors
  • Regulators
  • Header
  • N-chan FETs
  • Misc diodes
  • Solder
  • Barrel jacks

While the box does close and latch, I use two fabric hook and loop straps to make sure it stays closed.  The unit is really compact and fits in any backpack or side bag.  I do have a breadboard I take with me as well and I think I found a small plastic picture box that can hold that so I don’t crush components when it is in a bag.  Here are some pictures too

s1axter

MPLABX and XC16 on Xubuntu 13.10

Here’s what is needed to get Microchip XC16 and MPLABX running on Xubuntu 13.10

XC16:
sudo apt-get install lib32z1
tar xfv xc16-v1.21-linux-installer.run.tar
chmod 755 xc16-v1.21-linux-installer.run
sudo ./xc16-v1.21-linux-installer.run

MPLABX:
sudo apt-get install libc6:i386 libx11-6:i386 libxext6:i386 libstdc++6:i386 libexpat1:i386
sudo ./MPLABX-v2.20-linux-installer.sh

Linux idle time one-liner

I regularly need to see how much time an embedded Linux box is spending idle, so I can determine what impact performance improvement fixes have on the system over time.  Since ‘w’ is pretty much useless I use the following one-liner to parse the /proc/uptime

awk '{print ($2*100)/$1 " % idle over "$1/60 " min"}' /proc/uptime

User request video lesson

I like making videos and I like talking about / teaching embedded systems, so it should be no surprise there have been a few video tutorials on this site in the past.  I’m starting to get the bug again and want to post something that people working with embedded microcontrollers want, but I’m not totally sure what to show.  This lead to an opportunity, rather than try and guess what people want, I’m going to ask you the  people what you want to see! Here are the details:

  • Post a comment here telling me what you want to see in a tutorial video
  • My plan is to make a ~10 minute video about one or two topics
  • Topic areas include
    • Development tools (Logic analyzers, Rigol DS1052 Scope, PICKIT3, AVR Dragon, IDEs, Toolchains)
    • Microcontrollers (PIC16, PIC24F, ATMega, MSP430, STM32)
    • Processor peripherals (GPIO, Timers, ADC, Watchdog, PWM)
    • Bus protocols (SPI, I2C, CAN, RS232)
    • C programming (Modular programming, code reuse, basics through interrupts and threads)
    • Interfacing with devices (LCDs, buttons, keypads, EEPROM, accelerometers, etc)
    • Eagle PCB
    • Embedded Linux development (Raspberry Pi dev, Pi toolchain)
  • The video will be uploaded to youtube and posted here

Let me know about that thing you always wanted to know but never learned, I’ll make a video!

Compile using ffmpeg libraries

Tonight I wanted to play around with the ffmpeg API and see how complicated it was.  I downloaded the example decoding_encoding.c file and tried to compile it against a local build of ffmpeg I made based on their Ubuntu compiling tutorial.

Well let me tell you, ffmpeg sucks at getting people up to speed.  Yeah it’s great they have a few examples on how to use the API, but their makefile is dependent on pkg-config, so it is totally useless for a cross compilation, you would have to add the libs path to your build machine, which is dumb.  Not to mention the libraries they use in the example makefile are missing library references required for the example, leading to a TON of missing symbol errors!  Well after a bunch of searching I found one or two references to people who got the examples built which lead to the commands to build the damn thing on my machine.  This post is for everyone wanting to get started with the ffmpeg API and so I don’t loose it!  Enjoy :-)

The -I and -L paths should be to your ffmpeg build, mine was obviously /home/s1axter/projects/ffmpeg_sources/ffmpeg_build/

gcc -Wall -I/home/s1axter/projects/ffmpeg_sources/ffmpeg_build/include -c -o decoding_encoding.o decoding_encoding.c

gcc -Wall -L/home/s1axter/projects/ffmpeg_sources/ffmpeg_build/lib -L/usr/lib/i386-linux-gnu -o decoding_encoding decoding_encoding.o -lavformat -lavcodec -lswscale -lavdevice -lavfilter -lfdk-aac -lpostproc -lswresample -lx264 -lavutil -lvpx -lvorbisenc -lvorbis -lmp3lame -ltheora -ltheoraenc -ltheoradec -lva -ldl -lz -pthread -lm

And a Makefile: ffmpeg makefile

Raspberry Pi – Cross Compile & Kernel

This is the first post in a series on getting down into the bits of a Raspberry Pi Linux installation. It assumes familiarity with the Linux build process, gcc, make, apt-get, ssh, etc.

Lately I have been thinking about a project that would require a beefy embedded system, one with embedded Linux, fast, and lots of storage.  It turns out the RaspberryPi has all the requirements for this project, and I have one laying around, so I figured I would pull it out and get a full development toolchain started to see what the little Pi could do. This project might require a Linux driver module, so for that I need to compile the kernel and modules too. All steps were done on an Xubuntu 12.10 32-bit machine with the Ubuntu GCC/binutils/make packages installed.

Image

The first step was getting an image running.  I tried a few and the Arch Linux image is prefect for an embedded project, it doesn’t contain all the X crap by default, it boots  in ~10 seconds (thanks to systemd) and the stock image only takes up about 450Mb on a flash drive, leaving lots of space.  Here is the image (I used the version from Nov 2013), here is how to make an SD card.

Toolchain

The next step was to get a cross compiler toolchain build.  I have seen a lot of posts that say “do an apt-get install gcc-arm-linux-xxxxx on Debian”, that’s all well and good if like relying on Debian, I would like full control over my toolchain, and I don’t want to have to export tons of bash variables for tool locations.  Fortunately, there is an awesome application called crosstool-ng that makes downloading and building a custom compiler and tools a breeze.  I followed this post successfully and put the output directory of the cross compiler binaries within my home directory, this way the ARM compiler isn’t system wide and I can move it where I want it.  I did have to install some packages “sudo apt-get install gperf texinfo gawk libtool automake libncurses5-dev”. The test application compiled without issue and a quick SSH got me “Hello world” on the Pi command line.

Kernel

Rebuilding the kernel and modules seemed a little daunting, but actually it’s pretty easy once you do it. These two references (PDF and elinux) were good for understanding the process.  The kernel for the Raspberry Pi is build from a central git repo, so you just need to clone the repo and you have the whole kernel source all patched and ready to go.

The Arch Linux build has a handy feature enabled, it outputs the kernel config for the running kernel in the /proc directory, which means if you use this config as the base for your config, all the settings match the current kernel, which you know works. Copy the file /proc/config.gz from your Pi, uncompress it to ‘.config’ in the root of your kernel source and it will be read by menuconfig, can’t get easier than that!

Now, because I compiled the toolchain into a local home directory I need to pass the path to it for each call to make.  This isn’t that bad because I plan on making scripts that build the kernel and modules whenever I need them.  Here is an example of how to run menuconfig and the final make:

make ARCH=arm CROSS_COMPILE=/home/s1axter/raspi/toolchain/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi- menuconfig
make ARCH=arm CROSS_COMPILE=/home/s1axter/raspi/toolchain/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-

The kernel make builds both the kernel and the modules for that version of the kernel.  You have to copy over both the new kernel and the kernel modules since you can’t use the old modules that exist on the Pi.  Again, rather than export a bash variable like the elinux source says I pass the module folder path in the make command.

make modules_install ARCH=arm CROSS_COMPILE=/home/s1axter/raspi/toolchain/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi- INSTALL_MOD_PATH=/home/s1axter/raspi/kernel/modules

After these build steps use sftp or some other means to get the modules and firmware directories in the ‘modules/lib/’ folder into the ‘/lib’ folder on the Pi. The kernel new image is ‘arch/arm/boot/Image’  from the kernel source folder and needs to replace /boot/kernel.img on the Pi (Make a backup, just incase).  I used scp/sftp, so I logged into the Pi and did a ‘sync‘ command to make sure everything was written to the SD card and then ‘reboot’.  I might have been lucky but the Pi came back up and my kernel went from 3.10.18 to 3.10.25!

Good luck

 

GoPro timelapse ffmpeg

So I got a GoPro this Christmas for skiing.  Yesterday I took some footage on the mountain, including some time lapse shots which I wanted to stitch together to make a sped-up video.  I’ve used ffmpeg a bunch, so I knew it could do the job.  There isn’t much to making a movie from the images, and the following command works pretty good.  The only tricky part was the GoPro doesn’t start all timelapses at G0020001.JPG, mine was at G0020069.JPG. The timelapse setting was one picture every 0.5 sec and the output is 10 fps.  The GoPro still are also 4000×3000, so I convert them to 1920×1080 to match the video frame size, this adds a little distortion but still looks pretty good.

ffmpeg.exe -f image2 -r 10 -start_number 69 -i G002%04d.JPG -vcodec libx264 -pix_fmt yuvj420p -s 1920×1080 out.mp4

The 10 fps had some weird conflicts with my editor, so 29.97 fps might work better.

C Preprocessor Macro Demo Video

Here is a demo video on using C Preprocessor macros to make your code easier to read and write.

As promised, here is the code in the demo program

And don’t forget to check out the original articles

http://www.mybitbox.com/2012/11/robust-c-code-part-1-c-preprocessor/
http://www.mybitbox.com/2012/12/robust-c-code-part-2-advanced-c-preprecessor/
http://www.mybitbox.com/2012/12/robust-c-code-part-3-wrapping-c/

S1axter

Gerbmerge issues on Ubuntu 12.10

Gerbmerge is used to panelize multiple PCB gerber files into one gerber.  This allows you to submit one “board” that has multiple copies on it.  Note, gerbmerge was developed for Eagle PCB generated gerber files

Installing gerbmerge on Ubuntu 12.10 (Actually Xubuntu 12.10, but things should be the same with regular Ubuntu) didn’t work right out of the box, here is what needs to be modified:

Edit setup.py from gerbmerge 1.8 source: Change line 40:

From: DestLib = distutils.sysconfig.get_config_var(‘LIBPYTHON’)
To: DestLib = distutils.sysconfig.get_python_lib()

Run sudo python setup.py install

Check the ‘installed_file’ file and see where gerbmerge was installed, mine was “/usr/local/lib/python2.7/dist-packages/gerbmerge/gerbmerge.py”

Edit /usr/bin/gerbmerge to point to this location. The “installed_files” file will also tell you where the testdata was installed.

Source: Installing on a Mac: http://karplus4arduino.wordpress.com/tag/gerbmerge/

WordPress Themes