PIC18LF2550 Wireless 3-axis Accelerometer

Having a 2.4GHz Serial Link is helpful, but what kind of applications could it be utilized for? Well, I had a number of 1-axis accelerometers from Freescale (graciously provided by their samples department for my electronics lab projects), which I could use detect object orientation. Making the accelerometers wireless would allow for remote sensing of object orientation, which could be applied to virtual reality or possibly augmented cognition. In any case, it allows for some fun experimentation!

Transmitter Circuit

The source and firmware for the transmitter circuit can be found at the bottom of the page. Each section of the circuit is labeled in the schematic. All of the sections and their components are described and discussed below. The part numbers for the components are linked to websites for data and more information when available.

Transmitter Power Supply

The power supply uses a 9 volt battery and a TC1264-3.0V high-accuracy low-dropout linear voltage regulator to provide a stable 3 volt supply for the microcontroller and the transceiver. An additional TC1262-5.0V high-accuracy low-dropout linear voltage regulator is used to provide a stable 5 volt supply for the accelerometers. 1uF (microFarad) polarized decoupling capacitors are necessary on the outputs of the voltage regulators to prevent spikes or ripples. A wall wart power supply as low as 5.3V can be substituted for the 9 Volt battery.

Transmitter Accelerometers

To sense the position of the board, I used 3 single axis accelerometers in an X-Y-Z configuration. I used two MMA2260D Low-G X-axis accelerometers and one MMA1260D Low-G Z-axis accelerometer. The two X-axis accelerometers were positioned in an X-Y configuration and the Z-axis accelerometer was used to sense gravity in the Z-direction. The resistors below the accelerometers are used as a voltage divider so that the PIC, which is running at 3V, can read the voltage, which will vary from 0V to 2.5V. With this configuration, for each accelerometer 1.85V is +1G, 1.25V is 0G, and 0.65V is -1G.

Transmitter RF-24G Transceiver

The Laipac TRW-24G 2.4GHz transceiver uses a Nordic Semiconductor nRF2401a transceiver chip and includes all of the necessary components. The TRW-24G (also called the RF-24G and TXRX24G) requires a 3 Volt power supply and 3 Volt logic, so running the transceiver at 5 volts is not a viable option. Information on the chip’s interface cam be found in the following data sheets:

Transmitter Microcontroller

The microcontroller used was a Microchip PIC18LF2550. I modified the PIC18F2550 Tiny PIC Bootloader assembly file so I could use a 10MHz crystal/resonator at 57,600 baud (the modified bootloader can be found at the bottom of the page). The PIC18LF2550 runs at a maximum speed of 16MHz (4 MIPs) with a 3 Volt power supply; however, I had 10MHz and 20MHz ceramic resonators on-hand, so I ran at the fastest ‘safe’ speed possible (I could overclock the PIC by running it at 20MHz with a 3 volt supply, but it would be running out of spec. so it may not operate reliably). The firmware was written in C (using CCS PICC) and can be found at the bottom of the page, in addition to a generic RF-24G driver for Laipac TRW-24G 2.4GHz transceivers. R1 is a pull-up resistor necessary for operation. C1 is a stabilizing capacitor that is used for the onboard USB voltage regulator (which is not utilized in this project). The component marked ‘RES’ is a 10MHz resonator.

Transmitter RS232 Level Converter

The microcontroller USART pins need to be connected to a RS-232 Level Converter to connect to a PC for firmware updates using the Tiny PIC Bootloader. Otherwise, after initial programming they can be left disconnected.

Receiver Circuit

The circuit for the receiver is exactly the same as the circuit for the 2.4GHz Serial Link; however, the receiver code is different because it expects a 6-byte payload from the RF-24G. The source code for the receiver can be found below.

Source and Firmware

The PIC must initially programmed with the ‘SAC_tinybld18F2550_10MHz_57600’ hex file to program the bootloader on the PIC. Then, using Tiny PIC Bootloader, the hex files can be placed on the chips using the Tiny PIC Bootloader frontend with ’12h 34h 56h 78h 90h’ in the ‘List of codes to send first:’ in the ‘Options’ menu.
SAC_tinybld18F2550_10MHz_57600.asm (hex)
18LF2550 RF-24G Accelerometer Transmitter.c (hex)
18LF2550 RF-24G Accelerometer Receiver.c (hex)

