As the title of this article may suggest, I thought it might be interesting to see what mathematical knots I could tie myself in once I begin to remove modelling assumptions from a seemingly-simple physical system. The answer, somewhat predictably, is very very many indeed.
This all stems from some work on differential equations I did over the Christmas period, where I first came into contact with the idea of modelling resistive forces as a function of a differentiated variable (acceleration usually). After doing a physics PAG (assessed practical) on determining the terminal velocity of a cupcake case falling under acceleration due to gravity in October, I realised how interesting an investigation into exactly how the object accelerates between t = 0 and terminal velocity could potentially be and with a new mathematical skillset, I began to do some scribbling...
Several months later, with some on-and-off periods of work on the paper, I have come up with this 48-page pdf file documenting how I have somewhat tangentially approached ideas such as drag and restitution with a certain level of naivety. It has not been extensively proof-read, so is most definitely an unpolished version which serves to demonstrate how I have leapt from one problem to the next, and no doubt errors will be inherent in some of my working as a result. Nevertheless, I am immensely proud of some of the derivations, as well as my real-life experiments to test them.
The following list contains all the external links to Desmos graphs, which feature throughout the document:
p13 - http://www.tinyurl.com/hmdd5jc - CTDM
p20 - http://www.tinyurl.com/jezmcxo - light-gate data
p30 - http://www.tinyurl.com/za2cq2f - multiple cycles of the CTDM in a bouncing-ball situation
p31 - http://www.tinyurl.com/hncm9su - fragility of the CTDM
p32 - http://www.tinyurl.com/grd873b - stability of the SQTM
p36 - http://www.tinyurl.com/hl32bt2 - collision impulse and force
p47 - http://www.tinyurl.com/jrmk6ye - strobe data and restitution
Introduction
I begin the investigation with some theoretical modelling - first I take drag to be proportional to velocity, then velocity squared and finally velocity cubed. After this, I investigate how a model could be developed containing both a linear and a quadratic term in v, called the combined term drag model (CTDM). Next, I conduct some experiments with falling objects: one such experiment involves a custom-made tube of 10 phototransistor-LED light gates to observe in detail how a falling muffin-case's displacement varies with time; another determines the spring constant of the average tennis ball; another uses a strobe-light and a long-exposure camera setting to collect displacement-time data for a bouncing tennis ball. I use all this data to test the efficacy of the various models, with a good deal of running commentary and analysis.
The paper can be found here: https://www.dropbox.com/s/bgdq0vwqa0wumxp/PAPER.pdf?dl=0
Welcome to my world
Here is my domain for splurging my ruminations on the STEM fields. Most of the stuff I discuss and research on this site is way beyond what we learn at school and what I am conventionally taught, so there may well be errors in my information or maths - please do not viciously troll the page with corrections, although constructive and useful criticism is of course welcome :)
Sunday, 20 March 2016
Sunday, 28 February 2016
An intermediate attempt at modelling interference graphically
This modelling work, which I have spent most of my weekend developing, stems from a very simple question which came up in my AS physics textbook, on the topic of wave interference. It went something along the lines of "Draw 6 diagrams, 1 second apart, to show how these two approaching waveforms interfere". I was surprised at how difficult it was to faithfully do this, even with two simple waveforms in wide discrete time jumps and it got me thinking - how could I use a computer to do this better? The result is in an 8-page investigation, where I have endeavoured to develop some theory about how to model passing and reflecting waves and how they interfere - it begins easy, with some simple linear interference by summation of instantaneous displacements, but soon I found that the mathematics became more complicated (particularly in stage 3, where I began to model how waves slowly escape from a trap, like a solid-state laser but without the quantum stimulated emissions).
I have tried to explain myself fully throughout, although not enough proof-reading has been done to keep it from being a little haphazard, and the last page of the document requires some following-up when I have a little more time. However, I am pretty proud of some of the derivations.
In the paper, I have referenced some equations with numbers in square brackets. These match-up with equations on the corresponding Desmos file (here: http://tinyurl.com/zlmzg9d), to illustrate exactly what each equation looks like in practice.
The paper can be found here: http://tinyurl.com/zwegna4
I have tried to explain myself fully throughout, although not enough proof-reading has been done to keep it from being a little haphazard, and the last page of the document requires some following-up when I have a little more time. However, I am pretty proud of some of the derivations.
In the paper, I have referenced some equations with numbers in square brackets. These match-up with equations on the corresponding Desmos file (here: http://tinyurl.com/zlmzg9d), to illustrate exactly what each equation looks like in practice.
The paper can be found here: http://tinyurl.com/zwegna4
Sunday, 7 February 2016
Refraction in the third spatial dimension
In my AS Physics classes, we have reached the wave mechanics point of the course - one of the most fundamental observable properties of waves travelling through media of differing densities is refraction; however, we only ever seem to consider refraction in a coplanar sense (where there is only an incident angle against the plane of the boundary in two dimensions). My investigation of the morning is to develop a little theory, which will hope to extend my understanding of refraction to apply to the third dimension, which up until this point in my education has been ignored.
Firstly, let's review Snell's law. This states that the product of the refractive index of one medium and the sine of the angle in that medium against the normal is constant throughout the refraction process. In algebraic terms:
This provides the basic relationship between the two angles on the diagram below, which demonstrates the coplanar refraction I am talking about:
Similarly, I could represent the effect of refraction on the third-dimension in the same way, by reducing the problem into a coplanar one and ignoring the second dimension in the above example. However, considering all three dimensions at once will involve some basic vector geometry. The direction of the light ray, where the perspex-air boundary is an arbitrary straight line with the equation x = C, can be represented by a 3-D vector U:
This vector can then be divided into two components, dealing with different planes - the x-y plane and the x-z plane. The angle in the y-z plane is irrelevant because it is parallel to the boundary plane. I have worked through this problem, and here is my result:
From here, I used Desmos graphing calculator to demonstrate the result of this. I spent much time working with the z-axis, trying to produce the most convincing one possible by adjusting the positions of the x and y axis, all parametrically under the control of the rotation parameters A, B and C. I had some success with this, using the sinusoidal nature of rotational perspective to produce a set of coordinate axes which can be rotated about the origin (i.e. the real z-axis) in the x-y plane, and the image of the x-axis, allowing enough movement to achieve most angles on any 3-D subject. A current demonstration of this somewhat rudimentary and flawed model can be found here: http://tinyurl.com/hk4d3l7. In the future, I hope to be able to understand how not only full rotational freedom can be achieved through the parameters A, B and C, but also how I can faithfully project real points (x,y,z) onto these simulated axes while they can stand up to rotation.
However, since I have yet to truly crack the matter, I have for now settled with a simple pseudo-z-axis. However, it still demonstrates my mathematics fairly well. Furthermore I have paid attention to detail diagrammatically by programming Desmos to draw proportional arrows for the magnitudes of each component ray, as well as the resultant incident and refracted rays. The online version can be found here: http://tinyurl.com/jthre74.
Overall, I feel I have opened a metaphorical can of worms for myself when it comes to the true complexities of this physical phenomenon. Further research has yielded information regarding Fresnell's equations for transparent materials, which determine the relative amplitudes (and hence intensities) of reflected and refracted light at such a boundary between two media, which could be programmed into the graphing calculator. Also, I could isolate the mathematics from the assumption that the boundary is parallel to the y-z plane, such that refraction and reflection on a 3-D surface of differential-determined gradient could be modelled. Perhaps a follow-up to this will be required in the future.
Firstly, let's review Snell's law. This states that the product of the refractive index of one medium and the sine of the angle in that medium against the normal is constant throughout the refraction process. In algebraic terms:
This provides the basic relationship between the two angles on the diagram below, which demonstrates the coplanar refraction I am talking about:
Similarly, I could represent the effect of refraction on the third-dimension in the same way, by reducing the problem into a coplanar one and ignoring the second dimension in the above example. However, considering all three dimensions at once will involve some basic vector geometry. The direction of the light ray, where the perspex-air boundary is an arbitrary straight line with the equation x = C, can be represented by a 3-D vector U:
From here, I used Desmos graphing calculator to demonstrate the result of this. I spent much time working with the z-axis, trying to produce the most convincing one possible by adjusting the positions of the x and y axis, all parametrically under the control of the rotation parameters A, B and C. I had some success with this, using the sinusoidal nature of rotational perspective to produce a set of coordinate axes which can be rotated about the origin (i.e. the real z-axis) in the x-y plane, and the image of the x-axis, allowing enough movement to achieve most angles on any 3-D subject. A current demonstration of this somewhat rudimentary and flawed model can be found here: http://tinyurl.com/hk4d3l7. In the future, I hope to be able to understand how not only full rotational freedom can be achieved through the parameters A, B and C, but also how I can faithfully project real points (x,y,z) onto these simulated axes while they can stand up to rotation.
However, since I have yet to truly crack the matter, I have for now settled with a simple pseudo-z-axis. However, it still demonstrates my mathematics fairly well. Furthermore I have paid attention to detail diagrammatically by programming Desmos to draw proportional arrows for the magnitudes of each component ray, as well as the resultant incident and refracted rays. The online version can be found here: http://tinyurl.com/jthre74.
Overall, I feel I have opened a metaphorical can of worms for myself when it comes to the true complexities of this physical phenomenon. Further research has yielded information regarding Fresnell's equations for transparent materials, which determine the relative amplitudes (and hence intensities) of reflected and refracted light at such a boundary between two media, which could be programmed into the graphing calculator. Also, I could isolate the mathematics from the assumption that the boundary is parallel to the y-z plane, such that refraction and reflection on a 3-D surface of differential-determined gradient could be modelled. Perhaps a follow-up to this will be required in the future.
Sunday, 31 January 2016
The Simplex Algorithm
This rather complex algorithm was the latest subject in my Decision Mathematics 2 course at school. It involves taking a linear programming problem, and solving it without the need for graphical methods - the beauty of this is that it allows the logic to be extended to higher-dimensional problems which cannot easily be represented on multidimensional Cartesian coordinates. In fact, there is theoretically no limit to the number of variables that can be dealt with!
Anyway, the most important reason for the existence of the Simplex algorithm, as I see it, it that it can be more easily programmed into a computer. So this is what I did!
My C++ skills would seem rudimentary to a seasoned programmer, since I became a novice programmer several years ago and haven't touched an IDE since, but I'm quite pleased with the result of these 692 lines of code. It may spring bugs, but I have tested my version of the algorithm on the majority of the problems in the D1 and D2 textbooks and the results have been successful. This has allowed me to build on the pretty shocking SIMPLEX 1.0, developing a more robust SIMPLEX 2.0.
The various files can be found on my Dropbox:
- DevCPP source/project file (http://tinyurl.com/h7ck5ow)
- Readme in a text-file (http://tinyurl.com/gr4r56x)
- Executable SIMPLEX 2.0 file (http://tinyurl.com/zo8hbat)
Since the program is freshly programmed, it is likely that there will be faults in the code. Any error reports would be welcomed.
Anyway, the most important reason for the existence of the Simplex algorithm, as I see it, it that it can be more easily programmed into a computer. So this is what I did!
My C++ skills would seem rudimentary to a seasoned programmer, since I became a novice programmer several years ago and haven't touched an IDE since, but I'm quite pleased with the result of these 692 lines of code. It may spring bugs, but I have tested my version of the algorithm on the majority of the problems in the D1 and D2 textbooks and the results have been successful. This has allowed me to build on the pretty shocking SIMPLEX 1.0, developing a more robust SIMPLEX 2.0.
The various files can be found on my Dropbox:
- DevCPP source/project file (http://tinyurl.com/h7ck5ow)
- Readme in a text-file (http://tinyurl.com/gr4r56x)
- Executable SIMPLEX 2.0 file (http://tinyurl.com/zo8hbat)
Since the program is freshly programmed, it is likely that there will be faults in the code. Any error reports would be welcomed.
Sunday, 13 December 2015
GCHQ's Christmas puzzle and cryptography
WARNING
This post will contain some spoilers for the puzzle, although I will remain fairly vague - if you are trying to solve all 5 levels without any help from other solvers (indeed like I am trying to do), close this page now. To be honest though, this website is so obscure that nobody will read this until long after the contest has passed! I was very disappointed to find that there is a public Reddit community solving this puzzle by crowdsourcing, not because it is strictly cheating (I think it is an efficient and smart way to tackle the problem) but because I cannot easily conduct research on the cryptic puzzles without stumbling upon other people's solutions, ruining the fun of the challenge. However, trying my best to refer only generally to my current solutions, I must continue writing since this intelligent series of tasks has got me so excited and gripped!
My progress
So far, I have spent most of my Friday at school solving the first puzzle (the shading grid); then I solved the "not odd one out", "weird semaphore message" and "D, D, P, V, C, C, D," problems from stage 2 without help, and with the combined knowledge of my family completed the stage today. There is no prize for noticing that there is a strong emphasis on cryptography within these puzzles, using obscure systems such as hand-signals, morse code, ASCII, phonetic alphabet and even snooker balls colours, and it is this that has prompted me to write this article this evening.
The first problem
I was particularly excited by this, which was shown to be by a friend at school: using the enigmatic numbers on each row and column, one has to fill in the black squares and hence form a QR code, which will direct the player to the next challenge.
The QR code is a very efficient method for encoding information within an image, as a binary matrix of black and white. Although they appear simple enough as what is effectively a two-dimensional barcode, there was a huge amount of development and engineering that went into their perfection - such information was very useful in starting-off the puzzle. For example, there is always a position-fixing square in three of the four corners of the grid (excluding the bottom right), which pins-down a single rotational orientation of the code, a timing column and a timing row which help the reading device get its bearings on the matrix. The puzzle presented to us by GCHQ takes the form of a version 2 QR code, containing 25x25 bits: in this way we are reminded that this is only a beginner task, since the version 40 QR code can hold over a thousand ASCII characters and is 177x177 bits!
Information is not simply stored in rows from left to right, top to bottom, with black as 1 and white as 0 though - to avoid confusing the scanner, which in modern-day usage could be a low-resolution and slightly dirty/moist lens from a low-end smartphone, "masking" has to be employed to avoid the code producing large areas of black or white (which would start to hide the discreteness of the bits), or structures which emulate the tracking squares. Such masking algorithms could include changing which colours represent 1 and 0 depending on their position within the matrix, or entering the data in a non-linear fashion. Such "encoding modes" are represented by a number, which sits somewhere in the QR image.
I was especially intrigued, when sifting through the highly informative but also extremely technical Wikipedia page which forms the source of the past few paragraphs [1], to see how scientists/mathematicians have endeavoured to extend the functionality and capacity of QR codes to store ever more information. For example, coloured QR codes (which with greater bit densities we would regard as "pictures") with 4 or even 8 hues would allow much more data to be stored in the same space, since each colour could represent a longer string of "offs" and "ons" such as 101 and 110. However the difficulties in incorporating such functionality are quite clear: error-correction would be much more complex, since the contrast between adjacent colours would be lessened so scanners would be more easily confused, and version 40 matrices seem out of the question currently because with high bit density a dithering effect (as utilised by 16777216-colour RGB screens) would be observed.
My suggestion for an improvement to QR codes takes inspiration from recent developments in quantum computing, a field which relies on the existence of superposition to create complex "qubits". The fact that a single unit of information can now take the form of "on", "off" or "on-off" proves very interesting for the cryptography world in my eyes - what if the squares of the QR grid could be fully black, fully white or diagonally half-and-half? This would allow the "separators" (white regions between the tracking squares and the formattable area) and "timing strips" (two standard alternating lines) to stand out more, as well as increasing the potential data-storage power without deviating from binary colours (which cannot be confused in any lighting).
The issue I can see with this concept though is that the half-and-half squares, when viewed from a distance or when very small, would blur into a grey due to diffraction on the lens or the limit of the camera's resolution. However, zooming in too much and making the bits too large would limit the amount of information which could be captured in one snapshot! Therefore there must be an optimum bit size between these two extremes, which would maximise storage on the QR code. Without a thorough investigation it would be a sensible supposition that this optimum, taking into account the technicalities of error-compensation, is reached with a version 40 177x177 grid!
Thank you GCHQ
I feel it is only appropriate to give my sincerest thanks to GCHQ for their brilliant puzzle series this year - I am feeling extremely frustrated on the third level right now, but it sure is better than it being too easy! I really don't want to ruin the puzzle for other players, but I am also extremely proud of the progress my family and I have made through the challenge so far - therefore I will be posting the reasoning behind my answers in a separate article, which cannot be accessed through google and will not show up on my homepage (only through this link).
Sources
[1] Wikipedia - "QR Code" - here
This post will contain some spoilers for the puzzle, although I will remain fairly vague - if you are trying to solve all 5 levels without any help from other solvers (indeed like I am trying to do), close this page now. To be honest though, this website is so obscure that nobody will read this until long after the contest has passed! I was very disappointed to find that there is a public Reddit community solving this puzzle by crowdsourcing, not because it is strictly cheating (I think it is an efficient and smart way to tackle the problem) but because I cannot easily conduct research on the cryptic puzzles without stumbling upon other people's solutions, ruining the fun of the challenge. However, trying my best to refer only generally to my current solutions, I must continue writing since this intelligent series of tasks has got me so excited and gripped!
My progress
So far, I have spent most of my Friday at school solving the first puzzle (the shading grid); then I solved the "not odd one out", "weird semaphore message" and "D, D, P, V, C, C, D," problems from stage 2 without help, and with the combined knowledge of my family completed the stage today. There is no prize for noticing that there is a strong emphasis on cryptography within these puzzles, using obscure systems such as hand-signals, morse code, ASCII, phonetic alphabet and even snooker balls colours, and it is this that has prompted me to write this article this evening.
The first problem
I was particularly excited by this, which was shown to be by a friend at school: using the enigmatic numbers on each row and column, one has to fill in the black squares and hence form a QR code, which will direct the player to the next challenge.
The QR code is a very efficient method for encoding information within an image, as a binary matrix of black and white. Although they appear simple enough as what is effectively a two-dimensional barcode, there was a huge amount of development and engineering that went into their perfection - such information was very useful in starting-off the puzzle. For example, there is always a position-fixing square in three of the four corners of the grid (excluding the bottom right), which pins-down a single rotational orientation of the code, a timing column and a timing row which help the reading device get its bearings on the matrix. The puzzle presented to us by GCHQ takes the form of a version 2 QR code, containing 25x25 bits: in this way we are reminded that this is only a beginner task, since the version 40 QR code can hold over a thousand ASCII characters and is 177x177 bits!
Information is not simply stored in rows from left to right, top to bottom, with black as 1 and white as 0 though - to avoid confusing the scanner, which in modern-day usage could be a low-resolution and slightly dirty/moist lens from a low-end smartphone, "masking" has to be employed to avoid the code producing large areas of black or white (which would start to hide the discreteness of the bits), or structures which emulate the tracking squares. Such masking algorithms could include changing which colours represent 1 and 0 depending on their position within the matrix, or entering the data in a non-linear fashion. Such "encoding modes" are represented by a number, which sits somewhere in the QR image.
I was especially intrigued, when sifting through the highly informative but also extremely technical Wikipedia page which forms the source of the past few paragraphs [1], to see how scientists/mathematicians have endeavoured to extend the functionality and capacity of QR codes to store ever more information. For example, coloured QR codes (which with greater bit densities we would regard as "pictures") with 4 or even 8 hues would allow much more data to be stored in the same space, since each colour could represent a longer string of "offs" and "ons" such as 101 and 110. However the difficulties in incorporating such functionality are quite clear: error-correction would be much more complex, since the contrast between adjacent colours would be lessened so scanners would be more easily confused, and version 40 matrices seem out of the question currently because with high bit density a dithering effect (as utilised by 16777216-colour RGB screens) would be observed.
My suggestion for an improvement to QR codes takes inspiration from recent developments in quantum computing, a field which relies on the existence of superposition to create complex "qubits". The fact that a single unit of information can now take the form of "on", "off" or "on-off" proves very interesting for the cryptography world in my eyes - what if the squares of the QR grid could be fully black, fully white or diagonally half-and-half? This would allow the "separators" (white regions between the tracking squares and the formattable area) and "timing strips" (two standard alternating lines) to stand out more, as well as increasing the potential data-storage power without deviating from binary colours (which cannot be confused in any lighting).
The issue I can see with this concept though is that the half-and-half squares, when viewed from a distance or when very small, would blur into a grey due to diffraction on the lens or the limit of the camera's resolution. However, zooming in too much and making the bits too large would limit the amount of information which could be captured in one snapshot! Therefore there must be an optimum bit size between these two extremes, which would maximise storage on the QR code. Without a thorough investigation it would be a sensible supposition that this optimum, taking into account the technicalities of error-compensation, is reached with a version 40 177x177 grid!
Thank you GCHQ
I feel it is only appropriate to give my sincerest thanks to GCHQ for their brilliant puzzle series this year - I am feeling extremely frustrated on the third level right now, but it sure is better than it being too easy! I really don't want to ruin the puzzle for other players, but I am also extremely proud of the progress my family and I have made through the challenge so far - therefore I will be posting the reasoning behind my answers in a separate article, which cannot be accessed through google and will not show up on my homepage (only through this link).
Sources
[1] Wikipedia - "QR Code" - here
Monday, 12 October 2015
Clocks, piezoelectric crystals and logic gate solutions - part 2
To understand the full premise of this project, it may be useful to read the first part of this blog post, here.
The first thing one might notice is that there are in fact no solenoids in this model - within the constraints of the program, data can be outputted as a lightbulb or a binary-configured digit, so I chose the former of the two. Another thing is that, since a lightbulb has only two states ("on" and "off"), there cannot be room for the three solenoid states of "positive", "neutral" and "negative": however, assuming that we are looking at the negative end of the rotor, the negative solenoid state is merely used to achieve a higher torque, so it can be dismissed here - therefore in this model, "on" represents "positive", and "off" represents "neutral". The full working of the circuit is below, through its 4 states.
Clearly the solenoid configuration changes every second, controlled by the four AND gates. However whether this translates into a tick every second depends on the number of teeth on the rotor and stator - in the previous post I found that a 30-28 motor that turns by rotating the field 45° will move 30 rotor teeth in 120 rotations, so the clock could instead take an input of 1Hz in order to turn 360° in 60 seconds. This would involve using only 15 flip flops in the frequency division of the 32768Hz quartz oscillator, as opposed to the implicit 16 here.
The next section is optional, as you may well understand exactly how I have reached this result with the gates. If so, click here to jump to the next part of the post.
Next I produced a truth table for the circuit so far, plotting the discrete time intervals of the "clock" against the values of "Clock", "NOT-Clock", "T" and "NOT-T":
This doesn't seem to throw any light upon the situation, but placing 4 AND gates in certain combinations does:
From here we have a situation where one, and only one, AND gate produces a logic 1 output in each second. These can be hooked up to sequential opposite pairs of lightbulbs to produce the desired pattern shown in the video.
The explanation is very complex for this, so the next part is again optional.
Experimenting with logicly
Logicly, the demo for which can be found here, is a very useful logic gate simulator which can allow you to create complex logic systems without the need for electrical engineering level knowledge of using hundreds of transistors and resistors correctly. My first task with this simulator is to emulate a stepping motor, by using the gates to control which solenoids have a voltage when. This was a fairly simple affair, involving only one flip flop and nine gates. The "circuit" is pictured below.The first thing one might notice is that there are in fact no solenoids in this model - within the constraints of the program, data can be outputted as a lightbulb or a binary-configured digit, so I chose the former of the two. Another thing is that, since a lightbulb has only two states ("on" and "off"), there cannot be room for the three solenoid states of "positive", "neutral" and "negative": however, assuming that we are looking at the negative end of the rotor, the negative solenoid state is merely used to achieve a higher torque, so it can be dismissed here - therefore in this model, "on" represents "positive", and "off" represents "neutral". The full working of the circuit is below, through its 4 states.
Clearly the solenoid configuration changes every second, controlled by the four AND gates. However whether this translates into a tick every second depends on the number of teeth on the rotor and stator - in the previous post I found that a 30-28 motor that turns by rotating the field 45° will move 30 rotor teeth in 120 rotations, so the clock could instead take an input of 1Hz in order to turn 360° in 60 seconds. This would involve using only 15 flip flops in the frequency division of the 32768Hz quartz oscillator, as opposed to the implicit 16 here.
The next section is optional, as you may well understand exactly how I have reached this result with the gates. If so, click here to jump to the next part of the post.
FULL EXPLANATION OF THE CIRCUIT [OPTIONAL]
The "clock" here gives an output of 0.5Hz, meaning that a logic 1 is pulsed for a 1 second duration, starting every 2 seconds. This will be fed into a buffer, passing on the value of the clock at any given time, and a NOT gate which will pass on the inverse of this. In addition the "clock" will act as the clock for the T flip flop - since the PRE' and CLR' functions are negative-edge triggered, I have disabled the former by attaching it to a logic 1 input, and made the clear function operable by connecting the output of a push button to a NOT gate (i.e. the negative edge will occur when the button is pressed, acting as a reset function); the flip flop is in toggle mode, since the T input is connected to logic 1. The Q output of the flip flop, just like the "clock", is fed into a buffer and a NOT gate to form "T" and "NOT-T".Next I produced a truth table for the circuit so far, plotting the discrete time intervals of the "clock" against the values of "Clock", "NOT-Clock", "T" and "NOT-T":
This doesn't seem to throw any light upon the situation, but placing 4 AND gates in certain combinations does:
From here we have a situation where one, and only one, AND gate produces a logic 1 output in each second. These can be hooked up to sequential opposite pairs of lightbulbs to produce the desired pattern shown in the video.
"Stepping" it up a notch
Without alternative output options on the simulator, I have reached the end of what I can do with analog clocks. However, since a digit is the other output option, there is a wealth of potential within the realm of the digital clock. A huge amount of experimentation and tweaking, plus some attempts to make the whole circuit neater and more logically structured, has led to the creation of my basic 24-hour clock system, shown below.FULL EXPLANATION OF THE CIRCUIT [OPTIONAL]
This circuit is clearly more complex, and will take a huge amount of explaining: we will start with the far right hand of the circuit and work our way back. I have tried to make the diagram more clear by isolating the circuitry for each digit into blocks, but to be honest it still made a fairly unavoidable tangle...
Digit 1
The input comes from the 0.5Hz clock, the NOT value of which forms the first binary input of the digit. This clock is also used to trigger the (2^-2)Hz flip flop, the inverse output of which forms the second binary clock input. The Q output of the flip flop feeds into the next flip flop, and the process repeats for (2^-3)Hz and (2^-4)Hz. The most annoying thing about these digits is the same thing that makes them so convenient - they are binary. Since the number of possible numerical outputs follows the function n = 2x (where x = number of digit inputs), there must be 4 pins to allow all the numbers from 0-9 to be displayed (2 cubed is only 8). Unfortunately this also generates a surplus of 6 characters (A-F), so using the flip flops as they are causes the digit to count from 0 to F before resetting to 0. We only want 0-9, so some jiggery-pokery is required. I have therefore created a test, comprised of an OR gate, an AND gate and a NOT gate, which will tell when the character A is reached and will instead reset all the flip flops to 0. The OR gate returns a logic 1 if output 2 or 3 is logic 1, and the AND gate will return a logic 1 if the OR is 1 and output 4 is 1. In this case, the NOT gate will return a 0. The additional AND gate below it will allow the reset to occur either in this eventuality, or if the master reset button is pressed. The result of their of these cases is that the negative-edge triggered PRE' functions on each flip flop will be fed with a short pulse of logic 0, resetting every flip flop back to 0. The test on outputs 2, 3 and 4 works because every number higher than 9 (i.e. A-F) will have output 4 on, and either outputs 2 or 3 on too.
Digit 2
Digit 2 is fed the Q output from (2^-4)Hz to form the clock input for (2^-5)Hz. The same chain of events, which acts as an extended frequency divider circuit, will occur for digit 2. However there are 60 seconds in a minute, so we only want digit 2 to count from 0 to 5 - this involves a different version of the reset test explained earlier, comprised of 2 AND gates, an XOR gate and a NOT gate. The first AND gate will return 1 only if outputs 6 and 7 are both 1. The XOR gate will only return 1 if only one of outputs 5 and 6 are 1. The second AND gate will only return 1 if both the first AND gate and the XOR gate are 1. In this case, which has tested when the binary 0110 is reached (decimal 6), the NOT gate will return a value of 0, negative-edge triggering the PRE' functions for the four flip flops associated with digit 2, resetting them to 0 as before.
Digit 3
This digit has exactly the same wiring as digit 1, but has four flip flops because we do not have the benefit of the 0.5Hz clock input providing a 'free' output. The clock input to (2^-9)Hz is the Q output of (2^-8)Hz.
Digit 4
Since there are 60 minutes in an hour, this digit has the same wiring as digit 2, but takes the Q output from (2^-12)Hz as the clock input of (2^-13)Hz.
Digit 5
Things get even more funky here, because this digit will be required to tick from 0-9 twice (in 00-09 hours and 10-19 hours), then only 0-3 the third time (in 20-23 hours), before resetting to repeat the pattern. For this I have started by employing the reset-after-9 test, then I will return to this digit once I have built digit 6. Remember that the clock input for (2^-17)Hz is the Q output of (2^-16)Hz!
Digit 6
This digit is much more simple, because it only needs to tick 0-2 before resetting to zero. Therefore only two flip flops are required, and outputs 23 and 24 can be fixed at logic 0. As usual, the clock input for (2^-21)Hz is the Q output of (2^-20)Hz. The 0000 reset test for digit 6 involves testing for the binary 11 over outputs 21 and 22, which can be done with a single AND gate. In this case, the NOT gate will return a logic 0 which will negative-edge trigger the PRE' functions of the two flip flops associated with digit 6. A final test needs to be constructed as well though, to deal with the digit 5 irregularity - I have made a test for the situation where output 21 is logic 0 and output 22 is logic 1, using 2 XOR gates and an AND gate, which is fairly self explanatory when you look at the diagram. The creation of a logic 1 when both conditions are met feeds back into another AND gate at digit 5 - this will return 1 only if the digit 6 test is logic 1, and an OR gate comparing outputs 23 and 24 returns logic 1. In this case, the NOT gate will return 0, and this result feeds into a 3-input AND gate later on. This 3-input AND gate allows the PRE' functions to be triggered when the above conditions are met, when the master reset is pressed or if digit 5 reaches A in a [(digit 6) ≠ 2] situation.
I hope this makes my circuit easier to understand, but I imagine my explanation leaves something to be desired!
Sunday, 11 October 2015
Clocks, piezoelectric crystals and logic gate solutions - part 1
Lying in bed at night, I find myself considering exactly how the cheap analog clock in front of me keeps such perceivably accurate time, day after day and night after night. The only thing which can halt the unstoppable passage of the ticking hands is the slow discharging of the battery - but how does the input of voltage lead to a constant and reliable motion, which doesn't degrade as the voltage of the battery slowly decays?
Piezoelectric crystals
The piezoelectric effect describes how the application of mechanical stress to certain crystalline materials can generate a small electric current - the pressure causes the positive and negative charge centres to move, with the result that a weak external electric field is created. Early experiments showed that the effect was exhibited in a variety of natural crystals including cane sugar, topaz and quartz, with more recent developments augmenting this range with man-made structures including barium titanate (BaTiO3) and lead zirconate titanate (Pb[ZrₓTi₁₋ₓ]O₃). [1]
As an aside, the latter of these two compounds is classified as an "intermetallic compound", a curious label which means that metallic bonding occurs with defined stoichiometric ratios (i.e. for x lead atoms there are y zirconium and z titanium atoms, and for 2x lead atoms there are 2y zirconium and 2z titanium atoms) - within mainstream education I have never heard of such materials which form quasi-ionic lattices, so I find this very interesting. In the case of lead zirconate titanate, the chemical formula implies that for every lead atom there are x zirconium atoms, (1-x) titanium atoms and 3 oxygen atoms (where x is between 0 and 1 inclusive). Having thought through the implications of this formula, it would appear that the crystal is not as uniform as giant ionic structures are. The most common form is PbZr0.52Ti0.48O3, telling us that the ratio of the number of PbZrO3 unit cells to PbTiO3 ones is 0.52 : 0.48, or 13 : 12 [2] (since for the two statements Zr = x and Ti = 1 - x to be valid over the restricted range [x, (1 - x) ∈ ℕ], the two solutions are [Zr = 1, Ti = o] and [Zr = 0, Ti = 1]).
This isn't the first time my attention has been drawn to the idea of these materials - while I was sailing with my family, lighting the gas stove made me consider exactly what causes the spark. It turns out that piezoelectric crystals are indeed involved: the movement of the trigger causes a spring-loaded hammer to strike the crystal, inducing a voltage by the piezoelectric effect which produces a spark against a metal plate. This high pd is enough to ignite the fuel, lighting the burner.
The converse piezoelectric effect works by using a voltage to cause variation in the width of a piezo crystal. Since large voltages induce only tiny changes in the width of the crystal, the effect can be exploited to make motors which move objects with large precision - the crystal element is held against the target and a potential difference is applied across is, causing it to minutely change in width and push the target along by microns at a time. These motors are patented and manufactured by NanoMotion.
So how does this relate back to clocks keeping time? Well, these magical materials (usually quartz in this case) have a voltage applied between opposite faces by the battery, in turn causing the width of the crystal to oscillate thousands of times a second. However the crystal will not simply resonate by connecting the battery, but instead the electrical output needs to be fed back into it to continue the oscillation [6]. Since quartz oscillates at a fixed frequency of exactly 32768/s [3], a control circuit can convert these oscillations into even ticks of the clock by using a frequency divider circuit: these are used to take a high frequency signal in, and realise it to a much lower frequency signal - you want the clock to tick once per second, not 32768 times per second! Frequency divider circuits come in many different forms, but the simplest involves a chain of T flip-flops. These start with a default voltage of logic 1 or 0, and with each defined input will switch between the two. For example if the default was logic 1, and it will only flick to the alternative logic value when it receives an input of logic 1, the D flip-flop will output a digital signal of half the frequency. Therefore, the frequency-reduction factor of the circuit is 2number of flip flops [5]. Conveniently, 32768 = 215, so a circuit of fifteen sequential D flip-flops will reduce the frequency down to 1Hz.
Next, this signal will be fed into a stepping motor, which will use each electrical 'tick' to cause a mechanical tick of the clock: this type of motor is very useful for precision control of rotations. It is composed of a rotor with n metal teeth, and a stator with (n - 2) teeth connected to 8 solenoids arranged in a circle. The image below shows this well:
This is a view of the system from only one end. If we took the rotor out and looked at its cylindrical length, it would look like this:
[2] Wikipedia - "Intermetallic" - here
[3] Explain That Stuff - "Piezoelectricity" - here
[4] Youtube - digitalPimple - "Stepper Motor Basics and Control - How it works" - here
[5] Stack Exchange - Forum - here
[6]Hackman's Realm - "Information on Electronic Quartz Crystals" - here
Piezoelectric crystals
The piezoelectric effect describes how the application of mechanical stress to certain crystalline materials can generate a small electric current - the pressure causes the positive and negative charge centres to move, with the result that a weak external electric field is created. Early experiments showed that the effect was exhibited in a variety of natural crystals including cane sugar, topaz and quartz, with more recent developments augmenting this range with man-made structures including barium titanate (BaTiO3) and lead zirconate titanate (Pb[ZrₓTi₁₋ₓ]O₃). [1]
As an aside, the latter of these two compounds is classified as an "intermetallic compound", a curious label which means that metallic bonding occurs with defined stoichiometric ratios (i.e. for x lead atoms there are y zirconium and z titanium atoms, and for 2x lead atoms there are 2y zirconium and 2z titanium atoms) - within mainstream education I have never heard of such materials which form quasi-ionic lattices, so I find this very interesting. In the case of lead zirconate titanate, the chemical formula implies that for every lead atom there are x zirconium atoms, (1-x) titanium atoms and 3 oxygen atoms (where x is between 0 and 1 inclusive). Having thought through the implications of this formula, it would appear that the crystal is not as uniform as giant ionic structures are. The most common form is PbZr0.52Ti0.48O3, telling us that the ratio of the number of PbZrO3 unit cells to PbTiO3 ones is 0.52 : 0.48, or 13 : 12 [2] (since for the two statements Zr = x and Ti = 1 - x to be valid over the restricted range [x, (1 - x) ∈ ℕ], the two solutions are [Zr = 1, Ti = o] and [Zr = 0, Ti = 1]).
This isn't the first time my attention has been drawn to the idea of these materials - while I was sailing with my family, lighting the gas stove made me consider exactly what causes the spark. It turns out that piezoelectric crystals are indeed involved: the movement of the trigger causes a spring-loaded hammer to strike the crystal, inducing a voltage by the piezoelectric effect which produces a spark against a metal plate. This high pd is enough to ignite the fuel, lighting the burner.
The converse piezoelectric effect works by using a voltage to cause variation in the width of a piezo crystal. Since large voltages induce only tiny changes in the width of the crystal, the effect can be exploited to make motors which move objects with large precision - the crystal element is held against the target and a potential difference is applied across is, causing it to minutely change in width and push the target along by microns at a time. These motors are patented and manufactured by NanoMotion.
So how does this relate back to clocks keeping time? Well, these magical materials (usually quartz in this case) have a voltage applied between opposite faces by the battery, in turn causing the width of the crystal to oscillate thousands of times a second. However the crystal will not simply resonate by connecting the battery, but instead the electrical output needs to be fed back into it to continue the oscillation [6]. Since quartz oscillates at a fixed frequency of exactly 32768/s [3], a control circuit can convert these oscillations into even ticks of the clock by using a frequency divider circuit: these are used to take a high frequency signal in, and realise it to a much lower frequency signal - you want the clock to tick once per second, not 32768 times per second! Frequency divider circuits come in many different forms, but the simplest involves a chain of T flip-flops. These start with a default voltage of logic 1 or 0, and with each defined input will switch between the two. For example if the default was logic 1, and it will only flick to the alternative logic value when it receives an input of logic 1, the D flip-flop will output a digital signal of half the frequency. Therefore, the frequency-reduction factor of the circuit is 2number of flip flops [5]. Conveniently, 32768 = 215, so a circuit of fifteen sequential D flip-flops will reduce the frequency down to 1Hz.
Next, this signal will be fed into a stepping motor, which will use each electrical 'tick' to cause a mechanical tick of the clock: this type of motor is very useful for precision control of rotations. It is composed of a rotor with n metal teeth, and a stator with (n - 2) teeth connected to 8 solenoids arranged in a circle. The image below shows this well:
This is a view of the system from only one end. If we took the rotor out and looked at its cylindrical length, it would look like this:
In each step, two opposite solenoids will have positive magnetic charge and the two solenoids perpendicular to them will have negative charge. This will cause the rotor to jump by a quarter of a gear each time the field rotates [4]. It is better explained with my animations below; the first shows the process slowly, and the latter shows the net effect by playing it through at a faster rate. Since the rotor has 30 teeth and each 45° field rotation causes a quarter-gear jump, a full turn of the motor will occur every 120 field rotations - therefore my clock would run twice as slow as a normal clock, so real ones would have only half the tooth values (and be fed with a logic 1 frequency of 1Hz).
Sources
[1] NanoMotion - "The Piezoelectric Effect" - here[2] Wikipedia - "Intermetallic" - here
[3] Explain That Stuff - "Piezoelectricity" - here
[4] Youtube - digitalPimple - "Stepper Motor Basics and Control - How it works" - here
[5] Stack Exchange - Forum - here
[6]Hackman's Realm - "Information on Electronic Quartz Crystals" - here
Subscribe to:
Posts (Atom)