top of page

Lasercat - Progress Update #1

Writer's picture: Sophia SchulzSophia Schulz

Updated: Dec 7, 2023

Personal Project (ongoing since April 2023)

Overview of Progress

It's been a long time since I've discussed the Automatic Cat Laser Pointer project, nicknamed "Lasercat", but it's (somehow) been a productive time! Between semesters in June/July and since finishing up my 3rd year of university studies in November, I've had more time to work on the project and made some pretty concrete progress towards a final working product. I've taken my initial low-level C implementation and transformed it into (slightly) higher level C++, iterated on the designs of my components, and even 3D printed and assembled a few of the final pieces. Of course, this progress wasn't without its setbacks, mostly in the form of an intense university workload and some chewed up wires due to two very impatient cats. Since there's a lot of progress to update on, I've split this post into the following sections:

  • C++ implementation & Software Developments

  • Component Design Iteration & 3D Printing

  • Design of Outer Casing in CAD

  • Next Steps

Looking at my last post, I realise I've diverged from the next steps that I had laid out for myself back then. I had originally set out with the intention of creating a "manual mode" but, for the sake of creating a product that can sit by itself on the wall, I've decided to stick with implementing a purely automatic system. Nothing beats just holding a good old laser pointer if you want to entertain your cats manually!


C++ Implementation & Software Developments

Transitioning to C++


For better organisation and to make a feeble attempt at abstracting away some of the low level C, I rewrote my initial software in C++. I made use of PlatformIO, an extension for uploading code to microcontrollers via VSCode. My current code structure consists of a main file and two fairly self-explanatory classes, Motor and Timer. The Timer class helps implement most of the timer functionality that forms the backbone for the PWM-driven duty cycles that control the motors. The Motor class is used to create a Motor object for each of the (you guessed it) motors - the "laser motor", which holds the laser, and the "outer motor", which holds the motor that holds the laser. I kept my Interrupt Service Routines in the main file, but initially ran into difficulty when I realised that these ISRs couldn't access objects created in the main file. As a result, I kept their functionality extremely simple, mostly changing global parameters as these were all they could access.


Finite State Machine Implementation


After testing that my initial program worked in C++ form, I moved onto developing it by implementing a Finite State Machine (FSM) to switch between different operation states. A finite state diagram of the system I envisioned is shown below:

Two physical buttons will be used to transition states as indicated on the diagram. I then implemented ISRs for these two buttons, as well as a switch-case program in the main file, to complete the FSM framework in code.


Calibration Mode


I then focused my efforts on completing the Calibration Mode program for states 1 and 2 (CALIBRATE_Y and CALIBRATE_X). My thinking for this mode was to calibrate the "outer motor" first and then followed by the "laser motor", effectively setting the length ("y") and width ("x") limits that the laser could operate within. I decided to program each motor to rotate clockwise and counterclockwise continuously until a button was pressed, setting its minimum limit, and then rotating until the button was pressed again, setting its maximum limit. This would largely be dictated by the user's visual perception of where the laser was travelling within the space being used (in my case, my living room).


I initially wanted to control most of the calibration through the motor class but found that I couldn't guarantee fast state transitions using a button ISR if the motors were being continuously run through a class method (again, tying back to the fact that ISRs can't access objects as far as I'm aware). Since fast state transitions were key in properly setting the minimum and maximum limits for each motor, I ended up implementing the entire calibration script in the main file. It's quite lengthy and not as organised as I would like, so I may try to revisit this later on and see if I can clean it up. I've yet to test this part properly, owing to the fact that I still need to replace the wires my cats chewed up, but I'm crossing my fingers that this works ;)


If you're interested in seeing my code as it progresses (as well as my questionable commit messages), the GitHub link to the project can be found here.


Component Design Iteration & 3D Printing

To reduce 3D printing complexity, I removed the toothed parts and decided to just superglue some servo horns onto the prints. The updated component designs in CAD, as well as an assembly file showing how they fit together with the servo motors, are shown as follows:

I then 3D printed these parts using my friend's PETG filament, glued the servo horns onto them, and assembled them with the laser module and the motors! One of the prints was initially too thin and part of it snapped upon screwing the M2 screws into them, so I increased the length to add more material. The laser part also needed to be re-printed as the tolerance was too tight for the laser to effectively slide within it. Having adjusted for those initial failures, the end result was extremely successful! The assembled motors and laser are shown below:


Next Steps

So fun fact: I'm currently in Singapore! I'm completing an engineering research internship here (although my start's been delayed as I'm currently sick with COVID), but this means I have limited access to prototyping equipment for personal projects. With this in mind, my goal is to finish all of the software, as well as create the final CAD file for the outer casing that will hold everything together, before I return to NZ in February. That way, I can focus on 3D printing, soldering and assembling everything when I get back, thus completing the entire project (kind of like a "Sorry for abandoning you for 3 months!" gift for my cats). Broken down, the final steps are as follows:

  1. Write the path randomising algorithm for the motors

  2. Set up input pins for the buttons and the output pin for the laser

  3. Test all code (requires purchase of new wires — thanks cats)

  4. Create CAD file for the outer casing and prep the .STL file for 3D printing

  5. (Back home) 3D print, solder and put everything together!

15 views0 comments

Recent Posts

See All

Comments


© 2025 by Sophia Schulz.

bottom of page