Thursday 2 August 2012

The Circut

Below is a picture of the current circuit I am using for the prototypes. I will spend a little time describing how it work and how to make it better. (Click on the picture for a full size one).

 
Battery Management

U1 (MCP73831) is a LiPo charge controller. The value of R2 controls the circuitry to charge the LiPo at 500mA. C1 and C2 stabilise the output and input voltage. R1 limits the current of LED1, which switches on when 5V comes in through the USB connector and sets the Status Pin (1) high. Note that the data lines of the USB connecter do nothing. With the switch S1 off, nothing no power is being drawn and nothing works.

Power Management

U2 (TC1015) is a 3V low voltage dropout regulator. C3 and C4 stabilise the output. R3 and R6 form a voltage divider so the voltage of the battery can be measured at a microcontroller input (configured as an AD converter). The input range for the PIN is 0 to 3V, the battery range is 3.30 to 4.20V. Splitting it to 1.65 to 2.10V allows the 10 bit AD to measure to about two decimal places, which is good enough as a battery monitor. I have updated the PIC code to output a battery measurement once every ten seconds. The exact value of R3 and R6 is not critical, but they must be matched as closely as possible. If the ohmmeter matches to two decimal places that is good enough. Generally you need to test about ten to get two which match that closely. As soon as power is applied U4, U3 and U6 all start working.

Microcontroller

The PIC24F16KA101 has a simple circuit for basic operation. C6 is the standard decoupling cap between VDD and GND. C7 and R4 stabilise MCLR.  JP1 is currently a five pin right angle 0.1" header for programming via ISCP. I am planning to replace it with pogo pads to make it less clunky. I use LED 2 connected to pin 6 for microcontroller feedback. Currently it just flashes to let me know the microcontroller is working correctly, except when the RN42 is connected to a bluetooth host.

The PIC's pins 4 and 5 are connected to the UART on the RN42 for transmitting characters back and forth. PIC pin 14 is connected to the RN42 PIO2, which goes high when the RN42 is connected to let the microcontroller start sending data.

The PIC's pins 10, 11, 12 and 13 are connected to the MS5611 which uses the SPI interface.

RN42 Bluetooth transmitter

C5 is the standard decoupling cap between VDD and GND. RN42 pins 1, 12, 28 and 28 are all connected to GND. Pins 15 and 16 are connected for UART CTS and RTS feedback. This is not necessary, but is a legacy from some earlier testing. Pin 21 (PIO5) is connected to a status LED, which flashes to indicate connection state (flashing once a second - not connected, solid on - connected, solid off - not working, flashing faster - in special command mode).

MS5611 Pressure Sensor

Pin 2 (PS) is connected to GND to put the MS5611 into SPI mode (rather than I2C). C9, L1 and C8 work together provide the most stable power input possible. They form a pi filter. I think that I can further mess with these values to get it more stable, but really need an oscilloscope to see what frequencies the noise is.

Further work

There are a couple of changes that I might implement in future designs:
  • PIO4 (pin 22) of the RN42 should really have a exposed pad somewhere to allow me to factory reset the device.
  • I should connect RESET (pin 5) of the RN42 to a spare microcontroller pin so I can hold it low once battery power gets below a certain level (I think 3.5V).
  • The form factors of LED2, C9, C3, C1 and C2 could be smaller, particularly the caps. I used what I had. There are cheaper smaller options that will work just as well.