by ColdStart » Mon May 16, 2011 4:56 am
by ColdStart
Mon May 16, 2011 4:56 am
ok i have new problems now
1. i have configured my ax12 to give status packet only to READ commands.
2. i have configured the delay time to be 4us, 2 * value in address 0x05, which is 2.
Next i am collecting received data of 8 bytes, from position to temperature using the following interrupt service routine:
- Code: Select all
void __ISR(_UART1_VECTOR, ipl2) IntUart1Handler(void)
{
// Status1();
// Is this an RX interrupt?
if(mU1RXGetIntFlag())
{
// Clear the RX interrupt Flag
mU1RXClearIntFlag();
data[di] = getcUART1();
di+=1;
}
// We don't care about TX interrupt
if ( mU1TXGetIntFlag() )
{
mU1TXClearIntFlag();
}
// Status0();
}
Next, i have another timer interrupt every 10ms, and when that interrupt completes its job, which is indicated by int_done flag, then in my main infinite loop i start moving the ax12 in 4 different positions, back and forth, and also collecting the data. here is a code from pastebin, for some reason here this piece of code does not show up properly:
http://pastebin.com/XHYKER8bdata is declared as unsigned char data[14], di is just index to that data.
What happens is, my motor suddenly stops... and also, when i read the values which it had already written so far, i notice that not far away from a stop...sometimes before stop, sometimes after... it gives me garbage values for position and speed, in other words values are big, more than they should be according to manual.
I tried to see UART1 status error bits, but they were not showing up.
Also, when this thing happens, i tried also putting additional controls inside main loop and start moving it by pressing buttons... it did work! BUT... after few moves from manual button commands, sometimes ax12 stopped with blinking LED.
I want to know at least where could be the error?
WHy do i receive data normally which seems correct, and suddenly after 3-4 minutes of constant operation ax12 stops?
any ideas?
thanks!
also here is readmotor() and moveto0() functions (other move functions are similar)
- Code: Select all
void readmotor(void)
{
DIR1();
putcUART1(0xff); // pakcet TAG
putcUART1(0xff); // packet TAG
putcUART1(0x01); // ID
putcUART1(0x04); // LENGTH
putcUART1(0x02); // READ
putcUART1(0x24); // Start address of Present Position L
putcUART1(0x08); // 8 bytes from start
putcUART1(0xcc); // Checksum
while(BusyUART1());
DIR0();
}
void moveto0(void)
{
DIR1();
putcUART1(0xff); // pakcet TAG
putcUART1(0xff); // packet TAG
putcUART1(0x01); // ID
putcUART1(0x07); // LENGTH
putcUART1(0x03); // WRITE
putcUART1(0x1e); // Start address of Goal Position L
putcUART1(0x00); // 1st byte, Goal Position L
putcUART1(0x00); // 2nd byte, Goal Position H
putcUART1(0x00); // 3rd byte, Moving speed L
putcUART1(0x02); // 4th byte, Moving speed H
putcUART1(0xd4); // Checksum
while(BusyUART1());
DIR0();
}
thank you for any ideas[/url]
ok i have new problems now
1. i have configured my ax12 to give status packet only to READ commands.
2. i have configured the delay time to be 4us, 2 * value in address 0x05, which is 2.
Next i am collecting received data of 8 bytes, from position to temperature using the following interrupt service routine:
- Code: Select all
void __ISR(_UART1_VECTOR, ipl2) IntUart1Handler(void)
{
// Status1();
// Is this an RX interrupt?
if(mU1RXGetIntFlag())
{
// Clear the RX interrupt Flag
mU1RXClearIntFlag();
data[di] = getcUART1();
di+=1;
}
// We don't care about TX interrupt
if ( mU1TXGetIntFlag() )
{
mU1TXClearIntFlag();
}
// Status0();
}
Next, i have another timer interrupt every 10ms, and when that interrupt completes its job, which is indicated by int_done flag, then in my main infinite loop i start moving the ax12 in 4 different positions, back and forth, and also collecting the data. here is a code from pastebin, for some reason here this piece of code does not show up properly:
http://pastebin.com/XHYKER8bdata is declared as unsigned char data[14], di is just index to that data.
What happens is, my motor suddenly stops... and also, when i read the values which it had already written so far, i notice that not far away from a stop...sometimes before stop, sometimes after... it gives me garbage values for position and speed, in other words values are big, more than they should be according to manual.
I tried to see UART1 status error bits, but they were not showing up.
Also, when this thing happens, i tried also putting additional controls inside main loop and start moving it by pressing buttons... it did work! BUT... after few moves from manual button commands, sometimes ax12 stopped with blinking LED.
I want to know at least where could be the error?
WHy do i receive data normally which seems correct, and suddenly after 3-4 minutes of constant operation ax12 stops?
any ideas?
thanks!
also here is readmotor() and moveto0() functions (other move functions are similar)
- Code: Select all
void readmotor(void)
{
DIR1();
putcUART1(0xff); // pakcet TAG
putcUART1(0xff); // packet TAG
putcUART1(0x01); // ID
putcUART1(0x04); // LENGTH
putcUART1(0x02); // READ
putcUART1(0x24); // Start address of Present Position L
putcUART1(0x08); // 8 bytes from start
putcUART1(0xcc); // Checksum
while(BusyUART1());
DIR0();
}
void moveto0(void)
{
DIR1();
putcUART1(0xff); // pakcet TAG
putcUART1(0xff); // packet TAG
putcUART1(0x01); // ID
putcUART1(0x07); // LENGTH
putcUART1(0x03); // WRITE
putcUART1(0x1e); // Start address of Goal Position L
putcUART1(0x00); // 1st byte, Goal Position L
putcUART1(0x00); // 2nd byte, Goal Position H
putcUART1(0x00); // 3rd byte, Moving speed L
putcUART1(0x02); // 4th byte, Moving speed H
putcUART1(0xd4); // Checksum
while(BusyUART1());
DIR0();
}
thank you for any ideas[/url]