Posts

Divide-by-n counter with a fixed duty cycle

Image
A divide-by-n counter is a circuit that takes a digital clock signal with a frequency f and a number n and produces a digital output signal with a frequency of f/n . For example, the waveforms below are the input and output of a divide-by-5 counter that produces an output pulse every 5 input pulses. However, this approach produces a output waveform with a duty cycle that decreases as n increases. In some cases, it may be necessary to produce an output with an exact 50% duty cycle that does not change with n : In this article, I will describe a 9 bit divide-by-n counter circuit (where n is between 2 and 511) that produces an output with a 50% duty cycle. Note on reference designators: Many logic chips contain multiple copies of the same circuit (for example, 74HC00 NAND chip). Each copy will be shown individually, but will have the same reference designator. To distinguish these copies, the lowest pin number belonging to that copy will be placed in brackets after the refere...

Bitbanging Ethernet on an Arduino

Image
In this article, I will present a program that allows AVR-based Arduino to send and receive Ethernet packets at 10Mbit/s without the need for an external chip. This program only works on some Arduinos, as the Arduino must run at 20MHz (which may require hardware modifications), and it is still necessary to use external resistors and capacitors to adjust the voltage levels. The program also requires that the AVR chip have features that are only available on some chips (such as the atmega2560 on an Arduino Mega). This program also implements a simple ping server that works about 85% of the time. One can also transmit and receive simple UDP packets, so a possible use case would be making a sensor that transmits a value at regular intervals. Since the Arduino is only barely fast enough, transmitting a packet requires large sections of the packet to be hard-coded. The two PWM outputs of one of the timers are used to generate the differential signal and to perform the Manchester encoding ...

Remote low-voltage outdoor light switch

Image
In this article I will explain a remote light switch for low-voltage outdoor lighting. This device toggles the state of the load whenever the power to it is interrupted briefly. This device also connects to a wireless remote control (similar to this one ) to allow the user to control the brightness of the LED strip. Background I built this device to power a set of LED light strings (similar to these ) from a 12 volt battery. The battery is charged by a solar panel through a charge controller. Various motion-activated lights in the house are also powered from the battery and solar panel. However, there was only a single 12 volt wire feeding multiple outdoor loads, some of which were needed during the day. Thus, I created this device to switch these lights on at night. An Arduino measures the voltage on the solar panel and determines when night begins. Then, it briefly interrupts the power to the lights, and the device interprets this and switches the lights on (or off). This allows po...

Second version of the PWM dimmer and test results

Image
In this article I will give updates on the PWM dimmer I explained in a previous article . I will explain the changes that have been made and present a new schematic. I will also quantitatively compare the performance of the PWM dimmer to the performance of a phase control dimmer. New schematic and explanation The new schematic is shown below: Link to simulation (1Ω resistor and 500pf capacitor are only for the simulation, they are not part of the circuit) I have made several changes to the design: Gate drive circuit The gate drive transformer was replaced with a handmade one made from a toroidal ferrite core and 9 turns of a single twisted pair from a CAT5 cable. An additional circuit was also inserted between the 555 timer and the gate drive transformer to amplify the current on the output. This circuit consists of an NPN and a PNP transistor, with both bases connected through separate resistors to the output of the 555 timer. The capacitors between the output and the bases ...

Arduino-based pill timer that makes phone calls

Image
In this article I will explain the operation and construction of a pill timer that can make phone calls via a cordless telephone handset. I will explain the individual parts of the device and explain the logic that controls the pill timer and telephone. Operation of the pill timer The pill timer connects to a keypad, an LCD, and a telephone handset. when the user powers on the pill timer, they must enter the current time using the keypad. To start the timer, the user presses tha "1" key on the keypad. The pill timer determines at what times the user needs to take their pills according to a schedule that has been hard-coded into the pill timer. When it is time for the user to take a pill, the timer will initiate a call to a pre-programmed number. Once the user has picked up, it will play a recorded message. Specifically, this recorded message is "It is time for pill box number" followed by a number. Schematic and explanation gEDA schematic file Memory chip T...

Software for identifying the ideal setup of a solar panel based on surroundings

Image
In this article I will present a program that can identify the most efficient angle of a solar panel, taking into account any objects that may cast a shadow on the panels. I will explain each step of the program. The source code can be found at https://github.com/mnigmann/solar Finding the sky The program takes as an input an image of a spherical projection of the surroundings, such as the image below: To identify the regions of sky, the program applies a Sobel filter, dilates the image, and applies a threshold. This causes regions where the color does not change much (such as the sky) to be black and regions where the color changes a lot to be white (such as trees, grass, buildings, etc.). For the above image: The user must then click on the regions of the image containing sky. Using the cv2.floodFill function, the program identifies the rest of the sky, as seen below: Finding the position of the sun The program calculates the position of the sun based on some formulas fr...

People counter made from discrete components

Image
In a previous article , I described how I created a people counter that used capacitive sensing. In this article, I will describe the operation of a people counter I made from discrete components that works on a similar principle. As described in the previous article, this circuit will contain two separate oscillators, with each one connected to a sense wire. However, in this circuit, one of the oscillators will be a voltage controlled oscillator (VCO). A frequency comparator will compare the frequencies of the two oscillators and tune the VCO so they match. Schematic and explanation gEDA schematic file Regulator U1 regulates the 12 volt input into the 5 volts needed for the logic gates. The capacitors C1 and C2 are actually placed near the power pins of U2 and U3. Reference oscillator (bottom left box) The reference oscillator oscillates independently of any other signal, except for the capacitance on the sense wire. The circuit is identical to the one described in the prev...