View unanswered posts | View active topics It is currently Sat Apr 19, 2014 1:24 pm






Reply to topic  [ 5 posts ] 
RobotC and Arduino with Motor Sheild 
Author Message
Rookie

Joined: Thu Feb 16, 2012 12:25 am
Posts: 3
Post RobotC and Arduino with Motor Sheild
I am new to the Arduino platform and I am trying to learn to a good level that I can teach middle school kids Robotics and engineering concepts. I have Arduino R2 and a L293D motor sheild from Seeed Studio ( details on http://www.seeedstudio.com/depot/motor- ... th=132_134). Using the native Arduino sketch I was able to get the motor spinning. Now I want to move over to RobotC and there lies the issue. The RobotC code doesnt turn on the motor. I see the LED on the UNO board blinking but nothing happens. Below are both teh programs. Can anyone tell me what I did wrong please or is it a bug in RobotC?

Arduino native API:

Code:
int pinI1=8;//define I1 interface
int pinI2=11;//define I2 interface
int speedpinA=9;//enable motor A
int pinI3=12;//define I3 interface
int pinI4=13;//define I4 interface
int speedpinB=10;//enable motor B
int spead =127;//define the spead of motor

void setup()
{
  pinMode(pinI1,OUTPUT);
  pinMode(pinI2,OUTPUT);
  pinMode(speedpinA,OUTPUT);
  pinMode(pinI3,OUTPUT);
  pinMode(pinI4,OUTPUT);
  pinMode(speedpinB,OUTPUT);
}

void forward()
{
  analogWrite(speedpinA,spead);//input a simulation value to set the speed
  analogWrite(speedpinB,spead);
  digitalWrite(pinI4,HIGH);//turn DC Motor B move clockwise
  digitalWrite(pinI3,LOW);
  digitalWrite(pinI2,LOW);//turn DC Motor A move anticlockwise
  digitalWrite(pinI1,HIGH);
}
void backward()//
{
  analogWrite(speedpinA,spead);//input a simulation value to set the speed
  analogWrite(speedpinB,spead);
  digitalWrite(pinI4,LOW);//turn DC Motor B move anticlockwise
  digitalWrite(pinI3,HIGH);
  digitalWrite(pinI2,HIGH);//turn DC Motor A move clockwise
  digitalWrite(pinI1,LOW);
}
void left()//
{
  analogWrite(speedpinA,spead);//input a simulation value to set the speed
  analogWrite(speedpinB,spead);
  digitalWrite(pinI4,HIGH);//turn DC Motor B move clockwise
  digitalWrite(pinI3,LOW);
  digitalWrite(pinI2,HIGH);//turn DC Motor A move clockwise
  digitalWrite(pinI1,LOW);
}
void right()//
{
  analogWrite(speedpinA,spead);//input a simulation value to set the speed
  analogWrite(speedpinB,spead);
  digitalWrite(pinI4,LOW);//turn DC Motor B move anticlockwise
  digitalWrite(pinI3,HIGH);
  digitalWrite(pinI2,LOW);//turn DC Motor A move clockwise
  digitalWrite(pinI1,HIGH);
}
void stop()//
{
  digitalWrite(speedpinA,LOW);// Unenble the pin, to stop the motor. this should be done to avid damaging the motor.
  digitalWrite(speedpinB,LOW);
  delay(1000);

}

void loop()
{
  left();
  delay(2000);
  stop();
  right();
  delay(2000);
  stop();
  // delay(2000);
  forward();
  delay(2000);
  stop();
  backward();
  delay(2000);
  stop();
  exit;
}



RobotC:
Code:
#pragma config(CircuitBoardType, typeCktBoardUNO)
#pragma config(Motor,  motor_5,         motor5,        tmotorExternalHBridgeSinglePWM, openLoop, IOPins, dgtl5, dgtl8)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
motor[motor5] = 100;
wait10Msec(2000);

}


Mon May 06, 2013 9:22 pm
Profile
Rookie

Joined: Thu Feb 16, 2012 12:25 am
Posts: 3
Post Re: RobotC and Arduino with Motor Sheild
Any pointer is very appreciated. Like I mentioned earlier, I am trying to learn this so that I can teach middle school kids in summer and I am totally stumped.


Thu Jun 06, 2013 8:13 am
Profile
Expert
User avatar

Joined: Fri Nov 02, 2012 12:07 am
Posts: 164
Location: California, USA
Post Re: RobotC and Arduino with Motor Sheild
You did know that you can edit your own posts instead of making a new one for each follow up comment you make?

_________________
string Robored = "Awesome"
~~Neil Balch~~


Tue Oct 22, 2013 12:10 am
Profile WWW
Rookie

Joined: Tue Jan 21, 2014 10:58 pm
Posts: 2
Post Re: RobotC and Arduino with Motor Sheild
Have you tried adding the shield in the "Motors and Sensors" tab? If you do that it should recognize the board but otherwise it wont know what to reference. Because you were able to get it working with IDE you probably configured it but just a tip.


Thu Jan 23, 2014 1:56 pm
Profile
Rookie

Joined: Wed Mar 26, 2014 10:03 am
Posts: 5
Post Re: RobotC and Arduino with Motor Sheild
Vatsan....I tried to do the same thing as you but gave up. For some reason the code for the motorshield was very difficult for me to get working. I finally took the 293D chip off and put it on a breadboard as in the following link. I followed this guys tutorial and within an hour I was up and running. He has a link to his code on his websie as well. Of course, you would have to obtain (if you do not have it already) the wire jumpers and breadboard shown in the video. Good luck.

https://www.youtube.com/watch?v=5nDaHJqruq0


Wed Mar 26, 2014 11:42 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.