Category: Electronics

Automating Development with Tools in MikroC PRO

By , October 25, 2011 8:02 pm
This is my tool to load the current source code file in NotePad++.

This is my tool to load the current source code file in NotePad++.

MikroElektronika's compiler MikroC PRO has a handy Tools feature that allows you to automate your development workflow. You can specify external programs and command line parameters that you want to run. You can launch these tools from either a button located in your toolbar or with a hotkey. The tools feature is useful if you want to work with a 3rd party chip programmer or bootloader, or if you want to load your current source code file in an external text editor.

I first researched the custom tools feature when I wanted to automate the process of developing my own programs for the MikroElektronika mikromedia dsPIC33 board. This saved me having to manually start up the ds30 loader program every time I wanted to use the bootloader to transfer the latest version of my firmware.

You can download the excellent bootloader software ds30 loader here:
http://mrmackey.no-ip.org/elektronik/ds30loader/

This is my MikroC tool to automate the process of loading a new HEX file onto a mikromedia board using the ds30 loader.

This is my MikroC tool to automate the process of loading a new HEX file onto a mikromedia board using the ds30 loader.

Continue reading 'Automating Development with Tools in MikroC PRO'»

Exploring the Mikromedia dsPIC33 Board and Gaming Shield

By , October 11, 2011 9:54 am

For the past few weeks I have had the opportunity to use MikroElektronika's latest Mikromedia dsPIC33 development board with the new Gaming Shield and Battery Boost Shield. The Mikromedia board is also known as the MikroMMB board. It features a color TFT screen that is touch sensitive and has a 320 x 240 resolution display. The board also has a built-in MP3 decoder chip (VLSI VS1011e) that makes playing sound from a Micro-SD card easy.

The Gaming Shield accessory provides a game pad with arcade style controls, and two integrated speakers for sound playback. The Battery Boost shield allows you to power the Mikromedia Board for hours using two AAA batteries.

My First Mikromedia Project - Mini-Sub Game

For my first project using a Mikromedia dsPIC33 board I created a video game called "Mini-Sub". The game was designed to work with the two button pads and the speakers on the new Mikromedia Gaming Shield. The game was created using MikroC Pro for dsPIC.

In the Mini-Sub game you have to navigate a yellow mini sub through a treacherous ocean filled with naval sea mines. Use the left button pad to control the submarine and the square button to fire torpedoes to clear your path.

It takes 1 torpedo hit to destroy a red sea mine and two torpedo hits to destroy a grey sea mine.

Mini-Sub version 2.1 adds animated rotating sea mine sprites, harder levels, more lives, bonus items, MP3 music playback, and all round improved coolness!

The Mini-Sub game is hosted on libstock.com

You can get the latest version from:
http://www.libstock.com/projects/view/154/mini-sub-game-demo

Here is the title screen for the Mini-Sub game running on a MikroMMB dsPIC33.

Here is the title screen for the Mini-Sub game running on a MikroMMB dsPIC33.

The Mini-Sub game is fast paced and loads of fun!

The Mini-Sub game is fast paced and loads of fun!

You can pickup different types of bonus items as you play the game.

You can pickup different types of bonus items as you play the game.

Your Mini-Sub can fire torpedoes to destroy the sea mines in your path.

Your Mini-Sub can fire torpedoes to destroy the sea mines in your path.

Continue reading 'Exploring the Mikromedia dsPIC33 Board and Gaming Shield'»

Analyzing RC Radio PPM Signals

By , August 25, 2011 12:17 pm
The 72MHz FM Hitec Optic 6 RC radio provides excellent long-range control for model airplanes and features a handy trainer port.

The 72MHz FM Hitec Optic 6 RC radio provides excellent long-range control for model airplanes and features a handy trainer port.

This photo shows the reverse side of a Hitec Optic 6 RC radio.

This photo shows the reverse side of a Hitec Optic 6 RC radio. The Hitec trainer port uses a round DIN connector to provide PPM output. The pinout for the trainer port is the same as Futaba's older DIN connector.

In this photo I am analyzing the PPM signals from a Hitec Optic 6 RC radio on a Rigol DS1052E digital oscilloscope.

In this photo I am analyzing the PPM signals from a Hitec Optic 6 RC radio on a Rigol DS1052E digital oscilloscope.

