tag:blogger.com,1999:blog-49683889252863361012024-03-21T17:03:42.797-07:00Attempted fun with engineeringAnonymoushttp://www.blogger.com/profile/13900731941413064122noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-4968388925286336101.post-34345834642928716402015-07-01T08:33:00.003-07:002015-07-01T08:55:57.504-07:00Electronics Year 2 - Comparison of FETs with BJTs<h3>
FET component:</h3>
<div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhozRP8Nn0RxYbpWUvPgFx6yCNLG0kuMheBzSjTzqQffBooUbc9pIWBJworHCOnqRVrb_Eh6CScy-19QraaHsKr8dvv6P3unC_PxXlBjL2p3LUFGs2tpGcQN4qLxqfrFXMKrcIOn8EWA_M/s1600/photo+4.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="244" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhozRP8Nn0RxYbpWUvPgFx6yCNLG0kuMheBzSjTzqQffBooUbc9pIWBJworHCOnqRVrb_Eh6CScy-19QraaHsKr8dvv6P3unC_PxXlBjL2p3LUFGs2tpGcQN4qLxqfrFXMKrcIOn8EWA_M/s320/photo+4.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
</div>
<div>
<br /></div>
<div>
<b>Pins:</b></div>
<div>
(D)rain - Electrical current enters here</div>
<div>
(G)ate - This pin controls the size of the FET "gate", how much current is able to pass through.</div>
<div>
(S)ource - Electrical current exits here</div>
<div>
<br /></div>
<h3>
Comparison of BJT and FET:</h3>
<div>
As an analogy, the FET transistor can be compared to the BJT</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyA6Y1K9LUJb2X5iZTM3UV-CLAeq4HE9FxI-dp4w5duc1AK4pXbMLd9GN_HMVQcNNsxSk0JM6AVUgJiigrBzwK8xJKZxEiOMRwLennIDKNLtRg4nzmIBXDm1i9zyKBhdDmt5aDBQfv7yc/s1600/photo+3.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="238" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyA6Y1K9LUJb2X5iZTM3UV-CLAeq4HE9FxI-dp4w5duc1AK4pXbMLd9GN_HMVQcNNsxSk0JM6AVUgJiigrBzwK8xJKZxEiOMRwLennIDKNLtRg4nzmIBXDm1i9zyKBhdDmt5aDBQfv7yc/s320/photo+3.JPG" width="320" /></a></div>
<div>
</div>
<div>
BJT:</div>
<div>
<br />
<ul>
<li>(B)ase pin acts as input</li>
<li>Current flows from (C)ollector to (E)mitter</li>
<li>Input voltage V_b must be above 0.2V for the device to work in an operable region (a.k.a active region)</li>
</ul>
</div>
<div>
<br /></div>
<div>
FET:</div>
<div>
<br />
<ul>
<li>(G)ate pin acts as input</li>
<li>Current flows from (G)ate to (S)ource</li>
<li>Input voltage V_GS must be above a certain threshold, V_TO for the device to work in an operable region (a.k.a saturation region)</li>
</ul>
</div>
<div>
<br /></div>
<h3>
Comparison of voltage graphs:</h3>
<div>
Note that the FET voltage graph is not unlike that of the BJT</div>
<div>
BJT</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqSog6p_1OQjkdlRfSW4Mw3JsidRRaJxJAqeY_7MwLvS85O3zZg7hUS6j2wzYLw5g8mkqYDgY7VFDO1QLPTxiwC7X9MQ0S_WvBImhJdhQRuobRa9qUKdmwpg5YfaBNc1RZvcGuwx3O7oY/s1600/photo+1.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqSog6p_1OQjkdlRfSW4Mw3JsidRRaJxJAqeY_7MwLvS85O3zZg7hUS6j2wzYLw5g8mkqYDgY7VFDO1QLPTxiwC7X9MQ0S_WvBImhJdhQRuobRa9qUKdmwpg5YfaBNc1RZvcGuwx3O7oY/s400/photo+1.JPG" width="312" /></a></div>
<div>
<br /></div>
<div>
FET</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHOnee8mP3C6O3IF2QrLadn5NK74aIBhAICSr4O6TyURsIY29da8kOmeGNZjQnW-xSNP9gL11baHXGKHMdH4pM3tkdTY0_BfeuXU5tBfg5aD_l7YfI4xurTpdP10jQ50U1GErYaftlBI0/s1600/photo+2.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHOnee8mP3C6O3IF2QrLadn5NK74aIBhAICSr4O6TyURsIY29da8kOmeGNZjQnW-xSNP9gL11baHXGKHMdH4pM3tkdTY0_BfeuXU5tBfg5aD_l7YfI4xurTpdP10jQ50U1GErYaftlBI0/s400/photo+2.JPG" width="371" /></a></div>
<div>
</div>
<div>
<br /></div>
<div>
Note that while the output current of the BJT (emitter) is dependant on the input current, the output current of the FET (source) is dependant on the input voltage. This is an important point to consider when analysing the small signal properties of the transistors.</div>
Anonymoushttp://www.blogger.com/profile/13900731941413064122noreply@blogger.com1tag:blogger.com,1999:blog-4968388925286336101.post-29357609409722083452015-03-10T17:33:00.002-07:002015-03-11T19:06:51.293-07:00Electronics Year 1 - Op Amps<h2>
Introduction to Operational Amplifiers (Op-Amps)</h2>
<br />
In summary, the op-amp is a voltage amplifier, typically with two inputs, and a single output. For the sake of simplification, most op-amps can be simplified into the following model.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><img src="http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Op-Amp_Internal.svg/250px-Op-Amp_Internal.svg.png" style="margin-left: auto; margin-right: auto;" /></td></tr>
<tr><td class="tr-caption" style="text-align: center;">http://en.wikipedia.org/wiki/Operational_amplifier</td></tr>
</tbody></table>
There are 5 pins;<br />
<b>V+ </b>This is the noninverting input<br />
<b>V-</b> This is the inverting input<br />
<b>Vout</b> This is the output terminal<br />
<b>Vs+</b> This pin is attached to a high voltage source<br />
<b>Vs-</b> This is the grounding pin<br />
<br />
However, usually they are drawn as follows<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><img src="http://hyperphysics.phy-astr.gsu.edu/hbase/electronic/ietron/opamp.gif" style="margin-left: auto; margin-right: auto;" /></td></tr>
<tr><td class="tr-caption" style="text-align: center;">http://hyperphysics.phy-astr.gsu.edu/</td></tr>
</tbody></table>
<br />
We do not explicitly show the power-supply connections (Vs+ and Vs-) in circuit diagrams.<br />
It is assumed that the Vout voltage is made in relation to the circuit's ground.<br />
<br />
The op-amp multiplies the difference between V+ and V-, and multiplies it by Aol, the <a href="http://en.wikipedia.org/wiki/Feedback">open loop</a> gain.<br />
i.e. <b>Vout</b> = |(<b>V+</b> - <b>V-</b>)| x <b>Aol</b><br />
<br />
This gain parameter, Aol is very large, and is assumed to be infinite, in the case of an ideal op-amp.<br />
For the simplicity of calculation, we simply assume that, because Vout is real,<br />
<b>Vout</b>/<b>Aol</b> = |<b>V+</b> - <b>V-</b>|<br />
<br />
i.e. <b>V+</b> = <b>V-</b><br />
<br />
This concept is known as the summing point constraint.<br />
This is the default assumption we make whenever calculating feedback loops for ideal op-amps.<br />
By making this assumption, we can apply standard circuit analysis principles.<br />
While there is a difference between V+ and V-, we have to assume that they are the same value for the sake of calculation, such as the following cases demonstrated below.<br />
<br />
<h2>
Using the Op-Amp in circuits</h2>
<div>
Inverting amplifiers - negative feedback</div>
<div>
Inverting amplifiers - positive feedback</div>
<div>
Noninverting amplifiers</div>
<div>
Non inverting amplifiers always have negative feedback.</div>
<br />Anonymoushttp://www.blogger.com/profile/13900731941413064122noreply@blogger.com2tag:blogger.com,1999:blog-4968388925286336101.post-9082812402838081402015-03-04T17:18:00.001-08:002015-03-11T20:15:33.884-07:00Electronics Year 2 Chapter 1 - Amplifier models<h2>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Amplifier models:</span></h2>
<div>
There exist four amplifier models;</div>
<div>
<ol>
<li>Voltage Amplifier Model</li>
<li>Current Amplifier Model</li>
<li>Transconductance Amplifier Model</li>
<li>Transresistance Amplifier Model</li>
</ol>
<div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhuzd8A9Gtt8mHx6O8hTbqAVTW6_znRPe6bLNOkmHzRPke_3qA2caFt8qHwGgs_M90LdaIyNiReKn64MrYD_REGrMwWmP3u1mSM8nZsc266Ye5uTbB0MejsWWeXShYDT8jyKyoMeexKK1w/s1600/photo+1.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhuzd8A9Gtt8mHx6O8hTbqAVTW6_znRPe6bLNOkmHzRPke_3qA2caFt8qHwGgs_M90LdaIyNiReKn64MrYD_REGrMwWmP3u1mSM8nZsc266Ye5uTbB0MejsWWeXShYDT8jyKyoMeexKK1w/s1600/photo+1.JPG" height="297" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Simplified amplifier model</td></tr>
</tbody></table>
<br />
To begin, we need to understand the voltage amplifier model.<br />
<br />
<h3>
Voltage amplifier model</h3>
<div>
Consider the image above. In the case of the voltage amplifier model, the internal components can be modelled as the following;</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFQIfpU95L-yIPMMrdcXz7gJ0JUa8WkW5y6DP8BckFkGCaOu0fDk8giU5daybvdZn80V8cOuuU5p3htIpmIIDH8Ox0NSzZ4hTOg2c7K1bvajifzDygo6bnP819oMKNSG_7qSt1haAzjbU/s1600/photo+2.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFQIfpU95L-yIPMMrdcXz7gJ0JUa8WkW5y6DP8BckFkGCaOu0fDk8giU5daybvdZn80V8cOuuU5p3htIpmIIDH8Ox0NSzZ4hTOg2c7K1bvajifzDygo6bnP819oMKNSG_7qSt1haAzjbU/s1600/photo+2.JPG" height="297" width="400" /></a></div>
<br />
Where<br />
Vi = input voltage<br />
Vo = output voltage<br />
Ii = input current<br />
Io = output current<br />
Ri = input resistance/impedance<br />
Ro = output resistance/impedance<br />
<br />
The gain property of this model is represented by a <u>voltage-controlled voltage source</u>.<br />
(More information on which can be found <a href="http://en.wikipedia.org/wiki/Dependent_source">here</a>)<br />
<br />
<b><u>Note:</u></b></div>
</div>
<div>
By definition, voltage gain, Av = Vo/Vi</div>
<div>
<br /></div>
<div>
Open-circuit voltage gain = Avo</div>
<div>
(if the load is an open circuit, as shown above, there is no drop across the output resistance, and Vo = Avo*Vi)</div>
<div>
<br /></div>
<div>
Given a model with external loading (i.e. with external components attached), the model can be simplified as follows, for analysis. <a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3bAP-M74d6cZHnzvU67mK18zm7XhWG3yaURUlm5jkZ86q5fYo_brtF0nxCF449ITxWAUseM8yCgBxsZe2Y_FC_ndbGiu08gLo3OCglzi-zWWW79K-050vXfylDF5Es7tgKx_mYeaArN8/s1600/photo.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3bAP-M74d6cZHnzvU67mK18zm7XhWG3yaURUlm5jkZ86q5fYo_brtF0nxCF449ITxWAUseM8yCgBxsZe2Y_FC_ndbGiu08gLo3OCglzi-zWWW79K-050vXfylDF5Es7tgKx_mYeaArN8/s1600/photo.JPG" height="167" width="400" /></a><br />
<br />
Aside from voltage gain. there also exists current gain, Ai, which can be calculated as follows;</div>
<div>
Ai = Io/Ii = (Vo/Rl)/(Vi/Ri) = Av*(Ri/Rl)</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<h3>
Current amplifier model</h3>
<div>
Another method of modelling the amplifier is the current amplifier model.</div>
<div>
This can be modelled as the following;</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhMqbz4BYGQTt76aCYjuisPyD1D91Uq45-8LWrDRRY2IP-sL071rRBNM3mgEF_-Njz6J4aF8fv1-1GBdwGmiV5Dbw8Gax4qPZ2MUN0_xS782LviZVFPsd2y5Pa9_Qa4flO4Qo7CKaBjaE/s1600/photo+3.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhMqbz4BYGQTt76aCYjuisPyD1D91Uq45-8LWrDRRY2IP-sL071rRBNM3mgEF_-Njz6J4aF8fv1-1GBdwGmiV5Dbw8Gax4qPZ2MUN0_xS782LviZVFPsd2y5Pa9_Qa4flO4Qo7CKaBjaE/s1600/photo+3.JPG" height="238" width="320" /></a></div>
<div>
<br /></div>
<div>
The gain property of this model is represented by a <u>current-controlled current source</u>.</div>
<div>
<br /></div>
<div>
<b><u>Note:</u></b></div>
<div>
By definition, current gain Ai = Io/Ii</div>
<div>
<br /></div>
<div>
Open-circuit current gain = Aisc</div>
<div>
(If the load is a short circuit, no current flows through resistor Ro, and Io/Ii is short-circuit current gain.)</div>
<div>
<br /></div>
<h3>
Transconductance amplifier model</h3>
<div>
<div>
Another method of modelling the amplifier is the transconductance-amplifier model.</div>
<div>
This can be modelled as the following;</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEru-1Gsbqm2aCzVyDcUmDIFtSCYxcKrygCCZur125LSkXDrnJuGzrBad-nD_KpXojX6SPu8PSDFsqeaHz9jaZiy_CkSZI2sNVHEZkG8dCwQwn5kx98UgMvyc-QfGTnEAFYp-N3wITrVs/s1600/photo+4.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEru-1Gsbqm2aCzVyDcUmDIFtSCYxcKrygCCZur125LSkXDrnJuGzrBad-nD_KpXojX6SPu8PSDFsqeaHz9jaZiy_CkSZI2sNVHEZkG8dCwQwn5kx98UgMvyc-QfGTnEAFYp-N3wITrVs/s1600/photo+4.JPG" height="238" width="320" /></a></div>
<div>
<br /></div>
<div>
The gain property of this model is represented by a <u>voltage-controlled current source</u>.</div>
</div>
<div>
<br /></div>
<div>
Observe that while the transconductance-amplifier and current-amplifier models use the Norton equivalent circuit, the voltage-amplifier model uses the Theverin equivalent circuit, as will the transresistance model, as will be demonstrated below.</div>
<div>
<br /></div>
<h3>
Transresistance amplifier model</h3>
<div>
<div>
Another method of modelling the amplifier is the transresistance-amplifier model.</div>
<div>
This can be modelled as the following;</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOy-Xrx75VAYEibYNCFxEYN_vN96kPukcChAH6eeLRSzQuM1JggWcvDGxOlemOPfs3WXWSVil7ACYQj7z39Il6lHdf-Sjm07qX1eXcDIMRYXIJQUWdlF8GTgWME7B5IM7w1MA9V0OKk9U/s1600/photo+5.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOy-Xrx75VAYEibYNCFxEYN_vN96kPukcChAH6eeLRSzQuM1JggWcvDGxOlemOPfs3WXWSVil7ACYQj7z39Il6lHdf-Sjm07qX1eXcDIMRYXIJQUWdlF8GTgWME7B5IM7w1MA9V0OKk9U/s1600/photo+5.JPG" height="238" width="320" /></a></div>
<div>
<br /></div>
<div>
The gain property of this model is represented by a <u>current-controlled voltage source</u>.<br />
<br />
<h3>
On cascading amplifiers:</h3>
</div>
</div>
<div>
<br /></div>
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUKdwUJFs8bJipmZX9R5FVNm4q37Gr6xYVn6Pa_442nPPo5qBXIalgBh5-fgt8gbmDpuLDOzpl9B10DZ7ZdL8L8ev2JUNWyy2xSyTU-apNj6H3i883xrqfCTNbrfzBkHXJM42BEJ_FDCo/s1600/photo+1+(1).JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUKdwUJFs8bJipmZX9R5FVNm4q37Gr6xYVn6Pa_442nPPo5qBXIalgBh5-fgt8gbmDpuLDOzpl9B10DZ7ZdL8L8ev2JUNWyy2xSyTU-apNj6H3i883xrqfCTNbrfzBkHXJM42BEJ_FDCo/s1600/photo+1+(1).JPG" height="298" width="400" /></a></div>
<br /></div>
<div>
<br /></div>
<h3>
Ideal amplifiers</h3>
<div>
(To reduce loading effects)</div>
<div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwLImu6D5_StPtBxEuzC0SwxrBcPg90utxhXvMZWIedNYMWTDw5Ja5JdwFyrzOQjZ5NomC72NZNK7c45Wn2cBzvfZsrGSJo5fQjo5_5rSqwsrJ8RHLbY2XnW4gOqwWxayXe1SzrsgEDTU/s1600/photo+2+(1).JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwLImu6D5_StPtBxEuzC0SwxrBcPg90utxhXvMZWIedNYMWTDw5Ja5JdwFyrzOQjZ5NomC72NZNK7c45Wn2cBzvfZsrGSJo5fQjo5_5rSqwsrJ8RHLbY2XnW4gOqwWxayXe1SzrsgEDTU/s1600/photo+2+(1).JPG" height="238" width="320" /></a></div>
<br />
If the reasons for the above table remain unknown, consider the following<br />
<br /></div>
<div>
<b><u>Inputs:</u></b><br />
The <u>voltage</u> and <u>transconductance</u> models are voltage controlled.<br />
Thus, the input impedance Ri is ideally large, this maximises the voltage drop Vi to be maximised over Ri. (See earlier diagrams)<br />
<br />
The <u>current</u> and <u>transresistance</u> models are current controlled.<br />
Thus, to maximise the input current Ii, Ri is minimised.<br />
<br />
<b><u>Outputs:</u></b><br />
The <u>voltage</u> and <u>transresistance</u> models are voltage sources.<br />
Thus, to maximise the output Vo, the output impedance Ro is minimised. By doing so, the voltage drop over Rl is maximised.<br />
<br />
The <u>current</u> and <u>transconductance</u> models are current sources.<br />
Thus, to maximise the output current Io, the output impedance Ro is maximised, allowing the current to flow out of the amplifier (Ro becomes akin to an open circuit).<br />
<br />
(Note that this logic holds because for the voltage sources, a Theverin equivalent circuit is used, while for the current sources, a Norton equivalent circuit is used. More information on Theverin and Norton can be found <a href="http://www.calvin.edu/~svleest/circuitExamples/TheveninNorton/theory.htm">here</a>.)<br />
<br />
<br />
Hopefully, this provides an introduction to amplifier models. If you feel that any part of this post needs improvements, feel free to contact us at engyfun@gmail.com</div>
<div>
<b><u><br /></u></b></div>
<div>
<br /></div>
<div>
References:</div>
<div>
<span id="js-reference-string-0">Kroll, (2009). 1st ed. [ebook] Available at: http://surf.hep.upenn.edu/~kroll/p364_fall09/handouts/simple_voltage_amplifier.pdf [Accessed 5 Mar. 2015].</span></div>
<div>
<span id="js-reference-string-1">Lu, T. (2015). <i>Electronics IIM 2015</i>. Adelaide: University of Adelaide.</span></div>
Anonymoushttp://www.blogger.com/profile/13900731941413064122noreply@blogger.com0tag:blogger.com,1999:blog-4968388925286336101.post-36071634141418099352015-03-04T17:13:00.001-08:002015-03-10T17:34:12.009-07:00Electronics notesWe understand that the electronics courses I've taken with my friends are a little overcomplicated, and as such, we will attempt to post simplified explanations on this blog.<br />
<div>
<br /></div>
<div>
Advice, request and comments on the posts regarding this are welcome.</div>
<div>
<br /></div>
<div>
Look for the following label(s):</div>
<div>
ElectronicsI, ElectronicsII</div>
Anonymoushttp://www.blogger.com/profile/13900731941413064122noreply@blogger.com0tag:blogger.com,1999:blog-4968388925286336101.post-80007240477913751862015-02-07T20:44:00.000-08:002015-03-04T17:16:30.179-08:00Arduino library for 28BYJ48 Stepper motor and ULN2003 driver. Here is the source code for our 28BYJ48 stepper motor, ULN2003 driver library, as well as an implementation. Check out the diagram for the wiring.<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTO1i1jMDgoY8S9W-S9PWSi0tw9iCFjNoR8o6s5esE12lSNSFyRZlzVjo0myDYkmiX8O-Z6TSkQVjtvcTWKyESH1E8I5OOoH3JU1nYmRV8ERJVSNv2qjxQ7X9b3C1UQzZyw7Qz2EtVRFU/s1600/Wiring.png" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"></a><br />
The header file:<br />
__________________________________________________________________<br />
<br />
<br />
#ifndef Stepper_h<br />
#define Stepper_h<br />
<br />
class StepperMotor {<br />
public:<br />
StepperMotor(int In1, int In2, int In3, int In4); // Constructor that will set the inputs<br />
void setStepDuration(int duration); // Function used to set the step duration in ms<br />
void step(int noOfSteps); // Step a certain number of steps. + for one way and - for the other<br />
<br />
int duration; // Step duration in ms<br />
int inputPins[4]; // The input pin numbers<br />
};<br />
<br />
#endif<br />
<br />
<br />
___________________________________________________________________<br />
<br />
<br />
The cpp file:<br />
___________________________________________________________________<br />
<br />
#include <Arduino.h><br />
#include <StepperMotor.h><br />
<br />
StepperMotor::StepperMotor(int In1, int In2, int In3, int In4){<br />
// Record pin numbers in the inputPins array<br />
this->inputPins[0] = In1;<br />
this->inputPins[1] = In2;<br />
this->inputPins[2] = In3;<br />
this->inputPins[3] = In4;<br />
<br />
// Iterate through the inputPins array, setting each one to output mode<br />
for(int inputCount = 0; inputCount < 4; inputCount++){<br />
pinMode(this->inputPins[inputCount], OUTPUT);<br />
}<br />
duration = 50;<br />
}<br />
<br />
void StepperMotor::setStepDuration(int duration){<br />
this->duration = duration;<br />
}<br />
<br />
void StepperMotor::step(int noOfSteps){<br />
/*<br />
The following 2D array represents the sequence that must be<br />
used to acheive rotation. The rows correspond to each step, and<br />
the columns correspond to each input. L<br />
*/<br />
bool sequence[][4] = {{LOW, LOW, LOW, HIGH },<br />
{LOW, LOW, HIGH, HIGH},<br />
{LOW, LOW, HIGH, LOW },<br />
{LOW, HIGH, HIGH, LOW},<br />
{LOW, HIGH, LOW, LOW },<br />
{HIGH, HIGH, LOW, LOW},<br />
{HIGH, LOW, LOW, LOW },<br />
{HIGH, LOW, LOW, HIGH}};<br />
<br />
int factor = abs(noOfSteps) / noOfSteps; // If noOfSteps is +, factor = 1. If noOfSteps is -, factor = -1 <br />
noOfSteps = abs(noOfSteps); // If noOfSteps was in fact negative, make positive for future operations<br />
<br />
/* <br />
The following algorithm runs through the sequence the specified number <br />
of times<br />
*/<br />
for(int sequenceNum = 0; sequenceNum <= noOfSteps/8; sequenceNum++){<br />
for(int position = 0; ( position < 8 ) && ( position < ( noOfSteps - sequenceNum*8 )); position++){<br />
delay(duration);<br />
for(int inputCount = 0; inputCount < 4; inputCount++){<br />
digitalWrite(this->inputPins[inputCount], sequence[(int)(3.5 - (3.5*factor) + (factor*position))][inputCount]);<br />
}<br />
} <br />
}<br />
}<br />
<br />
_______________________________________________________________________<br />
<br />
<br />
An implementation:<br />
_______________________________________________________________________<br />
<br />
#include <StepperMotor.h><br />
<br />
StepperMotor motor(8,9,10,11);<br />
<br />
void setup(){<br />
Serial.begin(9600);<br />
motor.setStepDuration(1);<br />
}<br />
<br />
void loop(){<br />
motor.step(1000);<br />
delay(2000);<br />
motor.step(-1000);<br />
delay(2000);<br />
}<br />
<br />
_________________________________________________________________________<br />
<br />
<br />
Wiring diagram:<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTO1i1jMDgoY8S9W-S9PWSi0tw9iCFjNoR8o6s5esE12lSNSFyRZlzVjo0myDYkmiX8O-Z6TSkQVjtvcTWKyESH1E8I5OOoH3JU1nYmRV8ERJVSNv2qjxQ7X9b3C1UQzZyw7Qz2EtVRFU/s1600/Wiring.png" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTO1i1jMDgoY8S9W-S9PWSi0tw9iCFjNoR8o6s5esE12lSNSFyRZlzVjo0myDYkmiX8O-Z6TSkQVjtvcTWKyESH1E8I5OOoH3JU1nYmRV8ERJVSNv2qjxQ7X9b3C1UQzZyw7Qz2EtVRFU/s1600/Wiring.png" height="332" width="640" /></a><br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTO1i1jMDgoY8S9W-S9PWSi0tw9iCFjNoR8o6s5esE12lSNSFyRZlzVjo0myDYkmiX8O-Z6TSkQVjtvcTWKyESH1E8I5OOoH3JU1nYmRV8ERJVSNv2qjxQ7X9b3C1UQzZyw7Qz2EtVRFU/s1600/Wiring.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><br /></a></div>
<br />Anonymoushttp://www.blogger.com/profile/13900731941413064122noreply@blogger.com20tag:blogger.com,1999:blog-4968388925286336101.post-30688328465692433932015-02-07T03:00:00.003-08:002015-02-07T03:00:40.198-08:00Link to instructables<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Here's a link to our instructables page</span><br />
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">http://www.instructables.com/member/EngyFun/</span><br />
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;">Suggestions are welcome!</span>Anonymoushttp://www.blogger.com/profile/13900731941413064122noreply@blogger.com1