Jump to content
ELFORUM - Forumul Electronistilor
Sign in to follow this  
Untold

Dancing minibot

Recommended Posts

Am gasit ceva superamuzant si interesant:

E si schema, mai putin .hex-ul....

Credeti ca s-ar putea crea un .hex pt asa ceva? Sau cu un alt micorcontroler?

 

L.E. Am gasit un asm:

 

// Pins connected to the motor driver. The PWM pins control the speed, and the

// other pins are used to select the current operation of the left/right

// channels of the driver- forward, reverse, stopped, or brake.

#define LEFT_PWM 3

#define LEFT_1 2

#define LEFT_2 4

#define RIGHT_PWM 6

#define RIGHT_1 7

#define RIGHT_2 5

 

void setup()

{

Serial.begin(57600); // This isn’t actually used anywhere; it’s here because

// once you start modifying the code and need to add

// print statements, you’ll forget to put this back in.

pinSetup(); // Configure the pins for the application. If we are in

// test mode, this will also configure the pins needed

// to support the addtional test functionality.

driveStop(); // Just to be good citizens, make sure the motors aren’t

// going to just randomly start turning.

}

 

void loop()

{

driveFwd(128);

delay(3000);

 

driveStop();

delay(500);

 

driveRev(128);

delay(2000);

 

leftFwd(128);

rightRev(128);

delay(1000);

 

leftRev(128);

rightFwd(128);

delay(1000);

 

}

 

void pinSetup()

{

pinMode(LEFT_PWM, OUTPUT);

pinMode(LEFT_1, OUTPUT);

pinMode(LEFT_2, OUTPUT);

pinMode(RIGHT_PWM, OUTPUT);

pinMode(RIGHT_1, OUTPUT);

pinMode(RIGHT_2, OUTPUT);

}

 

// Stop mode is simply a hi-z state. The motor will coast for some time if it

// is running at the time when this mode is activated.

void driveStop()

{

leftStop();

rightStop();

}

 

// Brake mode actually connects the two pins of the motor together, which will

// cause it to stop more quickly and to resist moving to some extent.

void driveBrake()

{

leftBrake();

rightBrake();

}

 

// Forward and reverse ground one pin and then toggle the other at the rate

// defined by the PWM inputs.

void driveFwd(byte spd)

{

leftFwd(spd);

rightFwd(spd);

}

 

void driveRev(byte spd)

{

leftRev(spd);

rightRev(spd);

}

 

// The left/right Rev/Fwd functions are set forth in the datasheet. Worth

// noting- this is relative to the preferred assembly of the Minibot kit. If

// you wire up your motors in another way, expect different results.

void leftRev(byte spd)

{

digitalWrite(LEFT_1, HIGH);

digitalWrite(LEFT_2, LOW);

analogWrite(LEFT_PWM, spd);

}

 

void leftFwd(byte spd)

{

digitalWrite(LEFT_1, LOW);

digitalWrite(LEFT_2, HIGH);

analogWrite(LEFT_PWM, spd);

}

 

void rightRev(byte spd)

{

digitalWrite(RIGHT_1, HIGH);

digitalWrite(RIGHT_2, LOW);

analogWrite(RIGHT_PWM, spd);

}

 

void rightFwd(byte spd)

{

digitalWrite(RIGHT_1, LOW);

digitalWrite(RIGHT_2, HIGH);

analogWrite(RIGHT_PWM, spd);

}

 

void leftBrake()

{

digitalWrite(LEFT_1, HIGH);

digitalWrite(LEFT_2, HIGH);

analogWrite(LEFT_PWM, 0);

}

 

void rightBrake()

{

digitalWrite(RIGHT_1, HIGH);

digitalWrite(RIGHT_2, HIGH);

analogWrite(RIGHT_PWM, 0);

}

 

void leftStop()

{

digitalWrite(LEFT_1, LOW);

digitalWrite(LEFT_2, LOW);

analogWrite(LEFT_PWM, 0);

}

 

void rightStop()

{

digitalWrite(RIGHT_1, LOW);

digitalWrite(RIGHT_2, LOW);

analogWrite(RIGHT_PWM, 0);

}

 

Il poate compila cineva in hex? Eu nu am assamblerul de la MPLAB instalat...

Si eventual, verificat, va rog? daca e pt pic-ul folosit?

Multumesc frumos.

post-71315-139829782799_thumb.jpg

Share this post


Link to post
Share on other sites

Am descarcat MPLAB-ul si am compilat asm-ul in hex.Daca are cineva timp si chef sa verifice daca e bine compilat...simulare habar n-am sa fac sau ceva de genul asta.Iar multumesc.

dancing minibot.hex.txt

Share this post


Link to post
Share on other sites

Codul pe care l-ai postat mai sus nu e asm ci c (mikroc??).Hexul pe care l-ai postat nu contine nimic (nu-s decat FF-uri).

Share this post


Link to post
Share on other sites

Codul pe care l-ai postat mai sus nu e asm ci c (mikroc??).Hexul pe care l-ai postat nu contine nimic (nu-s decat FF-uri).

Am inteles. De aia n-a compilat nimic, trebuia asm.Ma poate ajuta cineva cu compilarea? Multumesc anticipat.

Share this post


Link to post
Share on other sites

Ma poate ajuta cineva? Sau renunt la idee..Multumesc.

Share this post


Link to post
Share on other sites

Părerea mea umilă , de începător în C , este că acel cod nu e complet . Par a lipsi definițiile unor funcții care se aflau probabil în alt fișier. N-am vrut să mă bag , dar dacă n-a răspuns nimeni mai priceput ...Cu rezerva că s-ar putea să greșesc.

Share this post


Link to post
Share on other sites

Am mai sapat zilele astea si am descoperit ca e cod pentru Arduino. N-ai ce face cu el la picuri.

Share this post


Link to post
Share on other sites

Multumesc pentru autor.Ar fi fost frumos sa fac niste robotei din aia, acum pic-urile se gasesc la preturi modice..dar daca nu se poate, asta este.Stima tuturor.

Share this post


Link to post
Share on other sites

acum pic-urile se gasesc la preturi modice..

Nici avr-urile nu costa o avere...

Share this post


Link to post
Share on other sites

Sa inteleg ca un AVR poate face acest robotel sa danseze? In cazul asta, ma puteti ajuta cu un hex?Un USBasp mi-oi face eu, sau cumpar unul....

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.