Sunday, May 17, 2009

Old fencing traing box i built a while ago

Sorry but due to the whole copy/paste thing - big chucks of this report will be missing including all the images - if you would like a copy of this report, email me via farrst@gmail.com.

Year 4, Engineering Project

Stewart Farr

0122165

Project: Score box upgrade.

Client: NZ Academy of Fencing


Fencing Score box Development

Start: May 2005, End: November 2005

Stewart Farr

0122165

avgas@slingshot.co.nz

(021) 298 4184

Report Submitted in (partial) fulfilment

Of the degree of

Bachelor of Engineering

Auckland University of Technology.

Auckland

October, 2005



Fencing Box Update – 2005 rules

Stewart Farr

Engineering Student, Auckland University of Technology.

ABSTRACT: This is the basis, and processes of designing a method to apply 2005 rules to a fencing box. It also includes the complete build (due to complications), of an entry level, practice score box.


1.1 Preface

1.2 Acknowledgments

Karl Snell,

Engineering Student, Auckland University of Technology.

Mark Weathersby,

Fencing Electronics Specialist, UK

Dr. John Collins,

Academic Supervisor, Auckland University of Technology.

Tony D’Arcy,

Initial Academic Supervisor, Auckland University of Technology

J_D (login name – fencing forum)

Fencing Electrical hobbyist, Leon Paul fencing forum.

1.3 Abbreviations

Hit: The contact of weapon, to opposing fencer, enough to depress the tip of the weapon (in case of epee’ and foil – depress the switch on the tip of the weapon).

Box: Hit Register box, also often called score box, even if it does not display a ‘score’, it registers the hit by displaying a light to the referee.

Lock-out time: This is the time that the opposing fencing has to deliver his/her reactive blow (riposte’), after they have had a valid hit arrive on themselves. After this time, the box no longer registers their hit until both fencers come ‘on-guard’ again. If the opponent lands the blow in the brief time allowed, it is counted as a double score – and both lights go.

Contact Time: This is the time the weapon has contact with the opposing fencing (In the case of a hit). This time has to have the tip consistently depressed the whole time.

N.Z.A.F.: New Zealand Academy of fencing (abv.)

F.I.E. – Fencing’s International Regulation Counsel



1.4 Table of Contents

2.0 Background

2.1 Brief Introduction to Fencing

2.1.1 Weapons

2.1.1.1 Physical Representation of the Weapons

2.1.1.2 Foil

2.1.1.3 Sabre

2.1.1.4 Epee’

2.1.2 The Equipment

2.1.2.1 Score box

2.1.2.2 Lame’

2.1.2.3 Cables, wires and other accessories

2.2 Rule changes from 2005 for fencers

3.0 Project Introduction

3.1 Project Brief

3.2 Proposed Ideas

3.3 Investigating a Current box (reverse engineering)

4.0 Hardware Design

4.1 Power Source Setup

4.1.1 Testing the computer source

4.1.2 Adapting the SMPS connector

4.1.3 Final Testing

4.2 Signal Lamp Design

4.3 Prototype Development Board

4.4 Schematic Adaptation and Development

4.5 PCB

4.5.1 PCB layout

4.5.2 Final PCB

4.6 Casing

4.6.1 Initial thoughts

4.6.2 New Box

4.6.3 Cover 1 (STD box)

4.6.4 Perspex Cover

Continued on next page
5.0 Software Design

5.1 Requirements of the Software

5.2 Flow/Logic Diagram

5.3 Structure Diagram

5.4 Test code

5.5 Final Code

6.0 Final Testing

7.0 Conclusion

7.1 Possible Future Developments with the designed box

8.0 References

9.0 Enquiries and Correspondence

10.0 Appendix CD
2.0 Background


2.1 Brief Introduction to Fencing


This contains only basics of fencing applicable to this specific project. For a more in-depth article on fencing please go to:

www.fencingmedia.org/whatisfencing.asp

Due to the fast nature of fencing, large amounts of electronics have become dedicated to the sport, particularly in the registering of hits. However due to the sport increasing in both speed and tactics, and the advancement of modern technology – rules have changed over the years, making some score boxes for the sport obsolete and outdated.

In a fencing bout, 2 fencers face each other using weapons, connected to a box. In foil and sabre the fencers where a metallic vests (Lame’) to allow fencers to register an ‘on-target’ hit. Fencing is performed on a strip (metallic and also connected to the score box), which on international length standards measures 6 foot wide (approx 1.8m), and 44 foot long (14m). This is grounded

The three different types of fencing, which all use different weapons, are:

- Foil (light court sword)

- Epee (French duel sword – bigger version of Foil)

- Sabre (Slashing sword)

These styles of fencing will be explained in the next few pages.

Figure 1 – Fencing Setups



2.1.1 The Weapons

2.1.1.1 Physical Representation of the Weapons


Epee’

Figure 2 – epee

