Legacy Forum: Preserving Nearly 20 Years of Community History - A Time Capsule of Discussions, Memories, and Shared Experiences.

AX-12 control with PIC32

Bioloid robot kit from Korean company Robotis; CM5 controller block, AX12 servos..
54 postsPage 3 of 41, 2, 3, 4
54 postsPage 3 of 41, 2, 3, 4

Post by ColdStart » Wed May 18, 2011 6:25 am

Post by ColdStart
Wed May 18, 2011 6:25 am

Thanks Pedro and i-Bot. Here is what i have now.

First of all all my electric connections are right. They are ok and i can communicate with servo and get data via single button/manual commands.

Now, as i said my application moves motor from time to time, and every 10ms requests 8 bytes of information data from motor.

I noticed that sometimes, the request packet never comes full. i.e. it is not returned at all (and that is why it makes my motor stop since its movement depends on the current read data).


Of course few times people here recommended to have a time interrupt to check for that time out.

Lets say i have interrupt which waits for example 10ms, if 8 bytes of data not received, it just issues another command.

But here is a question: In this case, is it guaranteed that the next command will not be messed up? Because i am going to use this motor in some environment in which i wont have access to it for at least hour, and if for some reason after 40 minutes of operation it would screw the second and further commands followed by the timeout then it screws it all...

Or maybe solution would be just wait again... and send new command... will see how it works...
Thanks Pedro and i-Bot. Here is what i have now.

First of all all my electric connections are right. They are ok and i can communicate with servo and get data via single button/manual commands.

Now, as i said my application moves motor from time to time, and every 10ms requests 8 bytes of information data from motor.

I noticed that sometimes, the request packet never comes full. i.e. it is not returned at all (and that is why it makes my motor stop since its movement depends on the current read data).


Of course few times people here recommended to have a time interrupt to check for that time out.

Lets say i have interrupt which waits for example 10ms, if 8 bytes of data not received, it just issues another command.

But here is a question: In this case, is it guaranteed that the next command will not be messed up? Because i am going to use this motor in some environment in which i wont have access to it for at least hour, and if for some reason after 40 minutes of operation it would screw the second and further commands followed by the timeout then it screws it all...

Or maybe solution would be just wait again... and send new command... will see how it works...
ColdStart
Robot Builder
Robot Builder
Posts: 17
Joined: Thu Jan 20, 2011 9:28 am

Post by ColdStart » Wed May 18, 2011 7:11 am

Post by ColdStart
Wed May 18, 2011 7:11 am

and something more about data readings again...

position is always being read as a value less than 1024.

But only for speed and load i get sometimes things like: 1424, 2016...

any ideas why? someone told here it has to do with +/- stuff. But... it does not make much sense in this case because for example sometimes i read things like:

speed = 1216, load = 639... why then load is less than 1024 and speed is not?


(again my motor moves from 0 to 180 and stops for around 500ms every 45 deg, and measurements of position during the whole data acquisition are consistent with what i expect, also temperature and voltage are ok too... but speed and load get crazy! and again... packet comes without error)


p.s. the issue of reliability of movement after delay of data packet is still there.. as described in my previous message.

i think in a whole i have some success, it just issues pop up here and there :)
and something more about data readings again...

position is always being read as a value less than 1024.

But only for speed and load i get sometimes things like: 1424, 2016...

any ideas why? someone told here it has to do with +/- stuff. But... it does not make much sense in this case because for example sometimes i read things like:

speed = 1216, load = 639... why then load is less than 1024 and speed is not?


(again my motor moves from 0 to 180 and stops for around 500ms every 45 deg, and measurements of position during the whole data acquisition are consistent with what i expect, also temperature and voltage are ok too... but speed and load get crazy! and again... packet comes without error)


p.s. the issue of reliability of movement after delay of data packet is still there.. as described in my previous message.

i think in a whole i have some success, it just issues pop up here and there :)
ColdStart
Robot Builder
Robot Builder
Posts: 17
Joined: Thu Jan 20, 2011 9:28 am

Post by Fritzoid » Wed May 18, 2011 1:03 pm

