![]() |
![]() |
![]() |
|
|
|||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
|
|
Thread Tools | Display Modes |
|
|
(permalink) |
|
Hi all, i'm really interested in interfacing my 68HC11 MCU with a servo. I've used the mcu for small programs, and only 1 program that interfaces with hardware. It was just a led blinking program using XIRQ and IRQ to change the speed of the blinks.
I'd really appreciate it if someone could give me a little help with this. I'd like the language to be in assembly as that is the only language i understand. From what i understand, i just need a PWM signal, but i have no idea how to create this signal. I have no experience with the timer system, but from what i have read this is information i need for this program. I appreciate the help! |
|
|
|
|
|
|
(permalink) | |
|
Quote:
http://home.earthlink.net/~tdickens/...rvo/servo.html Top of the 68HC11 section of his site: http://home.earthlink.net/~tdickens/68hc11/intro.html Other links: http://www.jimmythegeek.org/james_ra..._servo_pr.html http://www.leang.com/robotics/info/a.../drvservo.html
__________________
========================= Futz's Microcontrollers & Robotics ========================= Last edited by futz; 31st December 2007 at 02:57 AM. |
||
|
|
|
|
|
(permalink) |
|
Thanks for the help futz. I've been to that website, but i wasn't sure which pin ont he MCU board sends out the PWM signal. Basically i don't know how to wire the servo to the mcu.
|
|
|
|
|
|
|
(permalink) | |
|
Quote:
__________________
========================= Futz's Microcontrollers & Robotics ========================= |
||
|
|
|
|
|
(permalink) |
|
To connect a servo to a micro, you connect the servo's red wire to 5V, the black wire to ground and the white wire to signal, or the micro pin. Then you just have to write software to send a variable pulse train to the signal pin to tell the servo where to rotate to.
Those wire colors are typical - not every servo follows this standard exactly. Here's another link with more info and a chart of various servo wire colors: http://wolfstone.halloweenhost.com/M..._RCServos.html Botboard servos are on PA3, PA4, PA5 and PA6, which are the Timer Output Compare (TOC) pins. Tom's code there uses two of those, I think PA5 and PA6. Here's a link to a Botboard PDF with schematic and other details. http://home.earthlink.net/~tdickens/.../botboard1.pdf
__________________
========================= Futz's Microcontrollers & Robotics ========================= Last edited by futz; 2nd January 2008 at 02:53 AM. |
|
|
|
|
|
|
(permalink) |
|
Thanks for helping futz, i hate to make you do so much work. It's getting late so i can't try the program today, but as soon as i get it working i'll report back.
|
|
|
|
|
|
|
(permalink) |
|
One more piece of code that may help:
SERVO8_A.asm And pages 47 and 48 of Karl Lunt's book, Build Your Own Robot have some good info. You may find that the servos draw too much power (they can be greedy, especially when loaded), causing power sags and causing your 68HC11 to reboot when they move. In this case you need to power the servos from a separate power supply. Connect the servo power and ground to the separate power and leave the signal wire on the 68HC11. Be sure to tie the grounds of the 68HC11 and the servo power supply together. It won't work if you don't do that.
__________________
========================= Futz's Microcontrollers & Robotics ========================= Last edited by futz; 31st December 2007 at 03:52 AM. |
|
|
|
|
|
|
(permalink) | |
|
Quote:
__________________
========================= Futz's Microcontrollers & Robotics ========================= |
||
|
|
|
|
|
(permalink) |
|
I've been tinkering with the program, and you are right futz, PA6 and PA5 are the servo connections. So far when the servo's signal wire is connected to PA6 it moves to one direction, and PA5 to another.
I was wondering, is it possible to make the servo move to the left, then to the right, then stop in the middle, using only one of the signals PA6? I'll give it a shot tonight and let you know, i just want to know if that is possible before i attempt it. I don't see why it wouldn't be. |
|
|
|
|
|
|
(permalink) | ||
|
Quote:
Code:
ldx #$0A50 stx $1018 ;Set Timer 2 ldx #$07D0 stx $101a ;Set Timer 3 bra Main I have it all connected up with a Techno Arts MicroStamp11 32K Turbo board and of course it won't run as is. I'm working now on getting it to move servos properly. Quote:
__________________
========================= Futz's Microcontrollers & Robotics ========================= Last edited by futz; 2nd January 2008 at 02:12 AM. |
|||
|
|
|
|
|
(permalink) |
|
It's been ages since I played with an HC11. I'm having to refresh my very foggy memory...
__________________
========================= Futz's Microcontrollers & Robotics ========================= Last edited by futz; 2nd January 2008 at 02:13 AM. |
|
|
|
|
|
|
(permalink) |
|
Hey Arfin. I finally got a servo working on my Microstamp11.
I'm going to post the code here for you, but you should read the following notes if you plan to port the code to your micro. Your 68HC11 is very likely to be an E model or other, and not a D. Therefore the code won't work without some small changes. The MS11 runs a 68HC11D0 (no internal program memory) and gives up two of its ports as address/data bus for 32K of EEPROM in expanded mode. It has only Ports A and D available to the user. MS11 program memory starts at $8000. Yours is probably $b600. MS11 is clocked at 9.8304MHz. Yours is probably 8MHz. The MS11 register block is mapped at $00 to $3f. Yours is probably mapped at $1000 to $103f. MS11 RAM is mapped from $40 to $ff. 192 bytes. Can't remember if other HC11's have the same or more. The location is almost certainly different though. This was Tom Dickens code, but I have heavily modified it to suit. I'm only using OC2 (PA6) to control one servo. Put an LED with current limiting resistor on PD4 - anode to PD4. It will light when the servo is rotated CCW and turn off when servo is rotated CW. It just goes back and forth forever. Does nothing useful at present. My servo may be different than yours. Listen to it carefully when it's at the ends of its travel. If it's stalling at either end you'll have to modify the numbers I'm stuffing into TOC2 in main:. Mine stops a bit before the end stops at each end. If you want the include file just ask. You'd have to modify it to suit your register block mapping (no biggy). Here's a couple pics. The MS11 and breadboard are mounted on an old robot base: Top view Angle view Code:
#include register.inc ORG $8000 start: ldaa #4 ;disable COP in CONFIG register staa CONFIG lds #$00ff ;stack pointer = top of ram ldaa #$ff ;PORTD all outs staa DDRD ldaa #$00 ;init interrupts staa OC1M ;Out compares off staa TCTL2 ;In captures off staa TMSK1 ;Timer interrupts ldaa #$FF staa TFLG1 ;Clear interrupts ldaa #$F0 staa TCTL1 ;T2 T3, set to 1 ldaa #$60 staa CFORC ;Force T2 T3 to 1 ldaa #$50 staa TCTL1 ;T2 T3 set toggle ldaa #$80 staa TMSK2 ;Timer o-flow int staa TFLG2 ;Clear interrupt cli ;Enable interrupts main: ldx #$14ff ;servo full CCW stx TOC2 ;Set Timer 2 bset PORTD,4 ;LED on ldy #$00ff ;delay bsr delay ldx #$0580 ;servo full CW stx TOC2 bclr PORTD,4 ;LED off ldy #$00ff ;delay again bsr delay bra main delay: ldx #$0fff ;inner delay loop delay2: dex bne delay2 dey bne delay rts isr: ldaa #$00 staa TCTL2 ;In captures off ldaa #$F0 staa TCTL1 ;T2 T3, set to 1 ldaa #$60 staa CFORC ;Force T2 T3 to 1 ldaa #$50 staa TCTL1 ;T2 T3 set toggle ldaa #$80 staa TFLG2 ;Clear interrupt flag rti * Interrupt and reset vectors. org $FFD6 SCI_VECT fdb start ;ffd6 SPI_VECT fdb start ;ffd8 PAI_VECT fdb start ;ffda PAO_VECT fdb start ;ffdc TOF_VECT fdb isr ;ffde TOC5_VECT fdb start ;ffe0 TOC4_VECT fdb start ;ffe2 TOC3_VECT fdb start ;ffe4 TOC2_VECT fdb isr ;ffe6 TOC1_VECT fdb start ;ffe8 TIC3_VECT fdb start ;ffea TIC2_VECT fdb start ;ffec TIC1_VECT fdb start ;ffee RTI_VECT fdb start ;fff0 IRQ_VECT fdb start ;fff2 XIRQ_VECT fdb start ;fff4 SWI_VECT fdb start ;fff6 TRAP_VECT fdb start ;fff8 COP_FAIL_VECT fdb start ;fffa COP_CMF_VECT fdb start ;fffc RESET_VECT fdb start ;fffe
__________________
========================= Futz's Microcontrollers & Robotics ========================= Last edited by futz; 3rd January 2008 at 06:58 AM. |
|
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Latest |
| Need help with Intel Assembly Language and PIC16F877 | avinsinanan | Micro Controllers | 10 | 4th March 2008 10:02 AM |
| Separate Assembly Language Forum? | =CrAzYG33K= | Feedback/Comments | 1 | 1st April 2006 11:16 AM |
| Learning Assembly Programming Language | Johnson777717 | Micro Controllers | 4 | 22nd March 2004 02:00 PM |
| learning assembly language | Kurupt | Micro Controllers | 3 | 2nd March 2004 03:19 PM |
| Assembly Language Question | Jeggyman | General Electronics Chat | 6 | 30th January 2004 09:53 PM |