Use rtl_hard_disable_irq(0) to disable the rtl timer interrupt.

To get the higher rates polling is required of the 8254 timers.
Some similar sample code is contained in rtl_time.c and the measurements
example (rt_irq_gen.c).

Also, read the datasheet on the intel 82C54, and sections 3.7, 2.5.2
of the intel 82371 datasheet.

Use a counter set to mode 2 (square wave).

Write a define for a 'read-back' command similar to the 'latch' command
(i.e.. LATCH_CNO).  

Write a define for using the Control Word Register to select and setup a
counter (mode 2): SETUP_COUNTER_ZERO.

Write or use defines similar to WRITE_COUNTER_ZERO16 and
WRITE_COUNTER_ZERO8 to write to the upper and lower byte of the counter.

Do an inline function something like below with pulse_count, and
pulse_state as variables of type 'register'.

#define OUT_STATE 0x80 /* bit 7 is the output pin status bit */

register short int pulse1_count;
register char pulse1_state;
register short int pulse2_count;
register char pulse2_state;

SETUP_COUNTER_ZERO;
WRITE_COUNTER_ZERO8;
WRITE_COUNTER_ZERO16;

I haven't compilied it or checked it for typos, but this is the basic
idea for two motors:

/* set pulse_count1 and pulse_count2 equal to how many steps each motor
should step. */

while (pulse_count1 || pulse_count2){

        oldpulse1_state = pulse1_state;
        oldpulse2_state = pulse2_state;

        READ_BACK_CNT0;
        READ_CNT0(pulse1_state);
        pulse1_state ^= OUT_STATE;
        if ((pulse1_state != oldpulse1_state) && pulse_count1)
                pulse_count1--;
        READ_BACK_CNT1;
        READ_CNT1(pulse2_state);
        pulse2_state ^= OUT_STATE;

        if ((pulse2_state != oldpulse2_state) && pulse_count2)
                pulse_count2--;
        pulse2_state = pulse2_state << 1;
        motor_output = pulse2_state + pulse1_state;
        outb(motor_output,LPT_PORT);

        LATCH_CNT0;
        READ_CNT0(pulse_count1);
        LATCH_CNT1;
        READ_CNT1(pulse_count2);
}


- Kal.


dding wrote:
> 
> -----Original Message-----
> From: Kulwinder Atwal <[EMAIL PROTECTED]>
> To: dding <[EMAIL PROTECTED]>
> Date: 2000年3月13日 10:00
> Subject: Re: [rtl] generate squares
> 
> >You will able to use RTlinux with no extra hardware for motor control.
> >
> >Does each motor require 120 kHZ stepping speed at the same time?
> Yes ! a motor control the x direction the other control the z direction,then
> the knife can
> move along any trace! when the motor require 120Khz the knife (on machine
> tool) only move but do nothing!
> 
> >
> >Does your software also handle some kind of user input and output?
> 
> yes ,but when handling input or output ,the frequency is slow down to
> 30Khz,the RTlinux can
> handle it completely!
> 
> >How does it find out when and for how long to step the motors?
> >
> Maybe no need ,I can get data first and then call the subroutine to do the
> busy-task !
> 
> >- Kal.
> >
> >dding wrote:
> >>
> >> -----Original Message-----
> >> From: Kulwinder Atwal <[EMAIL PROTECTED]>
> >> To: dding <[EMAIL PROTECTED]>
> >> Date: 2000年3月13日 8:08
> >> Subject: Re: [rtl] generate squares
> >>
> >> >how many stepper motors?
> >> Two!
> >> >is there any other device's involved? sensors?
> >> Now no sensors! perhaps future...
> >> >sorry, i have forgotten what is your application?
> >>
> >> Oh ,I only want to generate squares in the highest frequency to test the
> >> RTLinux, if the realtime ability of RTLinux is enough we should use
> RTLinux
> >> as the control system platform to machine tool!
> >> >What are you using the motor for?
> >> >
> >> >- kal.
-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
---
For more information on Real-Time Linux see:
http://www.rtlinux.org/~rtlinux/

Reply via email to