Posts

Raspberry-Pi controlled robot for a school robotics project

Image
For a school project, several teams constructed and programmed small robots to navigate on uneven terrain and complete various tasks. The required tasks included being able to drive around, measure the position of the "sun" in the sky, measure the wind speed, measure the salinity of a puddle of water, measure the temperature of a block of ice, and plant a flag into the ground. Each team was also required to pick several additional tasks, according to the number of people in the team. We chose to also collect gravel from a pile. Most teams controlled their robots using the Vex Cortex and programmed their robots with RobotC. However, I didn't like using RobotC, so as the team's programmer, I chose to control our robot with a Raspberry Pi and program it with C. However, the Raspberry Pi only has two hardware pulse-width modulation (PWM) outputs, and no analog inputs, so it would not have been able to control all of the motors or use the light and salinity sensors. T...

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...