The Philippine Electronics and Technology Forum
February 09, 2012, 10:35:33 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Login Register  

Pages: [1]   Go Down
  Print  
Author Topic: help program po nmen yan s tower pro servo z8f082a, 28 pins  (Read 916 times)
daxz
CR2032 Battery
**

Pogi/Ganda Points: 0
Offline Offline

Posts: 12


« on: January 04, 2010, 11:02:33 PM »

#include<ez8.h>
#include<sio.h>

void init_timer0(void);
extern void interrupt isr_timer0(void);
void delay_ms(unsigned int count);

void init_timer1(void);
extern void interrupt isr_timer1(void);
void delay1500();

int ctr, ctr2;



void init_UART0(void)
   {
     U0BRH = 0x00;               
     U0BRL = 0x24;               

     PAADDR = 0x02;               
     PAAF = 0x30;               

     U0CTL0 = 0xC0;                
                                 
     U0CTL1 = 0x00;               
   }


void main(void)
   {
   PBADDR=0x01;
   PBDD=0x00;

   init_UART0();

   DI();
   init_timer0();
   init_timer1();
   EI();

   

   while(1)
      {
      if(U0RXD=='3')
         {
         PBOUT |= 0x01; // clockwise
         delay_ms(1);
         PBOUT &= 0xFE;
         delay_ms(19);
         }

      if(U0RXD=='4')
         {
         PBOUT |= 0x01; // countercw
         delay_ms(2);
         PBOUT &= 0xFE;
         delay_ms(18);
         
         }
      }
}

////////////////////////////TIMER PURPOSES///////////////////////////////////

void init_timer0(void)
   {
   SET_VECTOR(TIMER0, isr_timer0);
   T0CTL1 = 0x29;               /// continuous mode: prescaler of 32
                           /// internal oscillator of 5529600 Hz
   T0RH = 0x00;               
   T0RL = 0xAD;               /// reload value of 173

   T0H = 0x00;                  /// delay of 1.0012 ms
   T0L = 0x01;

   IRQ0ENH |= 0x20;            /// timer 0 enable
   IRQ0ENL &= 0xDF;
   }

//-----------------------------------------------------//

#pragma interrupt

void isr_timer0(void)
   {
   ctr++;
   }

//-----------------------------------------------------//

void delay_ms(unsigned int count)
   {
   ctr = 0;
   T0CTL1 |= 0x80;
   while (ctr < count)
      {}
   T0CTL1 &= 0x7F;
   }

help nmn po mga sir... program po nmen yan s tower pro servo z8f082a, 28 pins.. the problem is ayaw po nia tumigil.. continuous nmn po siya,, ano po kya ang mali sa program or dapat namen idagdag para tumigil??/
maraming salamat po sa lahat..
GodbLess..
Logged
The Philippine Electronics and Technology Forum
« on: January 04, 2010, 11:02:33 PM »

 Logged
'yus
Technical People
Nuclear Reactor
*****

Pogi/Ganda Points: 274
Offline Offline

Gender: Male
Posts: 4170


oops, kernel panic!


WWW
« Reply #1 on: January 05, 2010, 12:39:40 PM »

mukhag dun sa "isr_timer0" interrupt routine ang problema.
kelangan pa atang i-clear yung interrupt request after ma-service yung interrupt.
Logged

join PhilRobotics - Amateur Robotics Club of the Philippines
daxz
CR2032 Battery
**

Pogi/Ganda Points: 0
Offline Offline

Posts: 12


« Reply #2 on: January 06, 2010, 08:37:51 AM »

sir yus.. wat do you mean po... pano po icclear ung interrupt?
newbie po kc ko dito sa z8..
Logged
'yus
Technical People
Nuclear Reactor
*****

Pogi/Ganda Points: 274
Offline Offline

Gender: Male
Posts: 4170


oops, kernel panic!


WWW
« Reply #3 on: January 06, 2010, 12:29:39 PM »

... pano po icclear ung interrupt?
...

example:
Code:
//....
#pragma interrupt
void isr_timer0(void)
{
     ctr++;
     IRQ0 &= ~0x20;  // clear Timer 0 Interrupt Request bit
}
//....
Logged

join PhilRobotics - Amateur Robotics Club of the Philippines
daxz
CR2032 Battery
**

Pogi/Ganda Points: 0
Offline Offline

Posts: 12


« Reply #4 on: January 06, 2010, 01:41:31 PM »

