Bosch 6000 User's Guide Page 60

  • Download
  • Add to my manuals
  • Print
  • Page
    / 268
  • Table of contents
  • TROUBLESHOOTING
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 59
Chapter 2. Communication
45
Retrieving information from the fast status area using C: The source code
example below is written in Turbo C. If you are using Microsoft C, replace “inport” with
inpw”, replace “outport” with “outw”, replace “inportb” with “inp”, and replace
outportb” with “out”. This example is also provided on the DOS Support Disk in sub-
directory SAMPLES, files TC2ØFAST.C and MC6ØFAST.C.
#include <stdio.h>
#define STATUS 4
#define FASTSTATUS 2
#define REQ_STATUS Øx48
#define CS_UPDATED ØxØ8
#define AXIS1_CMD ØxØØ
#define INO_STATUS Øx25
unsigned int address; /* global address */
void request_status(void)
{
outportb(address+STATUS, REQ_STATUS); /* request fast status update */
/* wait for fast status information to be updated */
while(!(inportb(address+STATUS)&CS_UPDATED));
}
void set_pointer(int status_offset)
{
outportb(address+FASTSTATUS, status_offset);
}
void read_status( unsigned int * status_high; unsigned int * status_low;
unsigned long * status)
{
/* read fast status information */
* status_high = inport(address+FASTSTATUS);
* status_low = inport(address+FASTSTATUS);
/* build status because of low/high ordering */
* status_high = (* status_high<<8) + (* status_high>>8);
* status_low = (* status_low<<8) + (* status_low>>8);
* status = * status_high;
* status = (* status<<16) + * status_low;
}
void main(void)
{
unsigned int word_high, word_low, ino_bits;
unsigned long fast_status;
char pos_storage[2Ø];
char * pos_ptr = &pos_storage[Ø];
int i;
address = 768; /*default address */
request_status();
set_pointer(AXIS1_CMD);
for(i=0;i<4;i++){ /* using auto increment feature of fast status */
read_status(&word_high, &word_low, &fast_status);
ltoa(fast_status, pos_ptr, 1Ø);
cputs(pos_ptr); /* display axis 1, 2, 3,and 4 commanded positions */
cputs("\r\n");
}
set_pointer(INO_STATUS);
read_status(&word_high, &word_low, &fast_status);
ino_bits = word_high;
}
Page view 59
1 2 ... 55 56 57 58 59 60 61 62 63 64 65 ... 267 268

Comments to this Manuals

No comments