2

Author Topic: Axon I Programming Motors go back and forward ( Newbie )  (Read 2797 times)

0 Members and 1 Guest are viewing this topic.

Offline 325ciTopic starter

  • Jr. Member
  • **
  • Posts: 24
  • Helpful? 0
Axon I Programming Motors go back and forward ( Newbie )
« on: September 16, 2010, 05:37:47 PM »
I'm working on a project and I'm not familiar with the Axon MC, I have 2 motors and for now I need to get the motors go back and forward. I have no clue how to setup this MC. I read and watched the Webbotlib but i do not know if i can use that on Axon I or not.
Do i need a motor controller or can i just use some BJT's on a breadboard and go from MC to breadboard than to motors.\
I just have no clue where to start at?
Thank you in advance for the helps.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,658
  • Helpful? 169
    • Society of Robots
Re: Axon I Programming Motors go back and forward ( Newbie )
« Reply #1 on: September 17, 2010, 06:40:22 AM »
Yeap, you can use WebbotLib for the original Axon.

Download and run WebbotLib Project Designer.

click:
File -> New -> Axon

It'll load up a picture of the Axon. Now on the left you'll see a list of 'Devices' . . . open up 'Actuators' and choose what you want.

If you are just using servos, choose 'Servo Driver'. The others are for various types of motor drivers. If you don't have a servo, you'll need to get a motor driver. I personally recommend the Sabertooth by DimensionEngineering.com.

Here is an example with the Axon II:

Axon 2, Webbotlib and Project Designer Tutorial

Offline 325ciTopic starter

  • Jr. Member
  • **
  • Posts: 24
  • Helpful? 0
Re: Axon I Programming Motors go back and forward ( Newbie )
« Reply #2 on: September 18, 2010, 06:33:10 PM »
Very cooL, i got that webbotlib but it says that i need to import this in my main C. I don't have a main C or anything :)
(newbie)
:)

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,658
  • Helpful? 169
    • Society of Robots
Re: Axon I Programming Motors go back and forward ( Newbie )
« Reply #3 on: September 18, 2010, 06:47:45 PM »
After you load up AVR Studio with the file that PD (project designer) created for you, look at the .c file.

You'll see this line:
TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart) {

This is where your main starts, and where your code should go.

See example.txt in your folder after PD generates your code to see examples on how to use each device you programmed in.

Offline 325ciTopic starter

  • Jr. Member
  • **
  • Posts: 24
  • Helpful? 0
Re: Axon I Programming Motors go back and forward ( Newbie )
« Reply #4 on: September 19, 2010, 12:46:55 PM »
very nice ! Thank you for the replies. will probably ask more in future :)

Offline 325ciTopic starter

  • Jr. Member
  • **
  • Posts: 24
  • Helpful? 0
Re: Axon I Programming Motors go back and forward ( Newbie )
« Reply #5 on: October 05, 2010, 07:03:28 PM »
webbotlib project designer does not open up the sabertooth model for some reason. any chance someone can explain why please.
Thank you

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,132
  • Helpful? 109
Re: Axon I Programming Motors go back and forward ( Newbie )
« Reply #6 on: October 05, 2010, 07:10:18 PM »
What do you mean by '...does not open up the sabertooth model...' ?

Do you mean that you cannot see it in the list or what?
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline 325ciTopic starter

  • Jr. Member
  • **
  • Posts: 24
  • Helpful? 0
Re: Axon I Programming Motors go back and forward ( Newbie )
« Reply #7 on: October 05, 2010, 07:24:26 PM »
when you drag and drop it wont come up.all the other ones does except the sabertooth.

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,132
  • Helpful? 109
Re: Axon I Programming Motors go back and forward ( Newbie )
« Reply #8 on: October 05, 2010, 07:57:50 PM »
when you drag and drop it wont come up.all the other ones does except the sabertooth.

Re-run Project Designer again (whilst online to get latest version) and try again. Should now work.
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline 325ciTopic starter

  • Jr. Member
  • **
  • Posts: 24
  • Helpful? 0
Re: Axon I Programming Motors go back and forward ( Newbie )
« Reply #9 on: October 06, 2010, 09:29:42 AM »
it works again. Thank you so much.
For some reason though the code i generate from webbot, does not move my motors. I don't know where i'm doing wrong.
All i do is drag and drop the sabertooth on the webbot project, then set it up. generate the code, using avr studio build a .hex file and using fboot upload it to axon MC. after rebooting the device it does not do anything. suppose to go 10 sec. front and all that.

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,132
  • Helpful? 109
