MOV AX, BLOG

Electronics, Photography, Gadgets

Category: electronics (page 2 of 2)

Alarm Project 2.0 Beta

Our second version of the alarm project is now in beta! All we have to do now is update our design in circuit simulator, do a tiny bit of debugging and move it all over to perforated board. Over the next few weeks, there will be a series of posts describing how each module of the alarm circuit works. This design consists of 5 J-K Flip-Flops, 8 AND gates, 2 OR gates, 4 NOT gates, 1 NPN transistor, 3 555 timers, a darlington driver, a 5v relay, a 5v voltage regulator, 12 diodes, 7 LEDs, a magnet switch, a speaker, a piezo buzzer, a numeric keypad, various resistors and capacitors and lots of single core wire and time.

Alarm 2.0 Beta

PICAXE Traffic Light Project and Using PICAXE 20M Interrupts

In a previous post describing how to build a traffic light (or stop light) system using a PICAXE microcontroller, I did not include the details of how to implement a pedestrian crossing part of the project. This post will describe the two ways we tried to implement the feature. Our first attempt used the interrupt feature of the PIXACE 20M and a push button connected to +5v and input pin 5 on the microcontroller. By using the setint instruction, the PICAXE can detect changes on its input pins and match given states, for example: setint %00000000, %00100000 will trigger and interrupt when pin 7 is low and setint %00100000, %00100000 will trigger and interrupt when pin 7 is high. Once an interrupt has been activated, the PICAXE does a gosub to the subroutine at label interrupt and returns to the place it left from on completion. Below is the code we implemented for the first version of the pedestrian crossing using the interrupts described:

symbol rot = 1
symbol gelb = 2
symbol gruen = 3
symbol fgrot = 5
symbol fggruen = 4
let w0 = 0
setint %00100000,%00100000
high fgrot
ampel:
high rot
if w0 = 1 then
gosub fussgaenger
let w0 = 0
setint %00100000,%00100000
else
pause 3000
endif
high gelb
pause 1000
low rot
low gelb
high gruen
pause 3000
low gruen
high gelb
pause 1000
low gelb
goto ampel
interrupt:
let w0 = 1
return
fussgaenger:
high fggruen
low fgrot
pause 3000
high fgrot
low fggruen
return

Unfortunately, this design has a pretty big issue. Namely, when the push button is pressed, the interrupt breaks out of pause statements and does not return to within the pause but immediately after it. This means that a pedestrian can influence the speed at which the traffic light system switches from one phase to another. To get around this, we decided to replace the use of interrupts by a hardware flag in the form of a latch built from an AND gate and a diode. When the user presses the pedestrian crossing button the AND gate latches the input and during the red phase, a check is made to see if the button was pressed. If it was, the pedestrian light sequence is started and the program loops around as normal. In the picture below, you will be able to see the AND gate latch, the traffic light LEDs and the pedestrian crossing LEDs.

PICAXE 20M Traffic Light Project With Pedestrian Crossing

The schematic for this circuit, drawn using tinyCAD, can be seen below.

PICAXE-20M Traffic Light Schematic

Below is the final piece of code for the hardware shown above. There are of course, improvements that could be made, but for the time being, I think that this was a good first step into the PICAXE world.

symbol rot = 1
symbol gelb = 2
symbol gruen = 3
symbol fgrot = 5
symbol fggruen = 4
high fgrot
ampel:
high rot
if  pin5 = 1  then
pause 800
gosub fussgaenger
else
pause 3000
endif
high gelb
pause 1000
low rot
low gelb
high gruen
pause 3000
low gruen
high gelb
pause 1000
low gelb
goto ampel
fussgaenger:
high fggruen
low fgrot
pause 3000
high fgrot
low fggruen
pause 800
return

Ohm’s Law

This video from Make Magazine is a great introduction to ohm’s law and a good way of bringing some of the science behind electrical circuits to kids and adults alike.

