September 29, 2017

Upgrading a Bosch PLL 360 self-levelling line laser

Based on my previous upgrade of the Cocraft HL-10 cross line laser, I was set to upgrade my PLL 360 cross line laser as well.

Analysing the hardware

I first opened the laser by locating all 5 screws.
One of the screws is hidden under the sticker.
It seem to be possible to adjust the accuracy if needed by adjusting the copper coloured screws.
The line laser is self-levelling as long as the line laser is keep within ±4 degrees referenced from the  bottom plate. If the inclination is greater, the inclination switch kicks in and turn off the line lasers at the same time as a warning LED turns on. This can be avoided by pressing the Lock key.
When the spring makes contact with the surrounding PCB, the lasers are turned off.
Behind the control panel I find the main PCB.
A simple construction.
Top-middle right is a step-down converter to bring down 4x1.5V to 3.3V to feed the microprocessor. Bottom right is the microprocessor. A PIC16F676 and a convenient ICSP header close to it (J3). Bottom left is the laser driver n-channel mosfets. Top-middle left is some pull-up resistors and current limiting resistors for the indicator LEDs.
PCB overview
After some measuring I could map all pins on the PIC the functions,
// PORTA-defines
#define H_LED        0  // OUTPUT RA0, Horizontal laser indicator LED
#define V_LED        1  // OUTPUT RA1, Vertical laser indicator LED
#define BATT_STAT    2  // INPUT RA2/AN2
#define WARN_LED     5  // OUTPUT RA5, Warning indicator LED
// PORTC-defines
#define LOCK_LED     0  // OUTPUT RC0, Lock indicator LED
#define V_CTRL       1  // OUTPUT RC1, Vertical laser control pin
#define H_CTRL       2  // OUTPUT RC2, Horizontal laser control pin
#define MODE_BUTTON  3  // INPUT RC3, Mode button
#define LOCK_BUTTON  4  // INPUT RC4, Locked mode button
#define LEVEL_TRG    5  // INPUT RC5, Level switch

The BATT_STAT is never used. The pin is connected to battery output, probably to be able to sense when the battery is running out of juice. I did not find the point in implementing the voltage sensing function.

Adding a HW interface

The J3 connector can be used to connect to the PIC microprocessor.
Pro tip. Solder the cables from the bottom and up, if you'd like to keep the programming cables after closing the line laser.
Once the header has been populated with wires and a pin-header I connected it to my Pickit2.
To my surprise there is no read protection of the original software so it could be extracted and saved. That can be useful if something goes very wrong and I need to revert back to the original line laser firmware.

When the programming is done, the programming header can be tucked away along one side of the line laser. I taped it to one side just to make sure it does not fall loose and start to interfere with the self-levelling mechanism.

The original firmware function

The original firmware have a few basic features.
The Mode button selects which one of the two lasers should be lit. The horizontal laser, the vertical laser or both lasers.
The Lock button disables the internal inclination switch so that the line laser can be used at any angle.

The new features added with my new firmware

I have created two modes. Indoor mode and outdoor mode.
The indoor mode has exactly the same features as the original firmware except for one thing. The last used setting is saved in EEPROM and is recalled when turning on the line laser next time.

The outdoor mode is exactly the same as the indoor mode except that the lasers are pulsating at 2.6kHz.
By pulsating the lasers it is possible for a line laser detector to detect the lasers outdoor in bright daylight. This is a feature that is usually found in more expensive line lasers.
The outdoor/indoor mode is toggled by holding the Mode button while turning on the line laser.

The outdoor mode has been tested with the cheap Clasohlson laser detector, http://www.clasohlson.com/se/Laserdetektor-Cocraft-PRO-Edition-D50/40-9978
The detection range is measured to be at least 55 meter outdoor.

Talk is cheap. Show me the code.

The source code is written in C for the XC8 compiler here,
https://bitbucket.org/foogadgets/pll360-upgrade

The latest hex-file (pll360-outdoor-upgrade.hex) can be found and downloaded here,
https://bitbucket.org/foogadgets/foogadgets-document-and-firmware-download/downloads/