Tips & tricks

Compiling on Linux using the Microchip C compiler

Getting your PIC code to compile in Linux used to be a hassle, but since the release of MPLAB-X, Microchip provides a fully functional Linux version of their C compiler. In this blog post, I'll walk you through it's installation so you can now easily compile Dwengo programs on the command-line.

5

Programming microcontrollers in Windows, Linux and OS X using MPLAB-X

The fact that Microchip is building MPLAB X External link, a platform independent programming environment for microcontrollers, is no longer a secret. The final version is not available yet, but the current beta version (Beta 7.12) is mature enough for daily use. In this blog post, we show how to use MPLAB X in combination with the Dwengo library and the Dwengo board. We will show you how to install MPLAB X and how to build your first project.

4

Reading out analog signals with the help of an ADC

With the Dwengo library you can easily read out analog sensors that are connected to channel AN0-AN4 without having to worry about all the technical details. On this page we go into more detail about how you can setup the build-in ADC module (Analog Digital Convertor) yourself and how you can use all the available ADC channels. On the PIC18F4550 there are up to 13 pins that can be used to read out analog sensors. The analog digital conversion has an accuracy of 10 bits.

5

Driving servos with the help of interrupts

Servos are electrical motors that depending on the steering signal move into a certain position. A servo typically has three connections: the negative voltage power, the positive voltage power (5 V) and the steering signal. The Dwengo board has two connectors servo1 and servo2 that allows to directly connect servos to it. On this page we explain in detail how the steering signal for a servo can be generated in an efficient way with the PIC18F4550. Dwengo provides a library dwengoServo.h that hides these details from the user.

5

Adjusting the speed of a motor with pulse-width modulation

All equipment working on direct current, also known as DC, require a constant input voltage. Within this category are many electronic components such as Lego™-motors and LEDs. The voltage of these components is typically within a certain range, but in general it can also be lowered. In the case of LEDs a lower voltage results in less light and by adjusting the input voltage of an electrical motor the rotational speed can be altered. The motor will then run slower or faster. The Dwengo library provides for this several useful functions. On this page we look into more detail how you can configure the PWM module of the PIC18F4550 yourself in order to easily adjust the speed of an electrical motor.

0

Creating and using your own push buttons

For many applications it comes in handy to connect push buttons to the microcontroller. The Dwengo board already has 5 push buttons connected to port B of the microcontroller. The Dwengo library provides several useful macros to use these buttons. In this page we explain how you can create extra push buttons and how to read them out.

0

Dynamically managing interrupts

An interrupt is an event on which the microcontroller reacts by temporarily interrupt the normal program execution and executes a special piece of code whereafter it resumes normal program execution. Such an event can be the finish of a hardware timer, the change of the voltage an a specific pin of the PIC, ... The specific piece of code is called an Interrupt Service Routine (ISR).

5

Programming the Dwengo board without a programmer

Installing the bootloader

Programming the bootloader on the Dwengo board can be done easily. For this you first download the hex file Dwengo bootloader that is attached to this page. This hex file contains the bootloader for the Dwengo board. With MPLAB you can program the Dwengo board with this hex file. The bootloader will now take the first 8192 bytes (0x0000 - 0x1FFF) of the program memory.

Writing a program

5

Serial communication

When you want to exchange data between the Dwengo board and a computer or another electrical component such as a compass or bluetooth chip, then the easiest way to do this is using the RS232 protocol. This protocol is also used by your computer when you connect a device to the serial port. The Dwengo library provides the necessary functionality to setup a serial connection. Here we provide more information on how you can setup such a connection yourself.

5

Using EEPROM to store data after power down

The data memory of the PIC18F4550 is volatile. This means that information stored in this memory is lost when the power is switched off. In many cases this is not a problem, but sometimes it's useful that certain data, e.g. configuration data, is saved even when the board is powered down. To this end, the PIC18F4550 contains 256 bytes of non-volatile EEPROM memory besides the volatile data memory. This memory can be used to store non-volatile information.

5
Syndicate content