[youtube=http://www.youtube.com/watch?v=-mHLvtGjum4]

A First Simple PICAXE Microcontroller Project

Some of my son’s other interests include traffic lights (or stop lights), boom barriers, automatic doors and control panels of any kind. The first microcontroller project we decided to build was a traffic light system including a pedestrian crossing. The microcontroller kit I decided to use for this was the PICAXE-20M Starter Pack (USB) which uses a PICAXE 20M with 8 input pins, 8 output pins, 220 lines of program memory and supports interrupts, digital temperature sensors, radio-control servos, keyboard input, user defined musical tunes, infra-red transmission and reception, an 8/10 bit ADC option, pwm motor control and input pulse counting. The device is programmed via the supplied USB cable. It is a surprisingly sophisticated chip for 2,35 euros. Below is an image of the 20M connected to a small breadboard with three LEDs (one red, one yellow, one green) and 330 ohm resistors.

PICAXE 20M Traffic Light Project

In the circuit above, we connected output pin1 to a 330 ohm resistor and then a red LED, output pin2 to a 330 ohm resistor and then a yellow LED and finally output pin3 to a 330 ohm resistor and then a green LED. To program the PICAXE, you will need a copy of the MacAXEPad for the Apple Mac or AXEPad for the PC which is available at the PICAXE software download page. There is also a comprehensive set of manuals online which describe how to develop code for the PICAXE in BASIC. The basic program below controls the traffic light and is my son’s first ever piece of code. :-)

tlight:
high 1
pause 3000
high 2
pause 1000
low 1
low 2
high 3
pause 3000
low 3
high 2
pause 1000
low 2
goto tlight

Alarm 2.0 and Microcontrollers

The next projects we have been working on and will be described in later posts are much more sophisticated than the previous alarm system. The projects include: building logic gates such as AND, NAND and OR out of NPN transistors, a four bit adder out of logic gates which in turn are built from NPN transistors, a 4 bit counter from J-K Flip-Flops, a new version of our alarm system using 555 timers, logic gates, diodes and a keypad to activate and de-active the alarm and finally, a traffic light system using a PICAXE microcontroller and logic gates. If you would like to find out more about these components and electronics in general, I can highly recommend Make: Electronics by Charles Platt.

Make: Electronics

If you would prefer an online source of information, I can also recommend doctronics which has some great guides and projects with useful circuit diagrams in breadboard format. Take a look at the doctronics biscuit tin alarm for a fun project.

From Breadboard to Perforated Board

The next phase in the development of our first alarm system was to move the components from the breadboard we had been using for prototyping to a perforated board on which we could solder the components and install it in my son’s room. To do this, you will first need to learn how to solder and there are some great online soldering tutorials such as the one below.