Re: Axon I Programming Motors go back and forward ( Newbie )
« Reply #10 on: October 06, 2010, 09:51:03 AM »
Dont forget that when you run Tools|Generate for the first time then it creates your main C file.
Subsequent Tools|Generate will leave your main C file alone (otherwise it might delete all of the code that you have added by hand). Instead it writes the code into example.txt. So take a look in that file and compare (or cut/paste) the code into your main C file. Recompile and upload.
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline 325ciTopic starter

  • Jr. Member
  • **
  • Posts: 24
  • Helpful? 0
Re: Axon I Programming Motors go back and forward ( Newbie )
« Reply #11 on: October 07, 2010, 11:15:32 AM »
ohhh i didn't know that. ( NEWBIE ) I always just build the .c file right away without comparing the example txt, weLL i will try it tonight when i get home.
Thank you so much for the help btw, lot of helpful people in here. Appreciate it a lot.

Offline 325ciTopic starter

  • Jr. Member
  • **
  • Posts: 24
  • Helpful? 0
Re: Axon I Programming Motors go back and forward ( Newbie )
« Reply #12 on: October 10, 2010, 09:19:03 AM »
I have these sensors;
http://www.robotshop.com/hitec-distance-sensor-1.html

there is no sample code or this sensor on webbot designer? any clue if they are similar to any of the ones from webbot designer?

By the way got the robot running with sabertooth 2x5 now. Thank you for the helps...

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,658
  • Helpful? 169
    • Society of Robots
Re: Axon I Programming Motors go back and forward ( Newbie )
« Reply #13 on: October 10, 2010, 09:57:53 AM »
I have these sensors;
http://www.robotshop.com/hitec-distance-sensor-1.html

there is no sample code or this sensor on webbot designer? any clue if they are similar to any of the ones from webbot designer?

Add it as an analog sensor from the basic section.

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,132
  • Helpful? 109
Re: Axon I Programming Motors go back and forward ( Newbie )
« Reply #14 on: October 10, 2010, 10:01:36 AM »
As far as I can tell it may just be a digital sensor:
The sensor output is logic high when an object falls within the detection range (15cm). When no object is inside the detection range, a logic low is output.
In which case you could just add it as a basic Digital Input Pin.
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline 325ciTopic starter

  • Jr. Member
  • **
  • Posts: 24
  • Helpful? 0
Re: Axon I Programming Motors go back and forward ( Newbie )
« Reply #15 on: October 10, 2010, 10:24:59 AM »
Got it !! i just used the top one from the webbot list and it worked with usage of
distanceread(distance);
if (distance.distance.cm==10) .....

Thanks though !
you guys are good

Offline 325ciTopic starter

  • Jr. Member
  • **
  • Posts: 24
  • Helpful? 0
Re: Axon I Programming Motors go back and forward ( Newbie )
« Reply #16 on: October 12, 2010, 06:00:47 PM »
I have a big problem !!!!
even though i put my code inside of while loop it jumps out of it or resets or something.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,658
  • Helpful? 169
    • Society of Robots
Re: Axon I Programming Motors go back and forward ( Newbie )
« Reply #17 on: October 12, 2010, 06:54:10 PM »
You forgot to post your while loop code ;)

Offline 325ciTopic starter

  • Jr. Member
  • **
  • Posts: 24
  • Helpful? 0
Re: Axon I Programming Motors go back and forward ( Newbie )
« Reply #18 on: October 13, 2010, 07:11:12 AM »
It works only 3,4 times then jumps out of loop and just keeps going forward. Then I turn it off then turn it on again and it won't work at all.
Reboot again and it works for 3,4 times getting the sensor read and work, then gets out of while loop i assume because it keeps going forward after couple interrupts.

while(1)
{
distanceRead(distance);
if(distance.distance.cm <=10)
{
act_setSpeed(&motorR,80);
act_setSpeed(&motorL,190);
}
else if(distance.distance.cm >10){
act_setSpeed(&motorR,0);
act_setSpeed(&motorL,255);
}
}

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,658
  • Helpful? 169
    • Society of Robots