Post by Fritzoid
Wed May 18, 2011 1:03 pm

ColdStart,

Speed and load values above 1024 (0x0400) mean that they are applied in a clockwise direction. Values below 1024 are counterclockwise speeds/loads. The sign of the speed and load values can differ at start up or during the overshoot period.
ColdStart,

Speed and load values above 1024 (0x0400) mean that they are applied in a clockwise direction. Values below 1024 are counterclockwise speeds/loads. The sign of the speed and load values can differ at start up or during the overshoot period.
Fritzoid
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 331
Joined: Mon Dec 18, 2006 1:00 am

Post by def » Sun May 29, 2011 6:54 pm

Post by def
Sun May 29, 2011 6:54 pm

Hello friends
I have kind of similar problem as coldstart.
I'm trying to communicate with my ax-12 with pic18f4550 which i coded as a usb to serial convertor.
I configured it to work at 1mbps.
but when i send a ping to my ax-12, there is no response.
I've used 74ls125 instead of 126, and managed direction port accordingly through my port B pins.
when i enable both the rx and tx, i read back the data i'm sending, that clarifies that data is being sent. but on connecting ax-12, i do not get any response.
Hello friends
I have kind of similar problem as coldstart.
I'm trying to communicate with my ax-12 with pic18f4550 which i coded as a usb to serial convertor.
I configured it to work at 1mbps.
but when i send a ping to my ax-12, there is no response.
I've used 74ls125 instead of 126, and managed direction port accordingly through my port B pins.
when i enable both the rx and tx, i read back the data i'm sending, that clarifies that data is being sent. but on connecting ax-12, i do not get any response.
def
Robot Builder
Robot Builder
Posts: 11
Joined: Sun May 29, 2011 6:49 pm

Post by i-Bot » Mon May 30, 2011 10:59 am

Post by i-Bot
Mon May 30, 2011 10:59 am

I have not used the 18f4550 with AX12, but I guess it will work OK.

It was fairly easy to help coldstart because he carefully described his problems and his current status after he did lot of testing. We might help you too if you follow his method.

First things to check:

1) Is the baud rate of the AX12 set to 1Mbps ? 1M is not the default.
2) Did you set the PIC UART speed correctly to 1M. What are Fosc and divider setings ?
3) HC126 or HC125 is preferred over LS. LS is out of spec, but may work.
4) Do you have pullups to 5V on the 125 outputs ?
3) Is your control over the 125 correct ?
4) Do you wait until the output shift register is empty (TRMT flag) before switching direction ?
5) Is the ping command correct and good checksum ?
I have not used the 18f4550 with AX12, but I guess it will work OK.

It was fairly easy to help coldstart because he carefully described his problems and his current status after he did lot of testing. We might help you too if you follow his method.

First things to check:

1) Is the baud rate of the AX12 set to 1Mbps ? 1M is not the default.
2) Did you set the PIC UART speed correctly to 1M. What are Fosc and divider setings ?
3) HC126 or HC125 is preferred over LS. LS is out of spec, but may work.
4) Do you have pullups to 5V on the 125 outputs ?
3) Is your control over the 125 correct ?
4) Do you wait until the output shift register is empty (TRMT flag) before switching direction ?
5) Is the ping command correct and good checksum ?
i-Bot
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 1142
Joined: Wed May 17, 2006 1:00 am

Post by def » Mon May 30, 2011 2:13 pm

Post by def
Mon May 30, 2011 2:13 pm

hey i-bot!! thanx for replying
i'm using the codes which come readymade for picdem fs usb in microchip applications.
so clock frequency is 48MHz

1) Is the baud rate of the AX12 set to 1Mbps ? 1M is not the default.
--AX-12 manual says baud rate of AX12 are by default set to 1Mbps

2) Did you set the PIC UART speed correctly to 1M. What are Fosc and divider setings ?
-- TXSTA = 0x24; // TX enable BRGH=1
RCSTA = 0x90; // Single Character RX
SPBRG = 11;
SPBRGH = 0; // 0x000b for 48MHz -> 1M baud

