210 likes | 422 Views
Operating on Engineers. Five surgeons were taking a coffee break and were discussing their work. The first said, "I think accountants are the easiest to operate on. You open them up and everything inside is numbered.“
E N D
Operating on Engineers Five surgeons were taking a coffee break and were discussing their work. The first said, "I think accountants are the easiest to operate on. You open them up and everything inside is numbered.“ The second said, "I think librarians are the easiest to operate on. You open them up and everything inside is in alphabetical order.“ The third said, "I like to operate on electricians. You open them up and everything inside is color-coded.“ The fourth one said, "I like to operate on lawyers. They're heartless spineless, gutless, and their heads and their ass are interchangeable.“ The fifth surgeon says "I like engineers . They always understand when you have a few parts left over at the end."
Servomotor Speed Measurement Microprocessor Interfacing
Overview • Background • Tasks • Prelab – Frequency-to-Voltage Converter Design • Task 1 Speed to Voltage Characteristics • Task 2 Step Response • Task 3 Speed Display
Magnetism Permanent Magnet Electromagnet
Two-Pole DC Motor Electromagnet Permanent Magnets
DC Servomotor Motor Input Tachometer Output Surplus 5 ¼ inch full-height floppy disk spindle drive motor
Tachometer Output N = 120•f/P P = 16 N = 7.5•f
Prelab: LM2907 – 8-Pin DIP • Select proper values for I2 180 uA @ 3.3 VDC • R1 • R2 • C2 • In Task 1 select proper values for • Ra • Rb • So that Ra + Rb 10 kΩ • Place electrolytic cap across +5 VCC to GND on PICTail Plus to quite supply Some groups have N-8 (8 pin DIP) package and other groups have N (14 pin DIP) package
Task 1: Speed to Voltage Characteristics1 Saturation N = 120f/P = 7.5•f 1 October 2005
DEC2HEX Worksheet Function 1. Open Add-Ins 2. Select Analysis ToolPak
Task 2: Step Response 1/A • Use Voltage Cursor to find 63% • Use Time Cursor to find 1/A
Task 2 • Record Motor Number • Accurate measurement of A important to next laboratory exercise • Accurate measurement of B important to next laboratory exercise
Task 3 • Read Speed on AN3/RB3 • Connect RB3 to LM2907 Pin 4 • Add to initADC(0x03) if not already there • TRISBbits.TRISB3=1; • ADC1PCFGbits.PCFG3=0; • Initialize PMP and then LCD for channel 3 • initLCD(0) so there is no cursor
1234 RPM Task 3: Speed Display • printf(“. . . . . RPM\r”); • printf(“%04d\r”); • Use write function in peripherals.c that reacts properly to ‘\r’ • printf uses 2048 bytes of heap (see linker)
Write unsigned int write(int handle, void *buffer, unsigned int len){ int cnt; char ch; static unsigned char virtualCursor=0x80; switch(handle){ case 0: //standard-in not yet implemented len=0; break;
Write case 1: //standard out for(cnt=len;cnt >0; --cnt){ ch=*((char *)buffer++); switch(ch) { case '\n' : // if the virtualCursor less than 0x90, then set // virtualCursor to 0xC0 //else virctualCursor is 0x80. //send virtualCursor to display break;
Write case '\t' : //use bit manipulation to force virtualCursor to every fourth // position //send virtualCursor to display break; case '\v' : //use bit manipulation to force virtualCursor up or down // a line, whichever is appropriate //send virtualCursor to display break;
Write case '\b' //if virtualCursor is at start of first line, then set // virtualCursor to 0x80 //else if virtualCursor is at start of second line, then set // virtualCursor to 0xC0; //else subtract one from virtualCursor, send virtualCursor to // display, sent blank character to display, again send // virtualCursor to display. break;
Write case '\r' //use bit manipulation to force virtualCursor to start or // current line //send virtualCursor to display break; case '\f' : //clear LCD and set virtualCursor to 0x80 break; default : //increment virtualCursor and send character to display; } }
Write break; case 2: //standard error not yet implemented len = 0; break; default: len = 0; } return(len); }
Bit Manipulation • AND – No Change or Clear • OR – No Change or Set • NOT – Invert • XOR – No Change or Toggle