Re: Axon I Programming Motors go back and forward ( Newbie )
« Reply #19 on: October 13, 2010, 07:50:49 AM »
How do you know it exits the while loop? (it's impossible in this code)

Do the motors stop turning? (did you check your batteries?)

Put a few lines of rprintf("test position 1"); code in your while loop and see where stuff freezes.

Offline 325ciTopic starter

  • Jr. Member
  • **
  • Posts: 24
  • Helpful? 0
Re: Axon I Programming Motors go back and forward ( Newbie )
« Reply #20 on: October 13, 2010, 07:59:54 AM »
that's another problem !
yes it is impossible to jump out of this code but like sensors read 2,3 times and gets the motors activated as it suppose to do. but after few times, even thought motor dont suppose to run, it just starts to go forward forever.
if i do print things i can't read it because i don't know how to simulate it. all i do is generate the hex file and upload it to the MC. Don't know how to read it back using print commands.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,658
  • Helpful? 169
    • Society of Robots
Re: Axon I Programming Motors go back and forward ( Newbie )
« Reply #21 on: October 13, 2010, 08:14:41 AM »
I suspect you aren't getting the sensor data you expect.

Use Hyperterminal:
http://www.societyofrobots.com/programming_data_logging.shtml

and add this line to your code after distanceRead to output sensor data:
rprintf("\n%d",distance.distance.cm);

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,132
  • Helpful? 109
Re: Axon I Programming Motors go back and forward ( Newbie )
« Reply #22 on: October 13, 2010, 10:54:46 AM »
Your calls to act_setSpeed may not be doing what you think.
The library expects a value in the range -127 to 127 where:-
-127 = full reverse
0 = stop
+127 = full forward

Also you just chose a distance sensor at random and then said 'it works'.  I'm guessing what you meant was 'it compiles' - which of course it would do. Which sensor 'exactly' did you use?

Follow admins advice about adding rprintf statements and once you've got it sending stuff to your PC then also add a 'distanceDump(distance);'
This will dump out the value returned by the sensor and I'll bet it is giving weird values.


Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline 325ciTopic starter

  • Jr. Member
  • **
  • Posts: 24
  • Helpful? 0
Re: Axon I Programming Motors go back and forward ( Newbie )
« Reply #23 on: October 13, 2010, 11:39:26 AM »
well I just used the top IR sensor from the webbot project designer. but i thought it would be wrong then i used just a basic digital output which is only 0 and 1 and its still doing the same thing.
im gonna try that hyperterminal and let you guys know again.

for the values, motor 2 is reverseable,
Motor #1 is
0-127 where 127 is full forward and 0 stops
Motor#2 is reversable and
128-255 where 128 is full forward and 255 stops

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,658
  • Helpful? 169
    • Society of Robots
Re: Axon I Programming Motors go back and forward ( Newbie )
« Reply #24 on: October 13, 2010, 12:09:41 PM »
for the values, motor 2 is reverseable,
Motor #1 is
0-127 where 127 is full forward and 0 stops
Motor#2 is reversable and
128-255 where 128 is full forward and 255 stops
The WebbotLib motor command takes a signed int, meaning its from -127 to 127.

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,132
  • Helpful? 109
Re: Axon I Programming Motors go back and forward ( Newbie )
« Reply #25 on: October 13, 2010, 01:22:13 PM »
for the values, motor 2 is reverseable,
Motor #1 is
0-127 where 127 is full forward and 0 stops
Motor#2 is reversable and
128-255 where 128 is full forward and 255 stops

What you are probably telling us is what the motor controller you are using is expecting. The whole point of WebbotLib is you dont need to know that - ie your code just uses what WebbotLib is expecting ie -127 to +127. WebbotLib then changes this value and passes on what is required to the motor controller you are using to achieve the required result.

This means you can change from one motor controller to another without having to change your code - WebbotLib handles changing the -127 to +127 into whatever is necessary.
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline 325ciTopic starter

  • Jr. Member
  • **
  • Posts: 24
  • Helpful? 0
Re: Axon I Programming Motors go back and forward ( Newbie )
« Reply #26 on: October 14, 2010, 05:40:07 AM »
i will try them all tonight ald post the results. Thank you

Offline 325ciTopic starter

  • Jr. Member
  • **
  • Posts: 24
  • Helpful? 0
Re: Axon I Programming Motors go back and forward ( Newbie )
« Reply #27 on: October 17, 2010, 09:37:01 AM »
weLL i stopped using webbob designer because for some reason thats what it was ruining it. im just manually coding now and driving the motor with sabertooth(value);
and for now it works pretty good

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,132
  • Helpful? 109
Re: Axon I Programming Motors go back and forward ( Newbie )
« Reply #28 on: October 17, 2010, 11:45:55 AM »
weLL i stopped using webbob designer because for some reason thats what it was ruining it. im just manually coding now and driving the motor with sabertooth(value);
and for now it works pretty good

Send me the code you were using with Project Designer and I'll show you what you were doing wrong ;-)
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

 


Get Your Ad Here

data_list