Automatic Pet DoorHome AutomationProjects

Automatic Dog Door (Part 2b) – Electrical Problems

This post is part of a series looking at the challenges faced when taking my initial idea and prototype automated dog/pet door I described in Part 1, though to a working implementation. This post focuses on the electrical problems encountered.

Problem 1: Erratic performance

During the initial development and prototyping, I was powering the Particle Photon from the micro-USB connection on my PC to enable simple serial log debugging on my computer. The stepper motors were being driven by a separate 12V power supply and all was working. When I switched to powering the Particle Photon from a 12V to 5V DC-DC converter then something was going wrong, the door didn’t open smoothly, it stuttered as if something was constantly interrupting the stepper motor move routine.

This was the most frustrating problem I experienced during the development of this project. I spent countless hours adding decoupling capacitors of various sizes to various parts of my circuit, without any joy in resolving the problem.

I went off down a rabbit hole thinking the problem was related to how the Photon was being powered, Vin pin, rather than from the micro USB interface. Even though the schematic clearly showed the only difference between the two power methods was that the USB power is fed into Vin via a Schottky diode, which appears to simply to provide polarity protection.

I was further convinced this was the problem after I powered the Photon via the Micro USB connection using the same DC-DC converter that was causing the problems and it appeared to resolve the issue. It was only when I tried a shorter USB cable that the problem re-appeared. Ruling out the power input method as the cause of the problem.

Having tried various filter capacitors initially, I was back thinking the problem might be noise-related. Testing various L-C filter circuits still didn’t resolve the issue.

Resolution: After weeks of experimentation, probing with an oscilloscope etc. I eventually identified the problem as an earth loop issue. Commoning up all my ground connections a single point near the stepper driver resolved the issue.

Problem 2: Non-polarised connectors

During the troubleshooting of the power delivery mechanism, I learnt an important lesson. Always use polarised connectors when damage can occur if the connector is connected the wrong way round. I’d originally used Dupont connectors for all the connections on the board. They are ubiquitous connector seen used in a lot of projects.

2 pin Dupont Connector

Using a non-polarised connector for your power connection isn’t a good idea. One of the differences when powering the Particle Photon via the Vin pin instead of USB, is that Vin doesn’t have the protection diode. So when power is connected incorrectly to the Photon the 3v3 regulator gets cooked pretty quickly. Resulting in one dead photon (possibly recoverable if I could replace the regulator).

Resolution: I took 3 steps to address the problem I introduced with the use of Dupont connectors.

  1. I replaced the Dupont connector for the power supply with a 2 pin polarised connector.
  2. I added a polarity protection diode across the power rails on the board.
  3. I reviewed my other usage of Dupont connectors, replacing simple pairs with 2×3, 2×4 and 1×4 connectors. Often with not all connections populated, such that if the connection was reversed the pins wouldn’t be connected.

Problem 3: Stepper drivers

When I first began benchtop prototyping this project I purchased Adafruit TB6612 stepper driver. I’ll admit I hadn’t done much research but soon came to learn about micro-stepping and how that would provide smoother operation and increased torque.

TB6612

I then purchased some DRV8825 drivers which supported 1/32 stepping but in testing, even with the small heatsink fitted they would get incredibly hot when in regular use.

DRV8825

Resolution: Ultimately these were replaced with the larger TB6600 housed in a metal case with large heatsink fins to maximise heat dissipation.

TB6600

Though these drivers are listed as using Toshiba TB6600 stepper IC, the TB6600 only supports 1/1, 1/2, 1/4, 1/8 and 1/16 stepping. What is really used in these is the Toshiba TB67S109, which has the addition of 1/32 stepping. This comes at the expense of slight lower maximum peak current handling of 4A, instead of 5A with the TB6600.

Using this larger stepper driver provided significantly improved cooling capabilities and aided with mounting on to the 2040 aluminium frame.

Problem 4: Cheap components

The online availability of electronic components has brought benefits but also some challenges too. The trusted sources like RS Components, Farnell Components, Mouser and Digikey provide a wealth of high-quality components. But for small quantities, their pricing and shipping costs often lead me to look at other sources such as eBay and Amazon. Sadly gone are the days of the Maplin Electronics on the high street where you could pick up what you’d need for a project at a fairly reasonable price.

For this project, I needed to source a number of different components that I didn’t have in my project boxes. Many of the components sourced were fine, however, I had problems with 3 different items:

