Showing posts with label 555. Show all posts
Showing posts with label 555. Show all posts

Wednesday, April 2, 2014

555 Entropy and Robotic Teddy Bears

Recently I have been keeping busy with a few electronics projects, although it doesn't look like either of them will turn into anything. The first would transmit text wirelessly from a PC to a microcontroller to be displayed on an LCD. For this I planned to hack toy walkie talkies. This is not an ideal way to transfer text but I thought it would be fun to try different ways of making them work to start understanding wireless communication. Unfortunately, in my whole town I could only find one set of walkie talkies and one of them turned out not to work. The data being sent would not be especially sensitive but I still did not want to send it as plain text. This got me wondering about encryption, which I also have no experience with. There are many algorithms but I would need one very easy to compute since the microcontrollers involved would not be very powerful but would have to decrypt and transfer quickly. One solution that intrigued me was using a one time pad. Each microcontroller would have the same list of random numbers that would simply be added or XOR'ed with the data to encrypt and decrypt it. One time pad schemes have the advantage of being truly unbreakable as long as the numbers used are random and never repeated. A bigger advantage for me is that the microcontrollers could simply fetch the numbers from an SD card without having to compute anything. To get truly random numbers, though, I would need a hardware random number generator. These are a common project for hobbysts but not always easy to build correctly. One method uses a transistor in reverse breakdown mode but I decided against this because it requires 15 volts or more. Apparently the transistor also changes with age (perhaps due to being continuously run in a way it was not designed to be) and the characteristics of the numbers generated change too. Another interesting way I found was to measure the output of a 555 timer with a microcontroller ADC as shown here. This made me wonder if I could just measure the length of 555 pulses compared to the oscillator in a microcontroller to use clock drift as an entropy source. I connected a 555 running at 480Hz to the hardware counter of an MSP430 running at 16MHz to measure how many clock cycles each 555 cycle took and dumped 1,000,000 samples out over UART.

Saturday, August 17, 2013

RPN Scientific Calculator: Tweaks

Recently I was able to get some new components and took the chance to make a few tweaks to the calculator. First of all, I hooked up a new 20x4 character LCD to replace the 16x2 version I was using before. It is gray with black letters and I like how it looks. With this I will be able to make the bottom row of the screen a menu like the kind some of the later HP calculators use. The LCD itself came with male headers so it can be plugged into a breadboard, but there was no convenient place to put it so I decided to run wires from the headers to the breadboard instead. The LCD worked fine at first but quickly became corrupted after I wound the wires into a loop to make them neater. This was causing crosstalk and the problem disappeared when I separated the wires.

I also added a CMOS 555 timer to generate the negative voltage for the LCD. This frees up a microcontroller pin that I am now using to independently drive the input shift register of the RAM. Now I can read the external RAM and the keyboard at the same time without worrying about coordinating interrupts. In order to save energy I decided to use the smallest capacitor and the largest value resistors I could for the timer. Unfortunately, none of the resistor values I had on hand would give me the 30 Hz or so the microcontroller was generating. 48 Hz was the closest I could get using a 0.1 uF capacitor and 100k ohm resistors for R1 and R2. Adding a 470 ohm resistor to the output of the 555 gave a good contrast and should also keep the contrast constant if I try to run everything from a battery later.

The last thing I did was to expand the CORDIC tables to 32 bits wide instead of 16. Using a 16 bit wide table gives around 14 decimal places of accuracy which is sufficient for calculating logarithms. A problem arises, however, when that logarithm is used to calculate things like exponents because those 14 places of accuracy also include the whole part of the answer. A simple calculation like 8^9 only offers 5 decimal places of accuracy after the decimal since the whole part is 9 digits long. The new version takes about 6 seconds to calculate "atan(tan(37))" This is very slow so I will let the user set the precision in settings.

Saturday, December 1, 2012

555 Timer Setup

Recently I set up a 555 timer and three AAA batteries to experiment with. The first thing I wanted to do was flash an LED. I wrote a program that will let me figure out the frequency of the flash, size of the capacitor, or the values of the resistors. I decided on a 10uF capacitor and a 100k resistor to give me a blink slow enough to see. This was interesting but then I decided to put a potientiometer in place of R2 so that I could control the rate of the blink. I also put a potentiometer in place of the resistor to the LED so that I could control the brightness. Tuning the potentiometer so that the LED wasn't very dim or very bright was difficult. After doing some reading I saw that it is possible to adjust the on and off times independently of each other if you use a diode with R2. I replaced R1 with a potentiometer so I could control both the length of the flash and the pause between flashes.

Next I connected a piezo speaker to the timer. It ticks every time the current to it is switched on or off. According to the datasheet, the current doesn't have to be turned off but should actually be reversed. I am not sure how to do this with less than four transistors. By using the potentiometers to make the timer pulse quickly, the ticks of the speaker come fast enough to blend into a tone. I tried using smaller capacitors from the TV I took apart with the timer and the tone was much higher. I put another potentiometer in place of the resistor to the speaker to control the volume. One thing I noticed is that the speaker made a growling sound when I tried to turn the volume up too high. It seems that the timer was failing and restarting many times a second because the circuit was drawing more than the 200mA the timer can source. To remedy this I put a resistor in series with the volume potentiometer. This is also a good idea for the other potentiometers so that the timer and LED don't get damaged either.