[youtube=http://www.youtube.com/watch?v=I_NU2ruzyc4]

I personally chose a 15 watt soldering iron as I will only be using it to solder electronic components and the lower power should help protect the components from being damaged through exposure to too much heat. I recommend that you also purchase a vacuum de-soldering tool and a decent stand. What I have also found important is a third hand such as the one pictured below. This is a great tool for holding your board while soldering components onto it.

The Indispensable Third Hand

After a few minutes of practice, we were able to construct the simple alarm circuit described in a previous post onto a perforated board with little difficulty. The final result can be seen below.

Simple Alarm Circuit on Perforated Board

 

Our First Alarm Project

The project my son decided we should work on is an alarm system for his room. The first alarm we built is based on the lessons that we learnt using the conrad starter kit. It is based on the same components – a 9v battery, resistors, LEDs and an NPN transistor. The circuit can be seen in the image below.

Simple Alarm Circuit

The only components I added are a piezo buzzer, marked as buzzer in the circuit diagram, which you can buy for about 1 euro at most electronics retailers, and two switches marked as on/off and door in the diagram. For the on/off switch we used a lock switch which mean that the alarm can only be turned on or off with a key. For the door switch we used two power strips with multi.core wire stuck to them and then covered in aluminum foil – when the door opens, the contact is broken and the alarm is activated. The description for the circuit is below – give it a try! Please note that in the diagram I used an LED symbol as Circuit Simulator doesn’t have a buzzer component. The code for the circuit is listed below. Just copy and import the code into the free Java Circuit Simulator to get a feeling for the circuit.

$ 1 5.0E-6 10.20027730826997 50 5.0 50
v 368 368 368 272 0 0 40.0 9.0 0.0 0.0 0.5
r 368 272 368 208 0 330.0
162 512 208 512 288 1 2.1024259 0.0 1.0 0.0
s 368 208 512 208 0 0 false
w 512 208 608 208 0
162 608 288 608 368 1 2.1024259 1.0 0.0 0.0
w 608 448 512 448 0
w 512 448 368 448 0
w 368 448 368 368 0
s 512 288 512 448 0 1 false
w 608 208 688 208 0
w 688 208 768 208 0
t 688 288 768 288 0 1 -1.0853467247068087 0.6355071463035651 100.0
w 768 208 768 272 0
162 768 304 768 368 1 2.1024259 1.0 0.0 0.0
w 768 368 768 448 0
w 768 448 608 448 0
w 608 288 608 208 0
162 608 368 608 448 1 2.1024259 1.0 0.0 0.0
r 608 288 688 288 0 10000.0
x 413 237 469 241 0 18 on/off
x 788 347 847 351 0 18 buzzer
x 452 378 492 382 0 18 door

Amazing Java Circuit Simulation

Circuit Simulator is an amazing piece of free software. If you are in any way interested in electronics, download it from here and play around with it for an hour or so. I’m going to be using this application to publish the layouts for the cicuits we are working on in my future electronics related posts.

Circuit Simulator

If you want to see how the blinking LED circuit shown in the previous post works, paste the following into program using the import feature.

$ 1 5.0E-6 382.76258214399064 99 5.0 43
v 352 672 352 400 0 0 40.0 5.0 0.0 0.0 0.5
w 352 400 352 288 0
w 352 288 608 288 0
w 608 288 880 288 0
162 880 288 1008 288 1 2.1024259 1.0 0.0 0.0
r 1008 288 1008 320 0 500.0
w 1008 320 1008 336 0
w 1008 336 1120 336 0
w 1120 336 1120 832 0
w 1120 832 1104 832 0
r 1104 832 992 832 0 10000.0
w 992 832 816 832 0
t 528 400 608 400 0 1 -0.12632236495348304 0.5010407108474094 100.0
w 528 400 528 832 0
w 528 832 736 832 0
w 528 400 528 352 0
t 944 400 1008 400 0 1 0.5847909946260287 0.6273630758008925 100.0
w 1008 336 1008 352 0
w 1008 352 1008 384 0
w 1008 416 1008 672 0
w 800 352 800 400 0
w 800 400 944 400 0
w 1008 672 672 672 0
w 672 672 352 672 0
w 608 416 608 560 0
w 608 560 656 560 0
w 656 560 656 608 0
w 656 608 672 608 0
w 672 608 672 624 0
w 672 624 672 672 0
r 608 288 608 352 0 5000.0
w 608 352 608 384 0
r 608 352 528 352 0 5000.0
w 800 352 608 352 0
c 736 832 816 832 0 1.0E-5 0.21083170251411693

Electronics For Beginners

A new hobby that my son and I have taken up is Electronics. Not only is the topic interesting, but it is also educational for kids. The place that we started was with this starter kit from Conrad in Germany, but most electronics retailers such as Maplin Electronics in the U.K. and Maker Shed in the U.S. will have similar kits. The kit consists of assorted resistors, a 45uF capacitor, two NPN transistors and, fourLEDs, a small Bread Board, a length of single core wire and a battery connector. You’ll be amazed how much you can learn from a kit like this! In the picture below, you can see one of the circuits that we built using our first little kit – two NPN transistors connected to a 45uF capacitor and a few resistors that makes an LED flash on and off!

Blinking LED

Newer posts

© 2017 MOV AX, BLOG

Theme by Anders NorenUp ↑