Propeller Activity Board HELP
huutinhsau
Posts: 2
Hi everyone, i'm new to the forum and also new to this programming activity board. I just recently got me an activity board and two hb-25 motor controller. I'm having trouble on how to get the motor to work on this board. This is the code that parallax provided as an example but i have no clue on it. Can someone please help me with it so i can understand. For the setup i have a motor connected to the hb 25 motorl terminal and a 6v battery connected to the battery terminal of the hb 25 motor control. Then i connect the hb 25 using a servo cable to the activity board to pin 15. Please let me know if i have the connect right .Thank you and this is the example code:
/*
Two DC Motors 60 Percent.c
Version 0.94 for use with SimpleIDE 9.40 and its Simple Libraries
Drive a pair of DC motors at 6/10 of full speed.
http://learn.parallax.com/propeller-c-tutorials
*/
#include "simpletools.h"
int main()
{
// Keep pins low if unused.
set_outputs(5, 2, 0b0000);
set_directions(5, 2, 0b1111);
// Start PWM process. Period 1 ms, Freq 1 kHz
pwm_start(1000);
// Turn motors counterclockwise for 3 s.
pwm_set(3, 0, 600);
pwm_set(4, 1, 600);
pause(3000);
// Stop for 1 second.
pwm_set(3, 0, 0);
pwm_set(4, 1, 0);
pause(1000);
// Turn motors counterclockwise for 3 s.
pwm_set(2, 0, 600);
pwm_set(5, 1, 600);
pause(3000);
// Stop again
pwm_set(2, 0, 0);
pwm_set(5, 1, 0);
// End the PWM process
pwm_stop();
}
/*
Two DC Motors 60 Percent.c
Version 0.94 for use with SimpleIDE 9.40 and its Simple Libraries
Drive a pair of DC motors at 6/10 of full speed.
http://learn.parallax.com/propeller-c-tutorials
*/
#include "simpletools.h"
int main()
{
// Keep pins low if unused.
set_outputs(5, 2, 0b0000);
set_directions(5, 2, 0b1111);
// Start PWM process. Period 1 ms, Freq 1 kHz
pwm_start(1000);
// Turn motors counterclockwise for 3 s.
pwm_set(3, 0, 600);
pwm_set(4, 1, 600);
pause(3000);
// Stop for 1 second.
pwm_set(3, 0, 0);
pwm_set(4, 1, 0);
pause(1000);
// Turn motors counterclockwise for 3 s.
pwm_set(2, 0, 600);
pwm_set(5, 1, 600);
pause(3000);
// Stop again
pwm_set(2, 0, 0);
pwm_set(5, 1, 0);
// End the PWM process
pwm_stop();
}
Comments
You could use normal ActivityBot code to drive the HB-25 since the ActivityBot uses CR servos to get around.
I haven't used C on the Propeller much but I could find what "set_outputs" does by looking at this page.
I don't think you'll need to use these same function to use the HB-25. You'll want to use the functions normally used to control servos.
/*
Standard Servo Position.c Moves servo to 0, 90 and 180 degrees. Holds each position for 2 s. Connect servo to P16 port on Propeller Activity Board.*/
#include "simpletools.h" // Include simpletools header
#include "servo.h" // Include servo header
int main() // main function
{
servo_angle(15, 0); // P15 servo to 0 degrees
pause(3000); // ...for 3 seconds
servo_angle(15, 900); // P15 servo to 90 degrees
pause(3000); // ...for 3 seconds
servo_angle(15, 1800); // P15 servo to 180 degrees
pause(3000); // ...for 3 seconds
servo_stop(); // Stop servo process
}
When you say it didn't work, what does that mean? Did the motor move at all?
What kind of motor (how much current can it draw) are you using and what sort of 6V battery (how much current can is provide)?
You've probably noticed the forum software destroys the indentation in code. Here's a link to a tutorial on posting code to the forum.