Most 72 MHz RC radios used with model airplanes output a PPM (Pulse-Position Modulation) signal from their trainer port. This is often used to allow another model airplane pilot to help you learn to fly your airplane or for interfacing your RC radio with a computer flight simulator.

When my Rigol oscilloscope arrived the first electrical signal my brother & I tested was a PPM signal. Watching a PPM signal update in real-time on an oscilloscope provides a much better understanding of how it works.

Knowing how a PPM signal works is important if you have an interest in trouble shooting problems with your electronics or if you want to build your own microcontroller powered robotic devices.

A PPM signal can come in one of  two formats; Negative Shift and Positive Shift. This defines whether the positive or negative part of the signal carries the PPM timing pulse. The duration of the pulse defines the analog servo position and the number of pulses defines how many channels of control are available. The average PPM radio signal updates at approximately 50 Hz (times per second). My Hitec Optic 6 RC radio updates at approximately 45 Hz and my Walkera radio updates at 54 Hz. Each PPM channel on my Hitec radio has a duration ranging from 0.67 ms(full left stick position) to 1.5 ms (full right stick position). The neutral stick position value is approximately 1 ms. The "flat notch" delay between each channel pulse is about 400 µs.

On my 6 channel Hitec RC radio after the last channel is output there is a blanking period of 10 to 12 ms before the next update.  On a 9 channel RC radio the blanking period would be shorter due to the addition of the extra channels. The Hitec radio trainer port outputs a PPM signal with a range of  9.5 to 10 Volts VPP depending on the internal battery level. The PPM signal output from the trainer port on my Walkera brand radio (included with the Twister Co-Axial RC Helicopter kit) was 4.8 Volts VPP when I measured it.

On my Hitec Optic 6 radio the throttle stick has 38 throttle detent positions with a spacing of 20 µs per notch. The smallest manual stick movement is approx 8 µs which equates to about 95 positions on the throttle / rudder / aileron channels. A single click of the trim button on my Hitec radio adds or subtracts 0.004 ms ( 4 µs) from the channel duration.

Here is an oscilloscope view of the output from my Hitec Optic 6 RC radio:

This  animation shows the changing PPM signal on a Hitec Optic 6 channel RC radio. In the animation I am wiggling the stick controlling channel 3 on the radio from full left to full right.

This animation shows the changing PPM signal on a Hitec Optic 6 channel RC radio. In the animation I am wiggling the stick controlling channel 3 on the radio from full left to full right.

Sample PPM Signal

Here I have zoomed in on the analog waveform of the PPM recording listed below using an audio editing program called Amadeus Pro.

Here I have zoomed in on the analog waveform of the PPM recording listed below using an audio editing program called Amadeus Pro.

If you want to hear what a raw PPM signal sounds like here is a sample MP3 recording of the waveform captured using the sound card on my desktop computer.

Note: The raw PPM sound is loud and fairly harsh on the ears.

Audio clip: Adobe Flash Player (version 9 or above) is required to play this audio clip. Download the latest version here. You also need to have JavaScript enabled in your browser.

You can also download the sample .MP3 recording of a PPM data stream. If you zoom in on the recording using an audio editing program you can view the individual PPM pulses.

 

Creating Music on a Stepper Motor

By , August 21, 2011 8:58 am

When I was developing an antenna tracker for my FPV flight project I noticed that it is possible to play back music on a stepper motor by energising the coils using a microcontroller + stepper motor controller along with the MikroC PWM1_Set_Duty library function. I kept one coil on the stepper motor permanently ON and then changed the PWM duty cycle on a 2nd coil to generate the sound. The patch antenna resonated due to the stepper motor vibrations and amplified the sound.

I used a program called Goldwave to convert a short clip of the MacGyver theme song to a low frequency integer audio file. I then used MikroElektronika's MikroC to compile a simple stepper motor controller program that energizes the coils to the tune of the music. I used a PIC18F4685 microcontroller to run the experiment.

The Story of Andrew’s UAV Ground Control Station

By , August 13, 2011 5:05 pm

Mission Control GCS Software

I have been working on an ambitious long-term hobby project of developing my own Mac OS X based UAV ground control station system. I have been tinkering away at it slowly since February 2008. I've done all the programming and my brother and I together have built a lot of the custom hardware and done the model airplane flying. The project is still very much in the "Alpha" stages and no source code or binaries are available to the public.