(Image from http://www.inet.hr/~tdedic/epee.htm)

The epee’ is the largest of the 3 swords, incorporating all three of the ‘weapon connectors’, from the scoring equipment to be connected to it. 2 of these connections travel down the whole length of the blade, via a connecting wire – to the tip. Contained in the tip is a small switch (see 2.1.1.2). The grip in most modern weapons is a ‘pistol type grip’, as this gives more manoeuvrability.

Excerpt from http://www.inet.hr/~tdedic/epee.htm:

“The epee (pronounced "EPP-pay"), the descendent of the dueling sword, is similar in length to the foil, but is heavier, weighing approximately 27 ounces, with a larger guard (to protect the hand from a valid hit) and a much stiffer blade. Touches are scored only with the point of the blade. The entire body is the valid target area.”

Foil

Figure 3 – foil

(Image from http://www.inet.hr/~tdedic/foil.htm)

The foil is the smaller cousin of the Epee. Its is a lot lighter and more flick able than the Epee’. It too operates via a small switch in the tip with similar setup as epee’.

Expert from http://www.inet.hr/~tdedic/foil.htm:

The foil, the modern version of the dueling rapier, has a flexible rectangular blade, approximately 35 inches in length, weighing less than one pound. Points are scored with the tip of the blade and must land within the torso of the body.

The valid target area in foil is the torso, from the shoulder to the groin, front and back. It does not include the arms, neck, head and legs. The foil fencer's uniform includes a metallic vest (called a lamé) which covers the valid target area, so that a valid touch will register on the scoring machine. A small, spring-loaded tip is attached to the point of the foil and is connected to a wire inside the blade. The fencer wears a body cord inside his uniform which connects the foil to a reel wire, connected to the scoring machine.”

Sabre

Figure 4 – Sabre

(Image from http://www.inet.hr/~tdedic/sabre.htm)

The Sabre is the ferocity and speed, section of Fencing. You can score valid hits with any section of the blade, not just like the tip.

Excerpt from http://www.inet.hr/~tdedic/sabre.htm

“The sabre is the modern version of the slashing cavalry sword, and is similar in length and weight to the foil. The major difference is that the sabre is a point-thrusting weapon as well as a cutting weapon (use of the blade). The target area is from the bend of the hips (both front and back), to the top of the head, simulating the cavalry rider on a horse. The sabre fencer's uniform includes a metallic jacket (lamé), which covers the target area to register a valid touch on the scoring machine. The mask is different from foil and epee, with a metallic covering since the head is valid target area.”



Electrical/Electronic/Software Representations


2.1.1.2 Foil

Figure 5 – Foil wiring Diagram

(Taken from - www.leonpaul.com)

The foil itself has a small switch on the end (Normally closed), which requires 500grm of mass to put it in equilibrium (i.e. not trigger the switch). However depressing this switch does not register a hit as such. As well as the switch being pushed down (for a set time period – Contact Time), only hits that arrive on the lame’ – are counted as valid hits (i.e. ‘lethal blow’). If the hit is off target, it is not registered. There is a very strong set of ‘Right of way’ rules in Foil – but as this is controlled by the referee, it is not accounted for in this report.

On the scoring apparatus (box), there are 2 main signal lamps, a green on the right and a red on the left. If the box shows a red signal, the left fencer has scored an ‘on-target’ or ‘valid’ hit. Same for the green signal and the right fencer. If either fencer, makes a hit, that is not ‘on target’ or ‘valid’ – a white (or in some cases) lamp (for each independent side), shows the un-registered hit. A white signal, doesn’t count in scoring, but does temporarily halt the match.


2.1.1.3 Sabre

Figure 6 – Sabre (estimated) wiring diagram

Completely separate from either foil or epee, the sabre can have contact anywhere down the blade to score a hit. There is no switch activated score on the tip, but fencers do wear a lame’ – but in this case it covers everywhere above the waist. There are also a set of ‘right of way’ rules.

Most of the older sabre boxes had only the red and green signal lamps (see 2.1.1.2), however some of the newer boxes also use the yellow/white lamps.

The white lamps, signal touches as stated before, but since the new rulings, the red and green lamps only signal a valid hit, which means in sabre – a hit that has contact with the target for a set period of time (see – “Contact Time” in abbreviations).

Contact time for Sabre is currently set at 120 milliseconds.

The reason why this was introduced was due to the fact that fighting with sabre between two fencers was becoming a speed more than tactics sport. Whoever had right of way would simply use their weapon to bend around to a vantage point and ‘tap’ the opponent in the back. By introducing the contact time regulation, Sabre fencing became more traditional.
2.1.1.4 Epee’

Figure 7 – Epee Wiring Diagram

(Taken from - www.leonpaul.com)

Pronounced EPP-pay, this sword is similar to the Foil, but larger and heavier than its little counterpart. Also the switch (in this case normally closed) requires a larger weight on the end (750+g) to depress it. The causes the coloured bulb on the scoring machine to light.

Rules are similar to that of Foil (hit must depress the point to be valid), but different in the aspect that there is no ‘off target hit’. The fencer can score a hit anywhere on his/her opponents body so long as it depresses the tip. This removes the need of a lame’. Also in addition to this, under current rules, in the case of a hit – the opponent has 1/25th of a second to also score a hit – making a double touch occur and both fighters score a point. After that 1/25th of a second – the Epee is locked out (‘lock-out’ time) of being able to score a hit via the box.


2.1.2 The Equipment

2.1.2.1 Score box

Figure 8 – General Fencing Box inputs/outputs

As stated previously in this report, there are 4 main signal lamps involved in the box. 2 contact lights (yellow or white), and 2 hit register lights (Red for left, Green for right). Typically these lamps have a fairly large surface area (10cm²-400cm²), however this is mainly for ‘competition based boxes – which require the ability of the allowing the crowd to see the bout. For the purpose building a practise box, these lamps will be between 5-20cm² (0.05-0.2m²), with a relatively high brightness. So they can be seen across the room.

Notice that there are 2 fencer connections close together on the box, (each side for each fencer), these are 15mm apart, and are the actual weapon connections. The third connection is the connection that goes to either the Lame’ (for Sabre or Foil), or directly to the weapon (for Epee’). This connection is 20mm away from the closest weapon connections.



2.1.2.2 Lame’

This is either the large metallic suit worn by Sabre fencers, or the smaller metallic vest worn by Foil fencers.


This vest is usually either weaved metallic thread, or linked metal rings (similar to chain link, but lighter).

The Lame’ is typically low in electrical resistance (as are the weapons), with a contact between the weapon, and the lame’, typically lower than 5 ohms.

On some of the more complicated competition machines, the resistance value of the Lame’ are checked. This is done so that material of the Lame’ is below FIE standards. If the resistance drops below the regulated standard in these competition boxes, a white ‘warning’ lamp is engaged – displaying the fault (This is also called the fault lamp).

If the weapon is sitting on the Lame’ (say in a defensive position), then the Lame’ is extended to all conducting sections of the weapon in contact with it. E.g. should a fencer rest his weapon guard on his lame’ during a fight; and the opposing fencer hits his guard. This counts as a valid hit.

2.1.2.3 Cables, wires and other accessories

Figure 9 – Fencing Cables, and Connections

Unless for some sabre competitions, all weapons and lame’s are connected to the box via a cabling system. (Under the new 2005 ruling – Wireless systems for Sabre are now allowed).

These cabling systems all run a 3 wire system, with different plugs, and are all rated below 5 ohms. Some have a clear cable sheath – so it is easier to find breaks in the cables.

As stated previously, with foil and sable there are a 2 wires + lame’ clamp (see above) setup. But the epee’ instead has the same connector on both ends, as all 3 leads connect directly to the weapon (right photo).

Distance between weapon pins = 15mm

Distance between weapon pin and lame’ line pin = 20mm


Brief:

Problem:

The New Zealand academy of fencing currently operate a series of old score boxes, that no longer be of use while in training at international level. The international timing standards have changed. The task is to design a setup that will allow, the New Zealand Academy of Fencing to have the current 2005 rules, in a ‘Score box’, to practice on. Either by altering a current box to do this task, or by building a new box.

Current Box:

Figure 10: Current score box (outdated – but not as old as some!)

Specifications:

- The device must be durable.

- The device must be easily built, as multiple versions may be built by people with little electronics understanding.

- The device must be a cheaper alternative than reprogramming the machines.

- The device must be relatively universal.

- The device must be easily upgraded, preferably by someone with relatively little programming experience.

- The device must apply to new international standards (for fencing, AND electrical components)



Change in Timing standards (basic):

- Foil lockout time is to change to 300 milliseconds

- Contact time for foil tip (depressed) is changed to 15 milliseconds

- Sabre lockout is 120 milliseconds

These are essentially the basic rule changes (applied to the electronic score boxes), for international regulations that were applied at the end of 2004.

Contained in the CD in the back of this document is the 2002 and the 2004 rule book for fencing from the FIE.

You can click here. For the 2002 rules, or

Click this for the 2004 rules.

Figure 11 – Where the rule book files are located

Contained on this CD is many (!) files, and it is recommended that the reader familiarises themselves with a lot of the information on it if they need to know more.

It is noticed that multiple DIFFERENT settings will need to be swappable. So therefore a ‘mode’ will be required on the device to swap from epee, foil and sabre.




3.2 Proposed Ideas:

(As taken from proposal version 2.6 – 14/06/05)


Cost:

Cost comes in at a high factor, the reprogramming of the score boxes (if they are the type that can), comes below $250. Replacement score boxes (Low level signalling units), retail at over $US600 – so the should not be too large a problem to keep under budget.

I will plan for a complete budget of $100 for the whole unit (power supply, micro, outputs, and inputs), that way the project can realistically go over budget by 150% before it becomes and expensive operation.

Simplicity:

The device should be a simple as possible, the reasons for this being are:

- If the product is to be replicated, there is a high possibility that the assembler will be someone of a simple technical knowledge.

- If the product fails during the course of its life, it is more usefully if a person with low technical knowledge can fix the device.

- If the program needs to be altered, it is more usefully if a programmer with low programming knowledge can make the alterations.


Hardware:

Hardware Conceptual Ideas:

Because the project now involves building the whole score box, certain aspects must be considered:

  1. Inputs

Fig 12: Pin Connectors from equipment to score box

….. You notice that it is just simple 3 pin connection from equipment (1 for lame’, 1-2 for weapon), between the box. Therefore for the reasons of (a) simplicity, (b) problems using a multiplexer and (c) speed, we will have to use these connections as they are in parallel. Meaning we need at lease 3 (wires) x 2 (fencers) = 6 inputs. These 2 inputs preferably need to be broken into 2 ports (even though they will fit on one) – as this makes the program code easier to understand by others (e.g. PORTA, PORTB – instead of PINA.0-PINA.7 and PINA.0-PINA.7). And this also makes the data direction less confusing.



2. Power Supply

The supplies on the current boxes seem to be either an external supply (9V etc – see left hand side of figure 1), which could be quite easily purchased from Dick Smith, for a relatively low sum of money.

The other option some companies see to do is to use a mains type lead with a D-socket, similar to the one below:

Figure 13: D socket mains power cable

As this D-socket seems to be an international standard, it would probably be a good idea to consider using it.

Computer, switch mode power supplies, similar to the one below:

Figure 14: Computer SMPS

Are a cheap solution that use this type of plug (this one in particular was acquired second hand for NZ$1!!), and offer multiple voltages, at relatively well regulated currents. Their only disadvantages is the aspects a) They require improved capacitance across the inputs (for less distortion), and b) they are rather bulky. However for the test bed application, a SMPS would be a lot better then a regulated source.

Should these options become of no good to the project, then a specialist power supply will be built into the unit, with the specific ratings required for the operation of the circuit.

3: Outputs

Figure 15: box outputs (socket to external scoreboard on top right corner of box)

Most of the current models have a simple light setup (bulb or L.E.D.), indicating hits. Some of the current boxes have integrated 7-segment score boards. Another output that is common is a buzzer, to warn that a hit has been registered.

Initially to start with this project, the outputs be simple L.E.D. setup (probably only one L.E.D. per output in the concept stage), and a buzzer may be integrated into the setup via a Pietzo. A 7-segment will not be considered initially.


Method of CPU

- Microcontroller based

- Analogue/Digital circuit based (including CLPD….)

The problems with doing a Analogue circuit is it removes the accuracy, which is most important (we are dealing with milliseconds), also it is too difficult to adapt to a different situation – this same problem exists in basic Digital systems. In CLPD and other complicated digital systems, the reaction processes are too set, making a device that is not very flexible, where a microcontroller can easily be adapted, or even adapt itself should the circumstance change – perfect for fencing, as quite often (and in a very brief time!), the match can change hands.

What type of microcontroller?

The three major companies considered for microcontrollers were; Atmel, Motorola and PIC. The Motorola type chips were quite unreliable, and apparently difficult to program. Leaving the Atmel and PIC microcontrollers. An off the shelf microcontroller, was wanted. Also it had to be readily available from common electronics enthusiast stores (Dick Smith, Jaycar, RS…). And purchasable in low quantities, for a low price. Both Dick Smith and Jaycar (RS was too expensive for low quantities), stocked both Atmel and PIC micros, but Jaycar had a better range, and Dick Smith looked as most of the micros there were only 20 pin or smaller (apparently Dick Smith have faded out sales of the larger ones). The other requirement of my micro (as stated above), was it needed many ports (24 pin or better), to handle simultaneous inputs and outputs. This scrapped most of the PIC micros as a lot of them could not handle many signals at once, leaving the Atmel’s. Out of the Atmel chips, one stood out: the ATmega16L, it has 32 (+8) pins, large memory (meaning lots of multiple codes)…….and a lot more for less than $30! This chip was perfect, not only because it met (and succeeded) all the set requirements, but it also allowed for expansion for future use.

Hardware development:

This will be in 2 parts:

Pre-development – These concepts will be tested using the concept programs developed. They will most likely be assembled via a breadboard; however a few may make it to tracked-PCB/Vero-board.

Post-development – This will basically be the hardware of the final product, after is has met, and processed the developed software. It will be on PCB format (possibly even boxed ready to go) with corresponding ports and interfaces integrated.



Software


Software Concept:

The Software design will have to be more flexible than the hardware design. It will be broken into smaller components, and these components will be developed and tested individually before becoming a part of the main function.

The main concepts for the software development process of the software are:

- Interrupt approach

- Real Time Operating System

- Polled approach (step-by-step system)

Interrupt:

The Interrupt approach, is when all the programs functions are prompted by a series of interrupts, e.g. something interrupts the main program and does another task. Following this type of programming is relatively easy (but not as simple as polled code), as the code is broken into sections. However, due to the fact the program will be jumping all over the code, extra comments will have to be placed into the code and a full explanation will be required to any future users.

R.T.O.S:

The real time operating system, does just what is says it does. It operates tasks simultaneously, and would be prefect for the speed and performance of such an application. However it is virtually impossible to explain to someone with limited or no programming experience. So for the mean time will not be seriously considered for this specific application, (however this style of scripting, may be required should the project expand).

Polled:

Polled code, is performed in machine type logic. The microcontroller, starts at one point and goes through doing each task one by one, until it finishes – where it restarts again.

The advantage of such code is that it can be followed very easily; even by someone will little programming knowledge.

It is most likely that polled code will be used – as a lot of the tasks the box will be doing will be machine type logic statements.

Software Development:

Once again 2 parts:

Pre-development – These concepts will be attempting the basics with the concept hardware. They will start from a simple concept diagram and structure diagram to commented code. The concept is then pushed through to the development stage where the concepts become more refined.

Post-development-This will be the code(s), with the ability to change between scripts on the micro relatively easy, the code(s) with be explained with full detail and complete, simple, easy to read, diagrams.


3.2 Investigating a Current box


(reverse engineering)


Due to the lack of resources on how these boxes worked, a box was borrowed from NZAF, to see if reverse engineered to find the logic of the system, and how the device worked.

This is a current (and outdated) box at NZAF; it was an old box of Leon Paul origin. The exact date of manufacture – comparing it to other units that look similar – I would estimate it was built around the 1990’s.

Leon Paul has no knowledge of this device, and no records of how it worked…..or they did not wish to disclose this information.

Figure 16 – Current Box

Figure 17 – Old Leon Paul Box

Notice how the white signal lamps are integrated into the red/green, this is actually a disadvantage – as it makes it hard to see the white lamps glow on their own. So every time the lamp glows the bout is stopped to decide which lamp it is.

As stated, power was supplied via mains into the d-shape connector (or alternatively through the 12v inputs on the opposite side).

There was an external connector, which I imagine was to connect to external repeater lights of some sort. Or possibly and external scoreboard.

Figure 18 – L.P. box powered up

The box was powered up to check the voltages coming out of the box weapon connections – when this was compared to another box at NZAF.

If there was a correlation, of high/low voltage levels – this could determine the inputs/outputs of the device (black box testing).

However the voltages levels showed not correlation to each other. So it was concluded that each box (I tested 3 different manufacturers), had its own set principals of design.

Therefore this box was reverse engineered, to see if it could be found how the box worked.

Figure 19 – L.P. Box Internals

Opening the box, it was noticed that the boards were attached to the top of the box, allowing the lower section of the box to be dedicated to the power source (good from a heat perspective). The board itself was powered directly from a 12v supply (either the external 12v supply, or from the regulator).

Figure 20 – L.P. Box supply

When the supply was turned on, it was noticed a large amount of heat was generated by the transformer – however there was ventilation provided under the transformer.

Figure 21 – L.P. Box Sealed Supply

However the boards themselves were well protected by the heat – as a larger insulating cover, sectioned the supply away from the rest of the box. This also stopped the electromagnetic frequency of the supply affecting the inputs into the box (make the scoring systems more reliable).

However this investigation still did not inform me enough of how the device operated. So the boards were looked at more carefully.

Figure 22 – L.P. Box main and secondary boards

The boards were sectioned into a main board, and a CPU.

The CPU seemed to be an outdated, unknown brand, microcontroller (20 pin). The 324PC had virtually no information available about it in many previous suppliers’ websites.

This had virtually all of its pins connected to the board via various current limiting resistors.

Figure 23 – L.P. Box main board, topside

On the topside of the main box, it contained all of the driving components, selectable switches, lamps, logic gates and components.

It was laid out to confuse people – including many redundant components.

There did not seem to be any timing based components – so this box was designed with the old original rules, and the electronics determined hits with the different weapons.

Figure 24 – L.P. Box, fault lamp

So with that thought, the box was tested. Immediately the box signalled a weapon error – so it must be able to read a basic resistance. NZAF confirmed that most of the boxes have these fault lamps. This was quite a significant aspect later on, and changed the whole way the project was approached in the conceptual stage.

Figure 25 – L.P. Box, Registered Hit

The picture above shows what happens when a bout jams up. I initially showed a hit on both sides, then disconnected the weapons and did a valid hit on one side. This showed me that the ‘tap’ and the ‘fault’ lamps are the same thing – but for different periods of time (fault doesn’t turn off), where as the valid hit is a separate light all together.

The box had no timing standard built in. And the looking at the setup of the circuit, each box used a different method to do the fencing scoring.


4.0 Hardware Design


Initial Concept – Buffer system

The initial approach to this project was not to build the whole score box, but to build some form of peripheral, that would allow NZAF (or any one else) – to place 2004 timing updates on their box.

Figure 26 – Initial ‘Buffer’ Concept

The problem that occurred with this, was with the implementing (and overriding) the settings on the score box.

This became obvious, when the lockout time settings were attempted to be implemented into the system. As in lockout, the score box doesn’t allow anymore contacts/hits from the weapons. And it therefore it ignores any signals coming from the weapons after this point.

The problem therefore in placed a buffer (with a smaller lock-out time), is that the box notice’s the weapons as being ‘disconnected’, when the buffer applies its ‘lock-out-time’ – giving a warning lamp on the score box.

This meant that not only did the buffer box have to apply the new settings and check the weapons, but it also had to maintain the signals to the original score box.

Therefore this concept was abandoned, as it would be a lot easier to build a score box with the new timing standards built into it.


4.1 - Design and Setting up the Power Source


Because the device was primarily going to be used as a ‘practice box’, it had to be able run off the mains.

After much thought, it was decided that there was only 3 ways that the device that was going to be designed, was to be powered.

-Via external plug in adapter

-Self contained 230-xx volt adapter

-Computer SMPS.

The Self contained 230-12 or 9v supply was initially consider, then scraped – due to the reason that it would build up too much heat near the device – decreasing the lifetime of the device.

The external plug-in adapter (off-the-shelf), was then considered. But this was found to be inconvenient. As the 230v supply had a ‘D’ type plug on it – not the standard 3 prong plug (which was another disadvantage – as this adapter only exist in New Zealand).

This left the computer Switched Mode Power Supply, of which one was acquired for NZ$1. The advantage of the SMPS, was that it already had the ‘D’ type 230v plug – so therefore did not need to be converted.

However, computer SMPS’s are usually quite unreliable in the aspect that most have a lot of noise, or provide incorrect voltage levels. So therefore the SMPS had to be tested to see if it was suitable for the job.


4.1.1 Basic testing the computer source

Figure 27 – Measuring the SMPS output

The ex-computer, SMPS (switched mode power supply), that was designated for the task of powering the unit was a fairly old unit (date of manufacture – 1996).

Figure 28 – Measuring the 12v/5v rails

But after the voltage was tested, it was found that the ‘hard drive power connectors’, had quite a good voltage level, respectively close to the values stated on the box.

The 5 volt level sat at 5.18 volts, and the 12 volt sat at 11.32 volts.

Figure 29 – Comparing the 0v rails

Since the hard drive connector, ran two 0 volt rails, these too had to be checked – however they were found to be the same voltage, so no drift voltage existed between them.

4.1.2 Adapting the SMPS connector

At this point it was decided that the device was not going to need anymore than 2 voltage rails and a ground rail. This made the ‘hard drive’ type connection perfect for the job.

Figure 30 – Bundling the Connectors

But due to the light power rating of the device being designed – the rest of the connectors were not needed.

All the other connectors were a hazard therefore. And would possibly confuse the device user.

Initially it was considered that I would be a good idea to remove these – but this would remove functionality of the SMPS – should one of these connections be required in the future.

Figure 31 – Sheathing the connectors

So the rest of the connections were bundled together and isolated from where they could have possible caused harm. Also since the device had to be durable (as I was to be in a high impact environment), and sheath was places on the main supply line to prevent cuts exposing the live cable.

Figure 32 – Sheathed adapter cable

A long supply cable then was built, to supply the device. It was built long – as having the SMPS visible (say on a bench top), where I could be exposed to water was a potential hazard. And previously a few fencers have died because the mains have been so close to the score apparatus (which they are conductively connected too).

This too was sheathed.

4.1.3 Final testing

The SMPS then was then tested for noise – as SMPS are typically prone quite badly to noise.

Figure 33 –Checking the SMPS on and oscilloscope

The SMPS was checked for noise via an oscilloscope, and was left to run for 4 hours, to see if the results varied.

Figure 34 – Checking the SMPS connections

It was found that the results did not vary overtime, and the only inconsistency was when the device was turned on or off.


Figure 35 – Noise on 12v rail

The “12v” source ran 11.4 volts.

Figure 36 – Noise on 5v rail

And the “5v” source ran at 5.2 volts.

Both sources were found also to have fairly low amounts of noise as well, only a couple of micro volts (uV peak to peak), and this was typically in the Mega-Hertz (MHz) range.

Therefore the supply was considered satisfactory, and did not require a filter system implemented.

However it was considered that with a 2-3 Volt drop across a regulator, and with the 5v rail actually being 5.2 Volts. That the 5 Volt connection from the supply be scrapped as only 12 Volt supply would be required (this would be regulated to 5 Volts for the microcontroller).


4.2 Signal Lamp Design

Because the signal lamps were going to be the primary output, they required a reasonable amount of time and effort.

This will only be a brief summary of my findings, if you wish to see more about the experimentation I did please refer to the following folder:

Figure 37 – Standard LED’s

Standard (>50mcd) 5mm LED’s, were found not to be suitable, as it would have required 7-15 of them to make a sufficient signal lamp. Even spacing those out various ways did not make sufficient difference.

Figure 38 – 5mm High Intensity LED’s

Therefore the next progressive step was to test using 3000mcd, 5mm LEDs.

While these were better than standard they were too directly intense – and they did not cover sufficient surface area to be considered a ‘lamp’.

It had been decided at this point that a 4 LED/lamp setup would be most appropriate.

Therefore the only logical step was for a bigger LED’s. Completely new to New Zealand at the time was 9-10,000mcd, 10mm LED’s (Jaycar Cat. ZD0202 etc). While these not only offered the surface area required, they also have a good viewing angle (20°).

Figure 39 – 5mm standard/H.I. versus 10mm H.I.

This however all cam at a cost – as these larger/brighter LED’s, take a lot more power then the others.

The red were the most efficient, taking only 2.3-2.6 Volts, and 50-150mA of current.

The green were the most inefficient, not switching on at all unless 3.5 Volts @ 50mA were supplied to them.

This meant that they had to be driven off the 12v rail, with no more than 2 in series.

Figure 40 – 10mm LED lamps

So a 2 in series, 2 in parallel approach was used, and the resistance was setup appropriately for each independent lamp colour.

Figure 41 – Range view 10mm

The final result was a sufficient sized lamp that could be seen across the room.



4.3 Prototype Development Board

The following complications in implementing a microcontroller on a breadboard were found:

- The 10 pin JTAG/ISP connector never had a firm and constant contact when it had wires attached to it.

- The ATMEGA16 did not sit well in either the 40 PDIP holders or the breadboard. Allowing for miss communication with the microcontroller.

- The resonator was frequently picking up stray capacitance of the breadboard.

Therefore development board was produced to allow easier programming/testing of the project before the PCB was produced.

Figure 42 – Prototype development board

The board was designed with the various features:

- JTAG Connection

- In-System-Programmer Connection

- 4MHz Crystal Resonator

- 12v/5v supply connector

- All required ports could be connected to a breadboard via the connector wires.

By building this device it allowed me to interface the microcontroller to the various component setups (see next chapter) and test certain ideas.
4.4 Schematic Adaptation and Development

This is a brief summary of the development that went on, if you wish to understand more why some things were changed – feel free to request my log book.

Alternatively – If you wish to see these files in more detail go to the following directory:

Figure 43 – Where the Protel files reside

Figure 44 – Initial Concept

This was the first serious concept (post understanding the data sheet for the micro).

However following problems exist with this setup:

- There is no voltage regulation to the micro

- No connection to the Piste’ (fencing floor)

- No current limiting resistances

- The ADC pins are left floating

- And the microcontroller cannot sink this amount of current (300mA).

- The reset was set to high – but it triggers low


Therefore the following modifications were made:

- The lamps were driven from transistors (BC546 - npn).

(These transistors were simply used as switches – and were biased only as switches)

- A LM3117 was initially tried, then replaced by an LM7805 to regulate the voltage going into the micro controller.

- A connection to the piste’ was added

- Current limiting resistors were added to the weapon pins

(220 ohm à this corresponds to 15.9mA out of the micro – or worse case scenario 35mA….. lower than the I/O pins rating of 40mA)

- The crystal was replaced with a resonator

(8MHz à as the timing will be in milli-seconds, we will not require faster)

- The ADC pins were tied to various levels

- The input pins on the micro were tied low

(2.2K à 10 x higher than the series resistance)

Figure 45 – Development 1

However this setup too had its faults:

- The decision was made that the only 5v to be on the design was the LM7805 regulated 5 volts, so the external 5 volt supply had to be removed.

- It was discovered that there were buzzers that apparently ran straight of the micro voltage levels (3.3 volts). This would replace the current buzzer setup

- 4/7 pin connectors were not readily available – so a supplement would have to be provided

- There were no current limiting resistors on the output ports to the L.E.D. driver systems.


Development 2:

The following modifications were then made to the circuit:

- Current limiting resistors (220 ohm – same as previous), were placed on port B pins that were connected to the output drivers.

- The 5 volt supply was taken from the 7805 regulator to the various points that required it

- The 7 pin and the two 4 pin connectors were replaced with generic 10 pin ones.

- The buzzer was adjusted to run purely off the micro pins.

Figure 46 – Development 2

Problems that still existed with the updated circuit:

- The ISP (In-System-Programmer) was assumed to be a 4 pin – however the KANDA type programmer that was to be used, was in fact a 10pin connector.

- It was advised that it was a good idea to also include the JTAG connection to the circuit

- Because it was still undecided how the box worked, it was decided that all inputs into port A should have the same resistor setup.

It was at this point that serious experimentation began with the LED driver circuit (See section 4.2).

From this experimentation, it was found that 4 x 10mm, High Intensity (9000mcd) LED’s would be used


Changes in the 3 development of the box:

- LED driver/lamp circuit changed to one tested (in section 4.2)

- ISP connector changed to that in KANDA ISP datasheet (see PDF folder)

- Weapon/Piste’ Connections all get same resistor arrays.

- Moved the weapon selector switch to PORT D so that….

- ….. The JTAG connection could be placed on PORT C.

- Weapon selected, set low, not high – as the inputs are tied high internally.

Figure 47 – Development 3

But this diagram was rather messy as a schematic, so it was decided that the next thing that should be done was to remove the wires connecting everything – and simply create nets.

What else was needed to be changed?

- JTAG connection was incorrect

- Capacitors needed to be placed on the rail power pins of the microcontroller. As this removes a lot the noise from the very sensitive microcontroller. (See design notes, in the MEGA16 datasheet, in the PDF’s folder ß Investigation Media ß Score box CD)


With this version of the box:

- The GND, 12V and 5V rails have all been converted to NETS

- The JTAG connection has been corrected

- 0.1uF Capacitors have been place between the + and ground terminals on the microcontroller – to remove interference

Figure 48 – Development 4

However at this point, it was discovered the whole diagram was in fact incorrect!

The chip in the above drawing is an ATMega16L, but it is the 44pin, surface mount chip.

Therefore not only does the chip have to be replaced (and 2 Vcc pins are removed from the diagram). But some of the other pins also move (like Reset).

This meant that the diagram had to be reshuffled.

Also since the next schematic was to be used for the PCB – the designators on the components had to be changed to make them more suitable for the PCB.

At this point all the resistance values for the Inputs/Outputs had been calculated and tested so they were all defined. The ISP programmer LED had been found that it had to be connected to +5V to operate.

This all lead to the final setup….
Final Result


4.5 PCB

4.5.1 PCB layout

Figure 50 – PCB Layout
4.5.2 Final PCB

Figure 51 – Submitted PCB Diagram

Figure 52 – Received PCB

By following the diagram of the circuit, it was found that not all of the ground planes had been connected properly. This had probably occurred when the ground plane had been adjusted. This was easily fixed by including some jumpers onto the board and allowing them to connect the two planes.

Figure53 – PCB with Jumpers Marked

Figure 54 - Populated Board

Once the board was populated, it was tested to see if all the devices had be connected correctly on the PCB – while there were many faults, these were fixed and retested systematically around the board. This was all done without the microcontroller – which would eventually be tested as well.

Figure 55 – Tested Final board

Figure 56 – Complete assembled board (minus micro)

The final result were signal lamps that were quite nice and bright, and could visibly been seen from a great distance. Also the buzzer was quite nice and loud running at the 5v rail voltage (however the microcontroller would be providing less than that).

All connections seemed to have been made on the PCB.
4.6 Casing

4.6.1 Initial thoughts

Initially the concept was to attempt to find a completely clear Perspex case. However due to supplier problems this was not a good idea. However the box had to be durable and fit the PCB firmly.

Because Black would be good at making the internals of the box dark (and therefore the signal lamps would be more visible), a black box was then considered – along with a combination of a clear lens (Perspex).

If the box was also deeper this also would be an advantage – not only making the box darker (and the lamps seem brighter), but also in the aspect that if I needed to make a secondary board, to fix any corrections, hardware problem or even to upgrade the features of the box this could be done, and hidden underneath the main board and not be visible.

4.6.2 Black Box

The following box was acquired from Surplustronics on Queen Street:

Figure 57 – Black case

If you look closely, you will notice that the PCB is exactly the same size as the box; this meant however that the corners had to be removed from the PCB.

(See figure 54)

Now the lens had to be considered – so that the lamps could be made visible.


4.6.3 Cover 1 (STD box)

Figure 58 – Black case, drilled lid

While this is not blindingly impressive, the main concept of the box is not to look flash – it is to perform its set tasks. And these lamps are still quite visible.

This would be perfect in a situation where a judge or referee is staring directly at the box – as these 9000mcd LED’s have a very intense light if you stare directly at them – so this works more as a diffuser than a lens.

4.6.4 Perspex Cover

Figure 59 – Perspex lens

This makes the unit very aesthetical, and is also very practical – as any physical faults can be seen without opening the box itself.

The intensity of the LED’s may be too intense in some situations – but over all I find this cover is better suited to the role of a score box lens. So the LED’s could be diffused, or some paper/tape could be put on the lens to diffuse the light somewhat.
5.0 Software Design

5.1 Requirements of the Software

The software must process all the input/output signals that are involved in fencing. Compare the data to the new 2004 timing standards for fencing. Then display the appropriate output.

Therefore it must:

Class selection (Epee’, foil, sabre)

- Process which class of fencing is being used, setup and run the appropriate code for that class of fencing, applying the appropriate variable values and checking the appropriate pins for that class.

Training Box (loop mode)

- Be able to continually repeat the code specific for a particular weapon, even if an event (say a valid hit has been landed) occurs. Even if the code has to pause and reset.
5.2 Flow/Logic Diagram

Figure 60 – Program logic flow
5.3 Structure Diagram

Figure 61 – Structure Diagram


5.4 Test code

This is the test code initially designed, it is simply a version of the polled code, with descriptive comments, and however it doesn’t not contain any timing data:



// Score register box for fencing

// Stewart Farr, student id: 0122165,

// cell phone: (021) 298 4184, email: farrst@gmail.com

// Auckland University of Technology, New Zealand

// FIE timing rules, 2005

// header files

#include //this contains all the function prototypes for the Atmel Mega16 chipset

#include // standard input outputs

// definitions

// User Inputs/Outputs

// PORTA

#define lameleft PORTA.0 //sets the left lame at port a pin 0

#define lameright PORTA.3 //sets the right lame at port a pin 3

#define weaponleft1 PORTA.1 //sets the first pin, left weapon, port a pin1

#define weaponleft2 PORTA.2 //sets the second pin, left weapon, port a pin2

#define weaponright1 PORTA.4 //sets the first pin, right weapon, port a pin4

#define weaponright2 PORTA.5 //sets the second pin, right weapon, port a pin5

#define piste PORTA.6 //sets the piste, at port a pin 6

// PORTD

#define epee PIND.0 //epee is select 1 on portd pin 0

#define foil PIND.1 //foil is select 2 on portd pin 1

#define sabre PIND.2 //sabre is select 3 on portd pin 2

// Box Outputs

// PORTB

#define yellowright PORTB.0 //This is the yellow lights on the right fencer

#define green PORTB.1 //This is the green lights

#define yellowleft PORTB.2 //This is the yellow lights on the left fencer

#define red PORTB.3 //This is the green lights

// PORTC

#define buzzer PORTC.0 //sets the buzzer at port c pin 0

// function declaration

Void setup (void); // setup function

// main function

Void main (void)

{

Setup ();

While (1) // continuous loop - so the system keeps going

{

If (epees==0)

{

If (weaponleft1==1)

{

yellowright = 1;

if (lameleft==1)

{

green = 1;

yellowleft = 0;

}

}

else if (weaponright1==1)

{

yellowright = 1;

if (lameright==1)

{

red = 1;

yellowright=0;

}

}

red = 0;

green = 0;

}

else if (foil==0)

{

if (weaponleft1==0)

{

yellowright = 1;

if (lameleft==0)

{

green = 1;

yellowleft = 0;

}

}

else if (weaponright1==0)

{

yellowright = 1;

if (lameright==0)

{

red = 1;

yellowright=0;

}

}

red = 0;

green = 0;

}

else if (sabre==0)

{

if (lameleft==1)

{

yellowleft = 1;

green = 1;

}

else if (lameright==1)

{

yellowright = 1;

red = 1;

}

yellowleft = 0;

yellowright = 0;

green = 0;

red = 0;

}

else // weapon select no weapon

{

while(1)

{

// currently set to error

yellowright = 1;

green = 1;

yellowleft = 1;

red = 1;

yellowright = 0;

green = 0;

yellowleft = 0;

red = 0;

buzzer = 1;

yellowright = 1;

green = 1;

yellowleft = 1;

red = 1;

yellowright = 0;

green = 0;

yellowleft = 0;

red = 0;

buzzer = 0;

}

}

}

}

// setup function, this sets all the timers and ports on the micro

void setup(void)

{

// Port C is the weapon select

DDRC = 0b00000001; // this configures the Port C to receive inputs 0-6,

// and send on the buzzer (PORTC.7)

// Port D is the weapon select and expansion ports for future expansion

DDRD = 0x0F; // this configures the Port D to send outputs

/* Where Port D - Ox0X is the weapon select

pin0 is epee

pin1 is foil

pin2 is sabre*/

// Where Port D - 0xXF is the external buzzer

// If you wish to add a remote to this port, change the F(output) to a 0(input)

// Port A is multi functional, and is the main 'inputs' into the box

DDRA = 0b10010010;

/* This sends one output pin in each weapon, and 2 input pins.....

e.g. PORT A - 0bXXXXX 010 is weapon 1

PORT A - 0bXX 010 XXX is weapon 2

PORT A - 0bX 0 XXXXXX is the piste (mat) which receives and input

PORT A - 0b1 XXXXXXX is the extra pin (o/p) */

// This will change in the full code switching between the weapons (esp. sabre) to check connectivity)

// Port B is the Serial (for downloading the program), and LED output bus

DDRB = 0xF0;

/*PORT A - 0xFX LED drivers, (pin0 yellow right), (pin1 green),

(pin2 yellow left), (pin3 red)*/

//PORT A - 0xX0 SPI/ISP bus

yellowright = 0; //yellow lights on the right fencer low

green = 0; //green lights low

yellowleft = 0; //yellow lights on the left fencer low

red = 0; //green lights low

weaponleft2 = 1;

weaponright2 = 1;

// This will change in the full code switching between the weapons (esp. sabre) to check connectivity)


}




5.5 Final Code

5.5.1 Development of final code

This was then combined with the code I had previously studied/created (See “Polled Reaction Timer” - Investigation mediaàReaction Timeràpolled.c). Using the elements of the timing setup in this to help me setup the timing in the mega16.

Figure XXX – File directory to Polled code.

This is currently under testing at the of this report being published.

The problem that existed with the code, was not actually to do with the code - more with the fact that there was no way to test it during debugging.

This was remedied recently with the creation of some mock weapons:

Figure


7.0 Conclusion

7.1 Possible Future Developments with the designed box



8.0 References



http://www.inet.hr/~tdedic/fencing.htm

- Brief Summary of Fencing

www.jaycar.co.nz

- Component Purchasing

www.dicksmith.co.nz

- Component Purchasing

www.farnell.co.nz

- Component Purchasing

www.microcontrollershop.com

- Microcontroller and related component purchasing and research

www.leonpaul.com

- Fencing equipment manufacturer

- Fencing forum

- Armoury Information

http://www.favero.com/

- Fencing equipment manufacturer

http://www.fie.ch/Welcome.aspx

- Fencing ruling body

http://www.triplette.com

- Fencing Equipment Store

http://www.physicalchess.com/

- Sports Equipment Store

www.olimex.com

- Microcontroller Suppliers

- Helpful information on JTAG connections

www.ausfencing.org

- Australian Fencing body

- Armoury

http://eweb.chemeng.ed.ac.uk/jack/radio/projects/resnote3.html

- Helpful points on implementing resonators instead of crystals.

www.microcontrollershop.com

- Microcontroller Supplier

- Helpful information on In-System-Programmer connections

www.piclist.com

- Helpful hints on what clock to use



9.0 Enquiries and Correspondence

All enquiries related to papers, documents, or device related to this development, at any stage of preparation, review and publication to:

Stewart Farr

3/23 St Albans ave

Mt Eden

Auckland 1003

farrst@gmail.com

+64 21 298 4184

+64 9 623 3671




10.0 Appendix CD

<>



www.farrst.blogspot.com