Tips & tricks

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.

0

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.

0

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).

0

Programming the Dwengo board without a programmer

Installing the bootloader

As of July 2010 the Dwengo board is equipped by default with a bootloader. If necessary, you can always reprogram the bootloader on the Dwengo board. 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.

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

Using variables larger than 256 bytes

Several applications require the use of variables larger than 256 bytes. For example, if you want to build a robot with a camera and process images, or add cool effects to an audio stream. But while the PIC18F4550 of the Dwengo Board contains 2048 bytes of data memory, the default linker script does not allow one to create variables larger than 256. This is fairly easy to fix though.

5

A proximity sensor insensitive to ambient light

Proximity sensors such as those described here work by emitting infrared (IR) light and measuring the amount of light that is reflected by an object in close proximity to the sensor. However, when other sources of IR light are in view (such as the sun), the sensor cannot know whether the light it is receiving actually comes from the IR LED in the sensor and has been reflected by an object, or whether it is just ambient light. This can cause the sensor to falsely believe that an object is close by, while in fact it just saw ambient light coming from the sun, an (incandescent) light bulb, or some other IR-light source (TL or fluoresent light bulbs usually don't emit enough IR light to pose this problem).

4.5
Syndicate content