3) HC126 or HC125 is preferred over LS. LS is out of spec, but may work.
--LS125 is working fine. i checked by transmitting and receiving at the same time while given enable pin zero to both the buffers for rx and tx.

4) Do you have pullups to 5V on the 125 outputs ?
--yes i have 10k pullup to pull the level to 5v

3) Is your control over the 125 correct ?
--yes control is correct, i've checked communication at 9600 baud using pickit 2 uart tool.

4) Do you wait until the output shift register is empty (TRMT flag) before switching direction ?
--yeah i have taken care of this thing.

5) Is the ping command correct and good checksum ?
--as far as i know i used correct command. i used
ff ff 01 02 01 fb

moreover i tried with dynamixel wizard and dynamixel commander as well.
but no luck.
I cannot figure out whats going wrong.

[/quote]
hey i-bot!! thanx for replying
i'm using the codes which come readymade for picdem fs usb in microchip applications.
so clock frequency is 48MHz

1) Is the baud rate of the AX12 set to 1Mbps ? 1M is not the default.
--AX-12 manual says baud rate of AX12 are by default set to 1Mbps

2) Did you set the PIC UART speed correctly to 1M. What are Fosc and divider setings ?
-- TXSTA = 0x24; // TX enable BRGH=1
RCSTA = 0x90; // Single Character RX
SPBRG = 11;
SPBRGH = 0; // 0x000b for 48MHz -> 1M baud

3) HC126 or HC125 is preferred over LS. LS is out of spec, but may work.
--LS125 is working fine. i checked by transmitting and receiving at the same time while given enable pin zero to both the buffers for rx and tx.

4) Do you have pullups to 5V on the 125 outputs ?
--yes i have 10k pullup to pull the level to 5v

3) Is your control over the 125 correct ?
--yes control is correct, i've checked communication at 9600 baud using pickit 2 uart tool.

4) Do you wait until the output shift register is empty (TRMT flag) before switching direction ?
--yeah i have taken care of this thing.

5) Is the ping command correct and good checksum ?
--as far as i know i used correct command. i used
ff ff 01 02 01 fb

moreover i tried with dynamixel wizard and dynamixel commander as well.
but no luck.
I cannot figure out whats going wrong.

[/quote]
def
Robot Builder
Robot Builder
Posts: 11
Joined: Sun May 29, 2011 6:49 pm

Post by i-Bot » Mon May 30, 2011 3:05 pm

Post by i-Bot
Mon May 30, 2011 3:05 pm

Just a few ideas:

1) 1Mbps is the reset default, but I think most are shipped with a lower speed.

2) Shouldn't the baud rate divisor be 2 ? (= 48 / 16 - 1). As I said I don't use 18F4550 myself, but I got that from datasheet.

3) LS will work to itself, but the AX12 is using HC, so min V input high is 3.5V, min V out high of LS is 2.7V.

When you say the wizard does not work is that with a USB2Dynamixel ? You really need that to check the AX12 baud rate.
How are you powering the AX12 ?
Just a few ideas:

1) 1Mbps is the reset default, but I think most are shipped with a lower speed.

2) Shouldn't the baud rate divisor be 2 ? (= 48 / 16 - 1). As I said I don't use 18F4550 myself, but I got that from datasheet.

3) LS will work to itself, but the AX12 is using HC, so min V input high is 3.5V, min V out high of LS is 2.7V.

When you say the wizard does not work is that with a USB2Dynamixel ? You really need that to check the AX12 baud rate.
How are you powering the AX12 ?
i-Bot
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 1142
Joined: Wed May 17, 2006 1:00 am

Post by def » Mon May 30, 2011 4:45 pm

Post by def
Mon May 30, 2011 4:45 pm

1) 1Mbps is the reset default, but I think most are shipped with a lower speed.
--as far as i know, ax-12 are shipped with 1Mbps default, and to change it to lower bit rate, it need to be communicated atleast once at 1Mbps and change the register settings for baudrate.

2) Shouldn't the baud rate divisor be 2 ? (= 48 / 16 - 1). As I said I don't use 18F4550 myself, but I got that from datasheet.
--this formula is used when we use BRGH=0, I'm using BRGH=1; for that it is 48/4(11+1)=1Mbps