Microswitches: I purchased a range of miniature (V4) microswitches from several different suppliers. With various lever lengths and styles.

On some, the plastic holding the connection pins would melt/deform quickly when attempting to solder the connections. Some would only actuate when the lever was pressed incredibly hard, bending the lever beyond where it would normally travel. Others the hinge mechanism for the lever was loose. On the whole, I didn’t find any that I thought were good. In hindsight, I would source these from a trusted supplier.

Toggle Switches: I originally planned for using a centre off momentary miniature toggle switch as a way of manually opening the and closing the pet door.

I ordered this type from an eBay seller, what arrived were non-momentary centre off switches. So after getting a refund, I decided I could adapt my plan and using these new switches for a locking open and close feature, and use a simple push-button for manually triggering the door to open. Like the cheap microswitches, the toggle switches couldn’t take much heat from the soldering iron before the plastic deformed. Two switches broke during the soldering process.

Wire: I had some 5 wire ribbon-like cable leftover from my RGB lighting projects. I thought this would be good to use for running to my limit switches, keeping pairs of wires together.

This wire turned out not to be copper (possibly aluminium?) and very fragile. Almost every time I touched or moved the microswitches one of the wires would break where it had been soldered. After numerous re-soldering. I ripped out all this cheap wire and replaced it with regular copper equipment wire I had.

Problem 5: Proximity sensors

At the inception of this project, I was thinking I would use a RCWL-0516 Microwave radar sensor module for internal motion sensing.

RCWL-0516

In conjunction with a 134.2K long distance RFID reader designed for reading animal microchips which use the ISO11784/85 standard. This would be used for only allowing known (programmed) microchips in our pets to open the door from the outside.

134.2K Long Range RFID Reader

Microwave radar sensor

After taking delivery of the Microwave sensor module and testing it out it became apparent it wasn’t going to be suitable as it was too sensitive. With a detection range of ~7m and the ability to see through solid objects, it triggered too many false activations to be of any use.

134.2K Long Range RFID reader

This hasn’t been implemented yet, but maybe in the future. The notes that arrived with the sensor indicated it shouldn’t be powered by a DC-DC converter, but instead through a linear regulator, which suggests it could be very sensitive to noise. Given the limited access to the rear of our house and that we’ve never had a problem with other animals coming into our home before. I decided to stick with a simpler approach for the initial implementation.

Proximity sensors

I experimented briefly with a number of different passive infrared detectors (PIR). But found sometimes they worked fine, other times they didn’t trigger or acted erratically.

SR505 PIR Sensor

Distance sensors

The next stage in evaluating sensors led me to Sharp DP2Y distance sensors. Rather than providing a digital trigger for presence, it has an analogue output where the voltage level reflects the distance from the sensor. The sensor comes packaged in a number of forms with slightly varying characteristics. I tested 3 variants:

ModelMin range (cm)Max range (cm)
GP2Y0A41SK0F430
GP2Y0A21YK0F1080
GP2Y0A02YK0F20150

I opted to use the A21 variant for both the internal and external sensors.

The external sensor is within a 45cm high tunnel opening, which can easily provide a significant voltage increase when anything enters the opening. The internal sensor is pointing diagonally down to the floor which is ~80cm below. So again significant objects entering the view of the sensor is sufficient to trigger a large enough voltage change.

The Sharp sensors aren’t perfect, even after twisting all the connecting wires and adding decoupling capacitors at the sensor end to try and protect from noise I was getting false activations, which appeared to be more common when sunlight was shining onto the sensor.

Resolution: Moving the internal sensor to a more shaded location below the control box has helped. Through experimentation increasing the trigger voltage threshold has helped, but the final step required changes to the software to read the sensor value twice when triggered in order to avoid any spikes in readings.

bool indoorPresenceDetected() {
    indoorSensorValue = analogRead(indoorIRSensorPin);
    if (indoorSensorValue >= indoorIRSensorTriggerThreshold) {
        // Read again to try and avoid false trigger
        indoorSensorValue = analogRead(indoorIRSensorPin);
        if (indoorSensorValue >= indoorIRSensorTriggerThreshold) {
            keepOpenTimer.changePeriodFromISR(keepOpenTime);
        return true;
        }
    }
    return false;
}

This software change was one of many changes that were needed in taking the prototype to the implemented solution. These are covered in the next post in the series.

Project Series

Leave a Reply

Your email address will not be published. Required fields are marked *

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