Belgie - Belgique P.B. 3/6499 9340 LEDE 1 1 OKTOBER NOVEMBER DECEMBER DRIEMAANDELIJKS MAGAZINE VAN DE VZW TECHNOLOGY INTEREST GROUP ERPE-MERE
Verantwoordelijke uitgever: Bert Van den Abbeele Keibergkerkweg 108 9340 LEDE Afgiftekantoor: 9340 LEDE 1 1 P2A8747
Gelukkig Nieuwjaar!
Experimenten op de club
Beste leden, In dit clubblad vinden jullie de uitslag van de HF velddag, een artikel over servo motoren aansturen met een PIC (in C) en enkele sfeerbeelden. Vergeet je lidgeld niet te betalen, dank u! Hopelijk zien we jullie allemaal op de nieuwjaarsreceptie! Vriendelijke groeten, Bert Van den Abbeele COLOFON Dit is een uitgave van de vzw Technology Interest Group Erpe-Mere (TIGEM). De auteurs behouden het auteursrecht van alle artikels. Voor alle artikels in andere tijdschriften, voordrachten en dergelijke dient vooraf een schriftelijke toestemming bekomen te worden van de hoofdredacteur en de verantwoordelijke uitgever. Artikels en schakelingen mogen enkel aangewend worden voor particuliere experimentele doeleinden van niet-commerciële aard en dit vanuit een educatief standpunt. Ondanks alle aan de samenstelling van dit tijdschrift bestede zorg kan noch de auteur, noch de redactie enige aansprakelijkheid aanvaarden voor eventuele schade die zou kunnen voortvloeien uit enige fout die in dit nummer zou voorkomen. De auteursrechtelijke bescherming van dit clubblad strekt zich mede uit tot de illustraties met inbegrip van de circuits, evenals tot de ontwerpen daarvoor. De redactie behoudt eveneens het recht ingezonden artikels aan te passen, te wijzigen en/of in te korten. De Land van Aalst RadioAmateurs (LARA) en Radioamateurs Erpe-Mere (REM) zijn een onderdeel van de overkoepelende vzw Technology Interest Group Erpe-Mere. LARA met roepnaam on4lar is erkend door de vzw Vlaamse Vereniging voor Radioamateurs (VRA). REM met als roepnaam on4rem is erkend door de vzw UBA (Koninklijke Unie van de Belgische Zendamateurs). Iedereen die lid is van vzw TIGEM ontvangt dit clubblad. Het lidmaatschap bedraagt 10 EURO per jaar. Betaling kan gebeuren door overschrijving op rekeningnummer 979-534003593 met vermelding van lidmaatschap TIGEM 2009. Redactie en medewerkers: Marc Hoffelinck, Karel Braeckman en Bert Van den Abbeele. De verantwoordelijke voor deze uitgave is: vzw Technology Interest Group Erpe-Mere Zaal PAX Dorpsstraat 119 9420 Erpe
Nieuwjaarsreceptie De nieuwjaarsreceptie zal doorgaan op zondag 7 februari 2010. We verwachten jullie vanaf 10 uur in het clublokaal (zaal PaX te Erpe). Tot dan!
Nieuws: ATV ON0TVO Beste radiovrienden, Dankzij Wim ON8DSW is er een nieuw experiment met de DATV repeater ON0TVO te Gent: De streaming gaat nu sneller aan 100kBps en er zit geluid bij, de beelden zijn dus heelwat sneller... Kijk eens mee op: http://www.ovrc.net/!a/index.php?name=Content&pa=show page&pid=27 73s Jan ON5YK Clubblad
3
© vzw TIGEM
Uitslag HF velddag september 2009 Onze UBA sectie REM heeft de 15e plaats behaald tijdens de HF velddag. De resultaten: 352 QSO's en 53 multiplicator geeft een score van 66674. Proficiat aan iedereen die van deze velddag een succes gemaakt heeft!
Clubblad
4
© vzw TIGEM
Lidgeld 2010 Beste leden van VZW Tigem, hierbij vinden jullie een overschijvingsformulier voor het betalen van de lidgelden voor 2010. Hopelijk blijven jullie allemaal onze club steunen!
Clubblad
5
© vzw TIGEM
PIC servocontroller (in C) In this article I’ll explain how to control a simple servo motor from a PIC18F4455 microcontroller. I am using a real cheap servo (an ES-30, see Conrad site), but it should be enough for hobby (read: robot) purposes. Servo Controller A DC motor is controlled using a DC voltage, but a servo motor requires some more work as it is controlled using pulses. By varying the width of a pulse you can set the angle the servo motor has to turn to. A servo motor can usually turn from -90 degrees to +90 degrees, but my ES30 seems to be limited to -70 to +70 degrees or so.. Connections The servo motor has three connections: ground (black), supply voltage (red) and the connection for the input pulses (usually yellow). We will connect the black wire to ground, the red one to our PIC supply voltage (5V) and the yellow wire to the D3 output (PORTDbits.RD3). So D3 will be the PIC output pin that controls the servo.
Clubblad
6
© vzw TIGEM
Pulses The servo expects a pulse every 20ms. The width of this pulse varies in the range 1.0 – 2.2ms, this range could be different with your specific servo so consult the datasheet (or just try some values)! A pulse width of 1.0ms sets the servo to the far left, a pulse of 2.2ms to the far right, and everything in between should map on an angle somewhere in between. Timing with the PIC uC We are going to use interrupts to ensure our pulses appear every 20ms. A timer interrupt happens when the timer register overflows. The timer register (can be configured as 8bit or 16bit) is increased on every clock tick. If the prescaler is set it happens less than every clock tick. A spreadsheet with my calculations is available at http://spreadsheets.google.com/pub?key=p9YPS93eEHH3W7dx5fxQEMQ& output=xls, you can see the interrupt rate for various settings of
the prescaler value. You can enable the interrupts like this: OpenTimer0(TIMER_INT_ON & T0_SOURCE_INT & T0_16BIT & T0_PS_1_4);//enable TMR0, 16bit, CLK0 src, low-to-high trans, prescale on, prescale 1:4
So your servo initialization will look like this: void startServo(void) {//initialize TIMER0 + enable interrupts TRISD = 0;//D is output PORTD = 0; INTCONbits.RBIF = 0; INTCONbits.TMR0IE= 0; RCONbits.IPEN = 0; OpenTimer0(TIMER_INT_ON & T0_SOURCE_INT & T0_16BIT & T0_PS_1_4); INTCONbits.GIE = 1;//enable global interrupts INTCONbits.PEIE = 1;// enable peripheral interrupts } Clubblad
7
© vzw TIGEM
Define the interrupt function like this: #pragma interruptlow timerFtie void timerFtie(void) { if (INTCONbits.TMR0IF) { //interrupt timer 0 INTCONbits.TMR0IF = 0; //interrupt flag off servoInterrupt(); } } Now we only need to define what will happen inside the servoInterrup() function, i.e. the function that is called every time TIMER0 overflows. We will set D3 to the correct value (1 or 0) depending on whether the pulse is starting or ending. We will also initialize TMR0H and TMR0L to values so that the next overflow appears when a pulse needs to start/stop. This is explained in the following note: This results in the following code: void servoInterrupt(void) { //called on overflow of TIMER0 //create pulse (begin or end of pulse) PORTDbits.RD3 = (pulseOn == 1); //set new TIMER0 value if (pulseOn == 1) { pulseOn = 0; TMR0H = 0xFF & (pulseOnLoad >> 8); TMR0L = 0xFF & pulseOnLoad ; } else { pulseOn = 1; TMR0H = 0xFF & (pulseOffLoad >> 8); TMR0L = 0xFF & pulseOffLoad; } }
Clubblad
8
© vzw TIGEM
PulseOnLoad and PulseOffLoad are set according to the servo angle: void setServoAngle(short angle) { //set new servo value (called from external code) short loadTimer0BeginPulse = 0; short loadTimer0EndPulse = 0; short usPulse; short timerCount; // [2727,6363] =~ [900,2100]*3 servoAngle = angle; usPulse = MIN_PULSE_DURATION + angle*((MAX_PULSE_DURATIONMIN_PULSE_DURATION)/180); timerCount = usPulse * 3; //0.33us = 1/3 us per tick pulseOnLoad = 65534 - timerCount+2; pulseOffLoad = 5538 + timerCount +2; }
Code download You can download the complete code at http://kr3l.wordpress.com/2009/05/02/pic-servocontroller-in-c/. This is an Eclipse project (see my other article on how to use Eclipse for PIC development), but you can import the .c and .h files into MPlab if you like. Note that this project assumes to be loaded onto the PIC with an USB bootloader (see http://kr3l.wordpress.com/2008/11/29/pic18f4455-usb-bootloader/ for details)!
References - http://www.best-microcontroller-projects.com/servo-motor.html gives a very thorough introduction to using a servo with a PIC12F675, though all code is not freely available. My logic is also a bit different: I don’t wait inside the interrupt routine untill the end of the pulse but I set it low using a second interrupt. - http://www.mcmanis.com/chuck/robotics/projects/servo.html gives another introduction to using the servo with a PIC, the code is in assembler. - The PIC datasheet, chapter about TIMER0.
Karel Braeckman
Clubblad
9
© vzw TIGEM
Sfeerbeelden vrijdagavonden
Clubblad
10
© vzw TIGEM
Clubblad
11
© vzw TIGEM
Ledenlijst
Voor een gedetailleerde ledenlijst surft u naar:
www.tigem.be
Erelid ON4CLZ ex-ON1RJ ON7COB ON5YK ON7APG ON5DLG ON8DK ON5ADN ON6UV ON4CDA ON5HA ON4CDI ON5QT ON4LM ON8MA ON4ALU ON4WYR ON4DFR ON3DOE ONVL954 ON4BTW ON6VI ON9CVF ON7WE ON5DTL ON4CBG ON6BIT
DE TROYER WILLY ANDRIES FELICIEN BRAECKMAN KAREL COSYNS KOEN DE COCK JAN DE DOBBELEER GENTIL DE DURPEL GABRIEL DE KEYZER DANNY DESPRETZ EDDY DU LAING ACHIEL FAVYTS LUDO HEUNINCK ALFONS HOFFELINCK MARC HUYLEBROECK MARCEL LAMBRECHT MARC LEMAIRE GEORGES LUYCKX JEAN PONNET WILLY PROVOST CHRISTOPHE ROELANDT MARC SCHOCKAERT PAUL TIELEMANS WILFRIED VAN DE WIELE RENE VAN DEN ABEELE FREDDY VAN DER EECKEN STEFAAN VAN DEN ABBEELE BERT VAN PAMEL WIM WILLEKENS LEOPOLD