Mechatronic Systems ME 430
Popular in Course
Popular in Mechanical Engineering
This 29 page Class Notes was uploaded by Halie Berge on Monday October 19, 2015. The Class Notes belongs to ME 430 at Rose-Hulman Institute of Technology taught by Staff in Fall. Since its upload, it has received 20 views. For similar materials see /class/225095/me-430-rose-hulman-institute-of-technology in Mechanical Engineering at Rose-Hulman Institute of Technology.
Reviews for Mechatronic Systems
Report this Material
What is Karma?
Karma is the currency of StudySoup.
Date Created: 10/19/15
ME430 Mechantronic Systems Variable Types Everything stored in a computer is stored in some sort of binary format I don t care what it pro grams images data doesn t matter It must get stored as a much of 1 s and 0 s The primary building blocks of storage are hit A single storage location an individual switch which can have a value of 0 or 1 nibble less commonly used A set of four bits A nibble can represent values from 0000 to 1111 in binary or 0 to F in hexadecimal byte A set of eight bits A byte can represent values from 0000 0000 to 1111 1111 in binary or 00 to FF in hexadecimal When working with PICs there are really just two primary variable types integers and oating point numbers There are lots of other variable related things like arrays pointers structs strings made from character arrays etc Lets start with a look at integers and oating point numbers Integers Using the C 18 compiler there are integers of 4 di erent lengths 8bit 16bit 24bit and 32bit In general you want to save memory space so you should get into the practice of using the small est size integer that ful lls your needs For example don t use 16bit integers when an 8bit inte ger will do just ne The advantages of the larger integers are that you can t bigger numbers into them If an integer variable is 8bits then it can hold 28 256 di erent numbers If the 8bit number is unsigned you can hold numbers from 0 to 255 Ifthe 8bit number is signed you can hold numbers from 128 to 127 So if you can do everything you want with those options use a simple 8bit number The names of the bits are 8bit char 16bit int 24bit shortlong rarely used 32bit long TABLE 21 INTEGER DATA TYPE SIZES AND LIMITS Type Size Minimum Maximum char 39 8 bits 128 127 signed char 8 bits 128 127 unsigned char 8 bits 0 255 int 16 bits 32768 32767 uns igned int 16 bits 0 65535 short 16 bits 82768 32767 uns igned short 16 bits 0 65535 short long 24 bits 8388608 8388607 unsigned short long 24 bits 0 16777215 long 32 bits 2147483648 2147483647 unsigned long 32 bits 0 4294967295 The char Often when people talk about char they think of characters but char is any 8 bit integer The unsigned char commonly uses the ASCII format where a certain number corresponds to a character For example the number 65 0X41 corresponds to the character A The ASCII American Standard Code for Information Inerchange format employs an 8bit code 7 bits with l parity bit or extended character set bit Floating Point 1 Mews 1 equot 1 H 39 39 n1 s y Ifyoutry to store 15 into an intexger storage location you will be Very dissappointed n39 L 1 1 xx 39 1h 1m m mm 2 mm exponent 104 shown as a 1 1 negative 0 positive The 1234 is he mandssaponion and 41s me exponent So the exponent nick WWW 39pagzexpunenl 521 FloatingPoint Representation 754 Standard A oatmgypomt number 001751515 of four parts 1 A51ng 2 As1gn1 cand 3 Abase 11 These components are of the form dodvdzds 39 123 1 0 1 quot mm mug 1 Elm u Emax where Emm 7126 and Emax 27 Smg1ermrma1 numbers use a 32m word orgamzed a5 a 171311 srgn an arm blased exponent e E 127 and a 234m 11 action wmch 15 me lractlonal part loe signi cand magnitude 39 quot 39 quot 127 zda d7 Slgn ErbltblasedexponemE 1 e7e6555453ele1eu Using this method for storing numbers has a lot of advantages You can store any number not just integers and the range is very large 212 Floatingpoint Types 32bit floatingpoint types are native to MPLAB C18 using either the double or float data types MPLAB C18 utilizes the lEEE754 floatingpoint standard to represent floatingpoint types The ranges of the floatingpoint type are documented in Table 22 TABLE 22 FLOATINGPOINT DATA TYPE SIZES AND LIMITS Type Size M39mmum MEXImum Minimum Normalized Maximum Normalized Exponent Exponent float 32 bits 426 128 2 1262117549435e38 2125 22quot52680564693e38 double 32 bits 426 128 2quot26 117549435e38 212939 2245680564693e38 Let s see an example or two How would this variable get stored oat X 6039 Sign 0 positive Exponent Pick the 2x value that is just smaller than the number so that the mantissa will be ofthe form 1xxxxxxx In this case that s 22 Since it s a biased exponent where 127 is subtracted offwhat you store you store the exponent 129 0b1000 0001 2 129127 Mantissa Well we need 6 1xxxx 22 So to make that work we need 15 22 This will be easy lfdl 1 then we ll have the 05 we need to add to the default 1xxx So the mantissa gets stored as 100 0000 0000 0000 0000 0000 So the 32 bits stored for oat x 60 we d have 0 1000 0001 100 0000 0000 0000 0000 0000 Y ur turn What would the 32 bits be when storing oat x 10 Click here to go to the solution The down side of oating point variable storage is that it isn t exact You simply have 23 bits of resolution in the mantissa To see this example let s look at oat x 01 Sign 0 Exponent need 00625 24 So exponent 123 0b 0111 1011 Mantissa 10011001100110011001101 In order to be an exact value the mantissa should repeat 1100 forever That doesn t happen It simply is forced to round at the end So if you stored the value oat x 0100000005 It s store as Sign 0 Exponent need 00625 24 So exponent 123 0b 0111 1011 Mantissa 10011001100110011001101 Therefore ifyou tried to compare is 01 lt 0100000005 It d say NO They are equal To get around this problem your PC uses 64 bits of resolution A 64 bit oating point number is called a double The PIC doesn t use double just oat Using 64 bits doesn t fix the problem it just makes it not occur until you have more zeros in there So there are a lot of advantages but there are a few things tricky about oating point numbers A few other disadvantages are that printf doesn t support oats and you need to be careful about adding a oat to an int Also if you have a oat adding to an int you can t store it into an int variable Arrays In addition to integers and oating point numbers you ll probably also need to be able to use arrays Arrays are lists that have an index They can be very handy to go through lots of data Let s see an example ofusing an array int i 1 2 3 4 5 int Y51i YOl 10 Yll 20 Y21 30 Y3l 40 Y4l 50 The top example shows an initialized array You can use the syntax and don t need to state the size with that format The second example should an uninitialized array With that format you need to specify the size then load the entries individually Be careful with arrays because you can only access the entries you ve previously created If you tried to say y5 60 above you would be unhappy with the result You said the array would have 5 spots int y5 y5 is the 6th spot That doesn t y and people make that mistake all the time A very common type of array is an array of char s This special type of array is usually called a string Let s look at ways to use strings Working with Character Data and Strings There are two different and distinct ways to declare and de ne character data 1 Character Declaration You may declare and de ne individual characters char achar 39a39 char listchar 39t3939o3939y3939 3939b3939o3939a3939t39 char listchar2 toy boat char numchar 3913939239393393943939539 char numchar22 numchar0 0x61 printfquot c quotachar0 printfquot c quotlistchar1 printfquot c nquotnumchar2 Notice that when you de ne individual characters each character must be delimited with a pair of apostrophes not quotes Also each variable name must be followed with to indicate that the variable represents an array This will be true for all character variables used even if you only de ne a single character 2 String Declaration You may declare a set of characters together as a string char words quotI39m not happy quot printfquot s nquot words Notice that a string is de ned with quotes not apostrophes Even if you declare and de ne a variable as a string you can print each character with c or as the ASCII integer value of each character char words quotI39m not happyquot int i for i4 ilt6 ii1 printfquotc quot wordsi for i4 ilt6 ii1 printfquotd quot wordsi So when you here people talk about strings with the PIC it s really just an array of chars Structures Structures are special combinations of variables that you create If you are really into object oriented programming you might choose to use structures a lot but to be honest you could probably make it through your C programming career without knowing anything about structs Here is some example code for creating a struct struct int K Char yl4l sl OXSA abc struct int xISl int y s2 10 22 3o 40 50 OxAS In the rst example you made a variable of type sl So it s not an int or char or oat it s an sl variable type An sl variable you decided needs an int and an array of 4 chars The second example creates an s2 variable with an array of ints and a seperate int There are a lot of cool things you can do with structs and there is a lot more I d need to tell you about how to access the elds ect but let s let you look that up somewhere else if you want to learn to use structs I just wanted you to be aware that they exist Pointers A pointer is a variable that stores where a variable is stored in memory A pointer is always an Integer type and is either 16 or 24 bits when using the C18 compiler For this reason when you use a pointer you don t need to say the variable type You only need to tell the compiler what type of data the pointer points to A pointer can point to data in your RAM space where you usually store your variables or to ROM space where you programming code lives Let s look at some code using pointers ram char ramiptr rom char neariromgptr char ramiarrayll quotthis is RAMquot rom char romiarrayll quotthis is ROMquot void main void ramiptr ampram7array0l neariromiptr amprom7array0l So in this chunk of code we have 2 pointers Each pointer points to a char The rst pointer points to a char in RAM The second points to a char in ROM In this example the pointer points to the rst char in an array of chars This is pretty common since pointer syntax works a lot like array syntax So for example ram jtr2 points to the char data i The two major new things to pointers are the and amp symbols is for derefferencing That means what is the value at this pointer location The amp is the opposite That means what is the address this value is stored a Again in order to use pointers effectively you ll need to look them up It takes some practice getting good with pointers The code above also introduces the idea of ROM and RAM space There is a lot to talk about there For now I just wanted you to be aware that there is this thing called a pointer and it points to data Solution to the oating point problem above with X 10 Sign 1 Exponent 23 130 0b 1000 0010 Mantissa 10 1XXX 8 Need 125 so d1 0 d2 1 then we re set Mantissa 0b 010 0000 0000 0000 0000 0000 So oat X 10 is stored as 1 1000 0010 010 0000 0000 0000 0000 0000 Note I just put in the spaces to help you see it Really it s just stored into 4 bytes of RAM data storage as byte at location 0 11000001 byte at location 1 00100000 byte at location 2 00000000 byte at location 3 00000000 If you d just said char 10 it d store the value using 2 s complement as byte at location 0 11110110 If it was a long it d store the value using 2 s complement as byte atlocation 0 11111111 byte atlocationl 11111111 byte atlocation 2 11111111 byte at location 3 11110110 So if something is an Integer and ts in the char range just use a char Go back to the problem ME430 Mechatronics Special Function Registers Every PIC product has a bunch of Special Function Registers SFR that control how the PIC works Basically a SFR is an 8bit variable stored in the RAM memory data memory In general you can write to the SFR just like you could a variable Here we have a quick comparison Table 1 SFRs vs Variables Common variable SFR char X defined within the p18f4520h le X OXSA PORTB OXSA Both types of variables are stored in the data memory and both a char and a SFR is an 8bit register The primary difference between the two is who looks at the value stored there With a variable only your code looks at the bits in your variables With a SFR the PIC has ALL kinds of subroutines that look at the SFRs The SFRs control how the PIC operates and controls like 90 of how your program runs Let s look at some example code void main void TRISB 0X00 Makes Port B bits 0 amp l outputs TRISAbitsTRISA4 l Makes RA4 an input while 1 ifPORTAbitsRA4 0 PORTB 0X05 else PORTB 0X02 So this chunk of code us FULL of using the SFRs It uses 4 SFR TRISB TRISA PORTA and PORTB Each ofthese SFR serves a speci c purpose TRISA Settings make PORTA pins either inputs or outputs TRISB Settings make PORTB pins either inputs or outputs PORTA If A is an input you can read the values of the pins here If A is an output you can set the values of the pins here PORTB If B is an input you can read the values of the pins here If B is an output you can set the values of the pins here Each bit in a SFR is usually doing an independent function In these SFRs the bits make sense to all be together in other SFRs the bits do TOTALLY di erent things In order to gure out what a SFR does you need to look at the datasheet for that PIC Let s look at another piece of example code void main void OSCCONbitsIRCF2 l OSCCONbitsIRCFl l OSCCONbitsIRCFO 0 TRISB 0 while 1 PORTB 0b00000001 DelaleKTCYxdelayTime PORTB 0b00001000 DelaleKTCYxdelayTime This chunk of code uses 3 SFRs OSCCON TRISB and PORTB We ve already discussed the TRISB and PORTB SFRs so let s focus on the OSCCON SFR The first thing you ll notice is the format looks entirely di erent when dealing with that SFR What on earth is that about Well the crazy syntax XXXXXXbitsXXXX is just to access an individual bit in that register You can use that crazy syntax due to the fact that there is a strut variable created in the p18F4520h file that lets you access the bits individually You could also use PORTBbitsRBO to access an indi vidual bit in PORTB so that s not really the focus here The OSCCON SFR has information about Oscillator Con gurations OSC CON Let s take a look at the datasheet for the PIC18F4520 When we nd that SFR it looks like this REGISTER 22 osccon REGISTER Rin R W 1 RlWO RtW D R l R O RIW O Ri W U IDLEN RCF2 l lRCFt IRCFU osrs IOFS 8051 3080 bit bitD bit 7 IDLEN ldle Enable bit 1 2 Device enters Idle mode on SLEEP instruction 0 Device enters Sleep mode on SLEEP instruction bit 6 4 RCF2IRCFO Internal Oscillator Frequency Select bits 111 8 Nle INTOSC drives clock directly 110 4 MHZ 1012MH2 100 1 Nil12m 011 500 kHz 010 250 kHz 0 01 125 kHz 0 00 31 kHz from either moment or lNTRC directlyilzl bit 3 osrs Oscillator Start up Time out Status bid 1 Oscillator startup timeout timer has expired primary oscillator is running 0 Oscillator start up timeout timer is running primary oscillator is not ready bit 2 IOFS INTOSC Frequency Stable bit 1 INTOSC frequency is stable 0 INTOSC frequency is not stable bit 1 0 50515850 System Clock Select bits 1x Internal oscillator block 01 Secondary Timer1 oscillator 0 0 2 Primary oscillator Note 1 Reset state depends on state of the IESO configuration bit 2 Source selected by the INTSRC bit OSCTUNE b see text 3 Default output frequency of lNTOSC on Reset Legend R Readable bit W Writable bit U Unimplementecl bit read as 390 n Value at POR 1 Bit is set 0 Bit is cleared x Bit is unknown So in this SFR there are really 5 different variable settings The idle enable bit 1 bit long The internal oscillator frequency settings 3 bits long The startup timer 1 bit long The internal oscillator stability bit 1 bit long The System Clock Select Bit 2 bits long So this single SFR serves 5 independent functions It just saves space to organize them into a sin gle 8bit variable So now you can see why that special syntaX is really nice to modify one bit at a time In the code above we wanted to setup the internal timer to use 4 MHZ So we set those 3 bits We didn t want to mess with any of the other bits so we used that special bit syntaX If we d said OSCCON 0X60 We would ve gotten the 4 MHZ internal time but maybe we would ve messed up something else in the SFR So it s easier to just modify the bits you want Just how many SFR s does the 18F4520 have Well here s the list TABLE 51 SPECIAL FUNCTlON REGISTER MAP FOR PI C18F242012520l4420f4520 DEVICES Address Name Address Name Address Name Address Name FFFh TOSU FDFh lNDFEm FBFh CCPR1H FElth IPR I FFEh TDSH FDEh POSTINCZW FBEh CCF R39IL FEBEh PIR1 FFDh TOSL FDDh POSTDEC2m FBDh CCP1CON FQDh PIE1 FFCh STKPTR FDCh PREINC2 FBCh CCPR2H Fgoh FFBh PCLATU FDBh PLuswzm FBBh CCPRzL FQBh OSCTIUNE FFAh PCLATH FDAh FSRIZH FBAh CCP2CON FQAH Fngh PCL FDQh FSR2L FBQh 42 F99h FlF8h TBLPTRU FDBh STATUS FBBh BAUDCON FEJBh FlFTh TBLPTRH FDTh TMRUH FBTh PWMTCONl3l Fng FlFBh TBLPTRL FDBh TMRnL FBEh ECCPmsm F96h FlF5h TABLAT FDSh TUCON FBEh CVRCON F95h FlF4h PRODH FD4h 421 FB4h CMCON F94n TRISC FF3h PRODL FD3h osccow FBSh TMR3H F93h TRISB FF2h lNTCDN FD2h HLVDCON Fazh TMR3L F92h TRISA FHh lNTCON2 th WDTCON FB39lh T3CON F91h FFUh lNTCON3 FDOh RCON FBUh SPBRGH F9011 FEFh lNDFD m FCFh TMR1 H FAFh SPBRG FSFh FEEh POSTINCOW FCEh TMR1L FAEh RCREG FBEh FEDh POSTDECGW FCDh TTcoN FADh TXREG FSDh FECh PREINCUW FCCh TMR2 FACh TXSTA FBCh FEBh PLUSWDW FCBh PR2 FABh RCSTA FBBh FEAh FSRDH FCAh T2CON FAAh J2 FBAh FEQh FSROL chn SSPBUF FAgh EEADR F89h FE8h WREG FCBh SSPADD FABh EEDATA FBSh FETh INDFTm FCTh SSPSTAT FATh EECONQlquot FBYh FEBh POSTINCTl l Fceh SSPCOM FAEh EECON1 FBBh FE5h POSTDEC39I quot FCSh SSPCON2 FA h J21 FBSh FE4h PREINC39I FC4h ADRESH FA4h J2 F84h FEsh PLuswr FC3h ADRESL FABh J2 F83h FE2h FSRlH FCZh ADCONO FA2h PR2 F82h PORTC FElh FSR1L th ADCON I FA39lh PIR2 F81h PORTS FEOh BSR FCOh ADCON2 FAUh PIE2 FBO h PORTA Aren t you glad you asked That s a bit to much to learn all at once so we re taking it a little bit at a time For now it s good enough just to know that they are all there We ll work on a little bit at a time NEE430 7 Mechalronics Using the Breadboard Breadboard provide a quick and easy way to connect 1c integrated circuit chips with devices such as switches LEDs other digital 1c chips etc A standard breadboard is show below A bread board has many strips of metal copper usually which run underneath the board These metal 39 to make 39 quot The metal strips are laid out as shown below Hlll l l l llllllllll l ll m lll l l ll IIHIIlllllil lllllllllIIIIIHIIHIEIIHIHIIIIIIIIHull To use the bread board the legs of components are placed in the holes the sockets The holesarernadesoLhattheywilIL U L 39 EachL 39 4 one othe metal strips running underneath the board 1c chips are placed so that the pins straddle the slot that runs down the horizontal length ofthe board The long top and mi uppi anu ground connection Typically the red row is for power and the blue rowis for groun MMMMMMM The letters LED stand for Light Emitting Diode The important thing to remember about diodes including LEDs is that current can only ow in one direction To make an LED Work you need a voltage supply and a resistor Ifyou try to use an LED Without a resistor you will probably burn out the LED The LED has very little resistance so large amounts of current Will try to ow through it unless you limit the current With a resistor LED 220 to LED 470 Q 5v E 3 GND El An LED has two terminals an anode leg usually labeled With a and a cathode leg usually labeled With a 7 In order for an LED to light up there must be a voltage drop across the LED at a regulated current level controlled by the size of the resistor The long post of the LED usually represents the positive anode lead of the LED Some of our LEDs have had their legs cut and you Won t be able to see a difference in leg lengths Another good method to determine Which leg is Anoda and Which is Cathode is to look down at the top ofthe LED You should notice that the LED is not perfectly circular One side of the LED has a at spot The at spot should be on the cathode side ofthe LED Current ows alphabetically Anode to Cathode A to C Make sure the Andoe leg is at the higher volmge level The tWo main rules With LEDs are You MUST put in the LED in the correct direction and You MUST have a resistor in series with the LED Sizing the resistor that limits the LED current A standard LED has a forward voltage drop around 15 to 19 volts That means that the ifthe Anode leg is at 5 volts then the Cathode leg would be around 31 to 35 Volts LEDs can have a variety of ranges but that range is typical You can measure your LED voltage drop by attaching the DMM digital multimeter probes across the LED while it s lit in your circuit If your LED voltage drop measures 15 volts and the input voltage source is 5 volts the remaining voltage drop 35 volts needs to happen across a resistor So the size of the resistor determines the current owing through your resistor So you are setting the current that follow through the LED by sizing the resistor For most LEDs the current through the LED should be limited to 20 mA or less Usually about 10 mA is suggested for most LEDs we use The intensity of the light given off by the LED depends upon the amount of current owing through it The larger the current ow the brighter the LED Of course too much current ow will cause the LED to burn out For a supply voltage of 5 V a resistance of 330 ohms would be about right For other supply voltages you can determine an appropriate resistance value based on the calculation using Ohm s law Vs VLEdep 5V l5V i lOmA LED R 350 2 If your voltage source is a logic chip sometimes you want to draw less current so you should consider using a larger resistor like 1 or 2k Sometimes you ll even use LEDs that light up using less than 1 mA Sometimes ICs can t source 10mA so you might not be able to lite an LED directly We ll talk more about that when we get to transistors would be connzctcd to due mi wquot anmple Problem 12V supply resistor7 Smallest acczptable quot515mm ypum 1 I u m Reistor Color codes As you should know from ES203 Resistors have colorred bands which tell you the resistor value A standard resistor uses a 3 colorred bands which tell you the resistor value and a 4th band which tells you the level of accuracy usually gold or silver You ll mainly use the first three bands The band colors corresponds to a number using the following chart Color 1S IJalrd 2r dbaml 5 I remember via 3rd baml multiplier Black Brown Roy Biv Grey White 9 White As suggested on the chart the location of the band determines the signi cance of the number The 1st band is the first digit the 2nd band is the second digit and the third digit is how many EX RedRedOrange zeros to add Red 2 i Orange 3 L i Therefore 22000 which means that resistor is 22k ohms Example pro 31em What value would YellowVioletYellow be Click to see solution Standard Reistor values The rst time you look a package of resistors most people are surprised at the values available People expect to see things on standard intervals Say you were looking at resistor just above 10k You might expect to see 10k 20k 30k 40k 50k In the world of electronics it d be very surprising to find something like that You more likily find something like 10k 15k 22k 33k 47k 68k Eventually you get pretty good at guessing what resistor values you are likily to nd The reason for this system is so that the next resistor is a certain percentage larger than the last resister For example the list about is approximately 50 times larger than the previous resistor Table 1 Standard Decade Resistor value Resistor Multiplier Exact result Rounded to 10 x 15 15 15 15 x 15 225 22 22 x 15 33 33 33 x 15 495 47 47 x 15 705 68 68 x 15 102 100 100 x 15 150 150 150 x 15 225 220 The above table would continue for the next decade and you can see how the pattern is already starting to repeat The table above represents the E6 Standard Decade values For most resistors we use we ll use 5 resistors that have many additional values For some reason you still see LOTS of resistors with the values similar to those above For more details about typical values httpwwwlogwellcomtechcomponentsresistor7valueshtml E6 20 10 15 22 33 47 68 E12 10 10 12 15 18 22 27 33 39 47 56 68 82 E24 5 10 11 12 13 15 16 18 20 22 24 27 30 33 36 39 43 47 51 56 62 68 75 82 91 Using pnshhllttnn switcheswith the hrezdhnan l beeorne eonnee ed When you release the button the rows beeorne duconnected sgarn b wrth t The type of button rs called a smgle pole srngle throw momentary push u on tags are eonneeted So when you39re w button rs pressed all four e srde See the preture be swrteh status Whent usmg rt as a swrteh you only need on V A W lk JLlLl LlLlLILlLI 1 Mn pressed the signal hne rs eonneetedto 5 volts through the resrstorrnsxung rthrgh A annoyrng to work wrth but the erreurtrs yery srrnple ande works very well You also hrgh and low Ihur turn 3mm each nflht llnwing mpx CnnneccanLED nketheLEDmrn on and off m1 rnrzur mm l Large Current no Taday39s LED wan39l usumybum m xmmedu39zly thhnunhe aim m Lhzy really shnmd c amm an 125mm values range Amundle m 1k Makingaswlch Wm be dandy shamngpwwex and gaundwhenwu alas the swth Ths mam u Thasxs punymuch Cammanxeasmx values here 1k m Ink Wm um 55 v swpxy Next muoduee a log gate mto your eueuu sv A 1k wi s when u39s Workmg VERY suhuar for you use for your log Hw assxg hmehc You Won39t need the LED for a bash mput pushbutton but the N gate gwes you both the mvened and hohuhvened Sign The signal z goes hxgh Went the push unoh 15 pushed and Z goes low when the button 15 pushed Bmld 3 more pushbutton swuehes and use them as your mput sv 6 NOT gates 39 n digital rd on the course website Another good source is the website at http ww washingtonedustoiesDatasheets741s741shunl Notes and comme 5 gt Vccm ean on coll ector voltage For these chips you need to connect 5 volts to the Vcc pin A A to dnve an LED which we usually mn at 10 mA Thatbeing saidit almost always works just ne I d recommend only mnning 1 LED per logic chip though e layout for a 2 input logic chip is usually the same So the 2 input OR gate will have the same inputoutput layout an make a 3 input AND by cascading two 2input AND s You can also make a 3 input OR by cascading two 2input 0R5 MZE430 r Mechatronics Inrdass exercise Building a BA den FuH R and a Can39er addmon of two 4b numbers AA3A2A1A0 and BB3B2B1B0 Frgure 1 Adda on of bmary numbers Br H full adder illustrated below 3 Frgure 2 Block dragram of a full adder Make Cmnfxrstthen 1fyou39dhke some addmonal praeuee make Sum only cmrs requrred onee you fxmsh ths exererse start the lab Solutions to problems in packet Sizing the minimum LED resistor Givens 12 volt supply 19 forward voltage drop 20mA maximum Find Minimum resistor size Solution V i R 12V 19V 0020 A R R 505 ohms So the minimum size resistor you could use would be around 500 ohms Usually esistors only come in certain standard sizes So you would probably choose to use 470 hms or 680 ohms Most engineers prefer not to put resistors in series to get exactly 505 hms because it just doesn t matter Sizing a typical LED resistor Typically we run at half the maximum current which mean doubling the resistor So we d use lk Funny note The resistor shown in the problem statement picture has color bands Orange OrangeBrown That means it s 330 ohms 330 ohms would allow too much current It d be brighter but it could potentially burn out with that much current LIICK to return Solution to the resistor problem Yellow Violet Yellow 4 Violet 7 Yellow 4 Therefore 470000 which means that resistor is 470k ohm A good website for helping to figure out resistor values http www okaphonenlcalcresistor shtml Click to return