Gauges App Icon

I have learned so much over the last 3 years about model making, model aviation, electronics, programming, telemetry, networking, mapping, navigation, aerial photography, digital image processing, stereoscopic 3D imaging, meteorology, and many other topics. I have had a chance to experiment with all sorts of different hardware and software tools and equipment.

The main output from this project has been the ongoing improvement to my Mission Control program. Mission Control is a suite of modules that work together to form a low cost ground control station. The software runs on an Apple MacBook Pro laptop. The project started early on with a SDL based user interface and has evolved into a more robust Mac OS X based system with an Objective-C based user interface that uses Quartz Composer based gauges. Live telemetry data can be loaded into the Mission Control program from either a serial port connection, a video OCR engine, or via TCP or UDP protocols.

Mission Control Gauges

The Mission Control ground station gauges are run from a program appropriately called "Gauges". The gauge graphics are driven using Apple's node based Quartz Composer software. The gauges are updated based upon GPS data that is received either though a USB serial port interface using Termios or over a network TCP or UDP connection using BSD sockets.

This is the Gauges app using the horizontal display layout.

This is the Gauges app using the horizontal display layout.

This is the Gauges app using the vertical display layout.

This is the Gauges app using the vertical display layout.

Continue reading 'The Story of Andrew’s UAV Ground Control Station'»

mikromedia Gaming Shield Enclosure Community Design Concept

By , August 8, 2011 11:14 am
Here is the standard mikromedia Gaming Shield without an enclosure.

Here is the standard mikromedia Gaming Shield without an enclosure.

Last week MikroElektronika released a really cool product accessory called the mikromedia Gaming Shield that works with their existing MMB boards. This accessory is compatible with the PIC18FJ, DSPIC33 and AVR XMEGA mikromedia boards. The MMB boards can be easily programmed using either C code, Basic or Pascal using the MikroElektronika compilers. I have used MikroC since 2007 and have fallen in love with the speed that custom electronics projects can be completed thanks to the included software libraries that come with the compiler.

I think the gaming shield is a really innovative product for both electronics students and hobbyists. This means that electronics enthusiasts now have affordable bare metal access to embedded multimedia hardware. I can see people creating a lot of exciting interactive applications and games.

This week I was inspired to create my own 3D design concept for a mikromedia Gaming Shield enclosure. I used Autodesk Maya to model the design based upon reference images. I rendered the concept images using mental ray. The translucent case was created using a mental ray mia_material_x_passes surface material.

I am really happy that MikroElektronika mentioned my design concept on their news page. For future reference you can find the news article by looking for the date Aug 8, 2011!

When I get more accurate measurements I will update the design to add locking tabs, interior ribbing and bosses. Eventually I hope to create a prototype of the design using a 3D printer.

A Multi-Colour Lineup of MikroMedia Game Sheld Concept Cases

A Multi-Colour Lineup of MikroMedia Game Sheld Concept Cases

Low Angle View of a Multi-Colour Lineup of MikroMedia Game Sheld Concept Cases

Low Angle View of a Multi-Colour Lineup of MikroMedia Game Sheld Concept Cases

This is the Maya scene for my concept enclosure.

This is the Maya scene for my concept enclosure.

This is my concept design for a mikromedia Game Shield enclosure.

This is my concept design for a mikromedia Game Shield enclosure.

The idea for the enclosure was to have a transparent case so the electronics inside are visible to the user.

The idea for the enclosure was to have a transparent case so the electronics inside are visible to the user.

I wanted the controller buttons to have a retro classic console styling.

I wanted the controller buttons to have a retro classic console styling.

This is a rendering of the shell of the case without any electronics inside.

This is a rendering of the shell of the case without any electronics inside.

Here is a shot where you can see the back battery hatch for the case. The idea for the back hatch is that it snaps in place and is smooth with the back surface of the controller.

Here is a shot where you can see the back battery hatch for the case. The idea for the back hatch is that it snaps in place and is smooth with the back surface of the controller.

This is a view showing the openings on the side of the case for the mini-USB connector and audio jack.

This is a view showing the openings on the side of the case for the mini-USB connector and audio jack.