sir yus... ganon pa rin po.. wala pa rin pong pagbabago.. sana matulungan nio po kme...
Logged
'yus
Technical People
Nuclear Reactor
*****

Pogi/Ganda Points: 274
Offline Offline

Gender: Male
Posts: 4170


oops, kernel panic!


WWW
« Reply #5 on: January 06, 2010, 06:12:29 PM »

'bat dun sa "main()" mo halos magkapareho lang yung ini-execute ng dalang "if" condidtion:
Quote
Code:
void main(void)
   {
.....
   while(1)
      {
      if(U0RXD=='3')
         {
         PBOUT |= 0x01; // clockwise
         delay_ms(1);
         PBOUT &= 0xFE;
         delay_ms(19);
         }

      if(U0RXD=='4')
         {
         PBOUT |= 0x01; // countercw
         delay_ms(2);
         PBOUT &= 0xFE;
         delay_ms(18);
         
         }
      }
}

yung timer0 and timer1, saan mo ginagamit? sa "delay" function lang ba?
kung sa "delay" lang, (temporarily) 'wag ka munang gumamit ng timer (and timer interrupt),
para madaling ma-debug ang code.
gamit ka muna ng simple "counter".
Logged

join PhilRobotics - Amateur Robotics Club of the Philippines
daxz
CR2032 Battery
**

Pogi/Ganda Points: 0
Offline Offline

Posts: 12


« Reply #6 on: January 06, 2010, 07:07:03 PM »

meaning po hindi n ko gagamit ng timer? mpapatakbo p rin b ang servo khit alang timer?
Logged
'yus
Technical People
Nuclear Reactor
*****

Pogi/Ganda Points: 274
Offline Offline

Gender: Male
Posts: 4170


oops, kernel panic!


WWW
« Reply #7 on: January 06, 2010, 07:14:27 PM »

.... mpapatakbo p rin b ang servo khit alang timer?
pwede kahit walang timer.
Logged

join PhilRobotics - Amateur Robotics Club of the Philippines
daxz
CR2032 Battery
**

Pogi/Ganda Points: 0
Offline Offline

Posts: 12


« Reply #8 on: January 06, 2010, 07:19:19 PM »

pano po gagawin??? magdedeclare lang po b kmi ng ctr??
Logged
daxz
CR2032 Battery
**

Pogi/Ganda Points: 0
Offline Offline

Posts: 12


« Reply #9 on: January 06, 2010, 07:20:54 PM »

sir yus sana po matulungan nio kmi... defens n po kc nmin sa monday.. maraming salamat po talaga...
Logged
'yus
Technical People
Nuclear Reactor
*****

Pogi/Ganda Points: 274
Offline Offline

Gender: Male
Posts: 4170


oops, kernel panic!


WWW
« Reply #10 on: January 06, 2010, 07:33:59 PM »

meron na pala dito:
Delay in Z8 encore/b]
Logged

join PhilRobotics - Amateur Robotics Club of the Philippines
The Philippine Electronics and Technology Forum
   

 Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  


Related Topics
Subject Started by Replies Views Last post
Z8F082A 28 PINS ENCORE! XP CONTROLLER IN SERVO SEQUENCER
Zilog Microcontrollers
servomechaniX 11 1661 Last post April 17, 2008, 07:14:08 PM
by servomechaniX
Sir/Mam, what emulator po na compatible para sa Z8F082A 28 pins.? ???
Zilog Microcontrollers
Newbie 1 700 Last post November 19, 2008, 05:41:33 PM
by SpongeBob
Controlling 6 Servomotors using 2 timers and 6 GPIO pins of Z8f082A
Zilog Microcontrollers
abyssinian 4 809 Last post October 29, 2009, 08:12:40 AM
by abyssinian
tower pro 9805bb servo
ECE Students
daxz 0 490 Last post December 29, 2009, 06:01:20 PM
by daxz
where to buy tower pro sg 50-10 servo motor
PIC Microcontrollers
reymer555 5 98 Last post January 20, 2011, 02:59:32 PM
by reymer555
2 pins high program
Atmel Microcontrollers
jaireh 1 72 Last post March 07, 2011, 10:29:34 PM
by jaireh
Help... Z8F082A 28 pins Encore XP program,ADC-if else-desire 8-bit output
Microcontroller/Microprocessor Unit Projects and Programming
Marky21 11 205 Last post February 03, 2012, 10:30:47 AM
by ΔЅịMø
Powered by MySQL Powered by PHP Powered by SMF 1.1.15 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!