bennysong
Posts: 3
Joined: Tue Feb 28, 2017 12:07 pm

Gertbot missed steps

Tue Mar 07, 2017 3:43 pm

Hi,
I'm making a program in C for the gertbot, and i would like to use the linux method get_motor_missed(brd,mot)

Method in linux :

Code: Select all

#
# Get motor missed steps from board
#
# return list with on element: missed steps
# returns empty list on fail 
#
def get_motor_missed(brd,mot) :
   id = (brd<<2) | mot
   wrtbuf = [PRE, CMD_MOT_MISSED, id, POST, POST, POST, POST, POST, POST]
   os.write(filehandle,bytes(wrtbuf))
   # returns 8 bytes:
   # ID, CMD,
   # missed:MS, missed:MM, missed:LS
   # three times 0 
   termios.tcdrain(filehandle)
   ok , rec_data = read_uart(8)
   if (not ok) : # or rec_data[0]!=CMD_MOT_MISSED or rec_data[1]!=dest) :
      return []
   motor_data = [0]*2
   motor_data[0] =(rec_data[2]<<16) + (rec_data[3]<<8)+rec_data[4]
   # Next should be zero 
   motor_data[1] =(rec_data[5]<<16) + (rec_data[6]<<8)+rec_data[7]
   return motor_data 
C - program method
to know: the command to ask for the steps is not included in the C-drives and needs to be added manually.

Code: Select all

#define CMD_MOT_MISSED 0x1C //is not included in C-drives

void get_motor_missed()
{
     char *reply;
     int bytes,error;
     move_stepper(board_XY, MOTOR_X_CHANNEL, STEPS);
     stop_stepper(board_XY, MOTOR_X_CHANNEL, GB_STOP_OFF);
     gb_command7[1] = CMD_MOT_MISSED;
     gb_command7[2] = board <<2;
     gb_command7[3] = CMD_STOP_VAL;
     gb_command7[4] = CMD_STOP_VAL;
     gb_command7[5] = CMD_STOP_VAL;

     int i = write_uart(gb_command7,7);
     bytes = read_uart(&reply, 8);
     printf("Result: bytes %i      data %p", bytes, &reply);
}
As a result i get an 8 bit answer from the gertbot. but every time i run this method i get a different answer from the middle 4 bits.

Result examples

Code: Select all

Example 1:     STEPS = 200
Result: bytes 8     data 0x7ee4f9c8

Example 2:     STEPS = 200
Result: bytes 8     data 0x7ea779c8

Example 3:     STEPS = 200
Result: bytes 8     data 0x7ecc49c8
how can i retrieve the missed steps from the gertbot ?

User avatar
Gert van Loo
Posts: 2487
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Gertbot missed steps

Sun Mar 19, 2017 6:33 pm

Benny,
sorry never saw your post until today.
Tip: put questions about the gertbot in the gertboard classic section. I am subscribed to that.

What is your current status on this?

Return to “Automation, sensing and robotics”