3) LS will work to itself, but the AX12 is using HC, so min V input high is 3.5V, min V out high of LS is 2.7V.
--this can be one reason, but I tried just connecting the TX pin to dynamixel directly without buffer and tried to glow the LED, even that did not work.


When you say the wizard does not work is that with a USB2Dynamixel ? You really need that to check the AX12 baud rate.
How are you powering the AX12 ?
--No i do not have a USB2Dynamixel, since it uses just a usb to serial convertor, so any usb to serial convertor with 1Mbps baud should work fine with a little bit of tuning.
I'm powering ax-12 with a 9 volt adaptor
1) 1Mbps is the reset default, but I think most are shipped with a lower speed.
--as far as i know, ax-12 are shipped with 1Mbps default, and to change it to lower bit rate, it need to be communicated atleast once at 1Mbps and change the register settings for baudrate.

2) Shouldn't the baud rate divisor be 2 ? (= 48 / 16 - 1). As I said I don't use 18F4550 myself, but I got that from datasheet.
--this formula is used when we use BRGH=0, I'm using BRGH=1; for that it is 48/4(11+1)=1Mbps

3) LS will work to itself, but the AX12 is using HC, so min V input high is 3.5V, min V out high of LS is 2.7V.
--this can be one reason, but I tried just connecting the TX pin to dynamixel directly without buffer and tried to glow the LED, even that did not work.


When you say the wizard does not work is that with a USB2Dynamixel ? You really need that to check the AX12 baud rate.
How are you powering the AX12 ?
--No i do not have a USB2Dynamixel, since it uses just a usb to serial convertor, so any usb to serial convertor with 1Mbps baud should work fine with a little bit of tuning.
I'm powering ax-12 with a 9 volt adaptor
def
Robot Builder
Robot Builder
Posts: 11
Joined: Sun May 29, 2011 6:49 pm

Post by i-Bot » Mon May 30, 2011 10:23 pm

Post by i-Bot
Mon May 30, 2011 10:23 pm

Does the led flash when you power up the AX12 ?

How did you check the ID of the servo ?
so any usb to serial convertor with 1Mbps baud should work fine with a little bit of tuning.


Can you expand on what you tried ? I have never had a problem using any FTDI based usb to serial with the buffer tristate enables linked to TXDEN.
Does the led flash when you power up the AX12 ?

How did you check the ID of the servo ?
so any usb to serial convertor with 1Mbps baud should work fine with a little bit of tuning.


Can you expand on what you tried ? I have never had a problem using any FTDI based usb to serial with the buffer tristate enables linked to TXDEN.
i-Bot
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 1142
Joined: Wed May 17, 2006 1:00 am

Post by i-Bot » Mon May 30, 2011 10:23 pm

Post by i-Bot
Mon May 30, 2011 10:23 pm

Does the led flash when you power up the AX12 ?

How did you check the ID of the servo ?
so any usb to serial convertor with 1Mbps baud should work fine with a little bit of tuning.


Can you expand on what you tried ? I have never had a problem using any FTDI based usb to serial with the buffer tristate enables linked to TXDEN.
Does the led flash when you power up the AX12 ?

How did you check the ID of the servo ?
so any usb to serial convertor with 1Mbps baud should work fine with a little bit of tuning.


Can you expand on what you tried ? I have never had a problem using any FTDI based usb to serial with the buffer tristate enables linked to TXDEN.
i-Bot
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 1142
Joined: Wed May 17, 2006 1:00 am

Post by def » Tue May 31, 2011 4:57 am

Post by def
Tue May 31, 2011 4:57 am

yes my led flashes when i power up.

robotis says default ID of servo is 1, so i am using that

for usb to serial convertor, i'm not using FTDI, rather i've programmed my pic18f4550 as usb to serial convertor.

the major problem is i've lost my logic analyser, otherwise all the scenario would have been more clear.

the adaptor i'm using is a variable adaptor with vout 1.5 to 12v adjustable and 500ma rated current; will this current be a problem? as ax-12 are rated 800ma.
yes my led flashes when i power up.