16 thoughts to “PIC18LF2550 Wireless 3-axis Accelerometer”

  1. I have been thinking about a project to sense the position of binoculars in three dimensions. It is easily possible to buy a computer driven or position sensing telescope. When I use my binoculars, no such product exists. I have bought a 2 axis accelerometer from Parallax along with a basic chip. I had some success but it is clear I need 10 to 12 bits ADC to correctly determine my azimuth / elevation / tilt. I have a couple of questions:
    1. Why did you pick three one dimensional accelerometers rather than a three dimensional accelerometer? Cost, availability, they were in your junk box?
    2. Do you have a circuit for me to use a USB or serial port on my laptop to receive the output of the 3D measurements?

    Jim Kraemer
    PS. My son is a junior in Film at Tisch.

  2. Jim – Sounds like a great project, please let me know about its progress! In response to your questions:
    1. Three one-dimensional accelerometers were use because they were available in my pile-o-electronics. A three-dimensional accelerometer would be a much better investment in terms of size and accuracy.
    2. You can use my PIC18F2550 USB HID IO project to easily sample and acquire the accelerometer measurements. All that you have to do is attach the outputs of the accelerometers to the A0-A2 inputs and use the example Visual Basic source code to acquire the values.

  3. #3 (Leroy Vargas) – Sounds like a good idea. If coupled with a feedback system (such as haptic feedback), then the individual may be able to compensate.

  4. Hi, I am a Brazilian student, I am at the beginning of the course of electric engineering and am passing 3 months in a laboratory of French robotics. My first function is to calculate the alplitude of the vibration in a place of a helicopter. For this we have two accelerometers of 3 axis each, of PCB PIEZOTRONICS model 356A15. Making research to find solutions, I saw your project and liked a lot, but i would like that, if you have time, to help me in the adaptation for my situation, as much in the electronic part as in the part of the programs.
    Thank you very much.

  5. How small could a wireless 3 axis accelerometer / transmitter be made? I would like to instrument a billiard cue to detect the magnitude and direction of the impact force acting on the cue-ball and equal/opposite on the cue.

  6. which c compiler we need to use in order to build the source code. i used MPLAB IDE v8.1 and pic c18 compiler provided by microchip but i got a lot of syntax errors. so i think the code is written for different compiler

  7. Hi,

    I am working on a project involving detecting the overall fluctuation in conditions of a shipping container on the high seas.
    The data has to be viewed real-time or minutely averaged.
    What kind of software would maximise my data being received.
    Would a software to Hardware interface be inferior to a software to software to hardware interface. Would satelite feed be better than GSM.


  8. hi,
    i’ve a totally newbie question:
    can you send and receive 3 simoultaneous and independent streams of data of the 3 accelerometers, with just one transmitter ? or the stream transmitted is just one (and the the transmission is something like : (read and stream accelerometer x, for 1 ms; read and stream accelerometer y, for 1 ms; read and stream accelerometer z, for 1 ms; start again) ?

    (i confess i didn’tread the code)

    Have a nice day!

  9. hI THERE,

  10. hi i am working on 3 axis acceleromater data to transmit.
    which one microcontroller is best to us for this purpose

    avr or pic….?
    nd how i can get free sample acceleromater from freescle while company charge 12$ shipmint charges
    pleas guide me
    contact my on my email(qamar_raza786@yahoo.com)
    thank u in advance

  11. Hi Steve, I want to implement a vibration monitoring system using a PIC18F microcontroller. I’m almost new to this and I was hoping how could you help me. I only have acces to 2 accelerometers here in my country, the Analog Devices ADXL321 and the MEMSIC2125 from PARALLAX. Which would be better suited for vibration monitoring in rotating machines with speed up to 5000 rpm. Thanks in advance

    Henry Prieto

  12. hiii…. Steve, i m Mp cheema from india(punjab). i wan to implement a wireless video camera on a spy robo by using pic18lf2550. Actually, i wan 2 display the picture cought in da camera on computer’s display unit. Can u please help me in codin pic contrller???

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.