robotis says default ID of servo is 1, so i am using that

for usb to serial convertor, i'm not using FTDI, rather i've programmed my pic18f4550 as usb to serial convertor.

the major problem is i've lost my logic analyser, otherwise all the scenario would have been more clear.

the adaptor i'm using is a variable adaptor with vout 1.5 to 12v adjustable and 500ma rated current; will this current be a problem? as ax-12 are rated 800ma.
def
Robot Builder
Robot Builder
Posts: 11
Joined: Sun May 29, 2011 6:49 pm

Post by i-Bot » Tue May 31, 2011 10:33 am

Post by i-Bot
Tue May 31, 2011 10:33 am

Robotis programs which talk to the CM5/CM510 can use almost any different USB serial converters. Robotis programs which talk direct to servos require an FTDI converter and use FTDI drivers to set the speed etc.
Robotis programs which talk to the CM5/CM510 can use almost any different USB serial converters. Robotis programs which talk direct to servos require an FTDI converter and use FTDI drivers to set the speed etc.
Last edited by i-Bot on Tue May 31, 2011 10:42 am, edited 1 time in total.
i-Bot
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 1142
Joined: Wed May 17, 2006 1:00 am

Post by def » Tue May 31, 2011 10:40 am

Post by def
Tue May 31, 2011 10:40 am

does that mean my problem stays solved if i use FTDI?

but i've tried manually sending the ping with a push button programmed to send the command, still i do not get any reply from ax-12
what might be the problem?

i'll give it a try with ftdi also
does that mean my problem stays solved if i use FTDI?

but i've tried manually sending the ping with a push button programmed to send the command, still i do not get any reply from ax-12
what might be the problem?

i'll give it a try with ftdi also
def
Robot Builder
Robot Builder
Posts: 11
Joined: Sun May 29, 2011 6:49 pm

Post by i-Bot » Tue May 31, 2011 11:09 am

Post by i-Bot
Tue May 31, 2011 11:09 am

I have had AX12 arrive in different states of configuration (baud, ID). I just think it is good idea to check with an FTDI/USB2Dynamixel and Dynamixel Manager.
I have had AX12 arrive in different states of configuration (baud, ID). I just think it is good idea to check with an FTDI/USB2Dynamixel and Dynamixel Manager.
i-Bot
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 1142
Joined: Wed May 17, 2006 1:00 am

Post by def » Tue May 31, 2011 11:25 am

Post by def
Tue May 31, 2011 11:25 am

basically what a dynamixel manager does is it checks for all the possible baud rates possible for a dynamixel, it works with FTDI as after searching at one baud rate, it sends usb setup packets for configuring the FTDI for next baud rate, and then it agains checks for all the IDs at that baud rate, I think it is possible to get my pic18f4550 to work exactly as FTDI, i'll configure it to use those setup packets for changing its own baud rate.
But as of now as you said, the problem might be with baud rate and ID.
what I can try is program my 18f4550 for one baud rate, broadcast some action, then one next baud rate, atleast that will give an idea if my logic is working or not.
I think it'll be ok, just to connect tx pin to data pin of ax-12 and broadcast instruction for glowing led or rotating to some angle.
basically what a dynamixel manager does is it checks for all the possible baud rates possible for a dynamixel, it works with FTDI as after searching at one baud rate, it sends usb setup packets for configuring the FTDI for next baud rate, and then it agains checks for all the IDs at that baud rate, I think it is possible to get my pic18f4550 to work exactly as FTDI, i'll configure it to use those setup packets for changing its own baud rate.
But as of now as you said, the problem might be with baud rate and ID.
what I can try is program my 18f4550 for one baud rate, broadcast some action, then one next baud rate, atleast that will give an idea if my logic is working or not.
I think it'll be ok, just to connect tx pin to data pin of ax-12 and broadcast instruction for glowing led or rotating to some angle.
def
Robot Builder
Robot Builder
Posts: 11
Joined: Sun May 29, 2011 6:49 pm

PreviousNext
54 postsPage 3 of 41, 2, 3, 4
54 postsPage 3 of 41, 2, 3, 4