Controlling step motors is a little more difficult than that of DC motors. Moreover, the Handy Board can handle at most 2 step motors while it can handle 4 DC motors. Nevertheless, using the step motors for our project was better solution than using DC motors, because step motors gave us finer control than DC motors. I can move the step motor 1 step at a time and each step of the motor is 7.5 degrees of rotation. So if I command it to move 48 steps, then it will rotate 360 degrees.
The following set of commands moves the motor one step forward (clockwise).
float x = 0.001;
fd(0);
fd(1);
sleep(x);
bk(0);
fd(1);
sleep(x);
bk(0);
bk(1);
sleep(x);
fd(0);
bk(1);
sleep(x);
If you want to move it backward (counter-clockwise), you just need to reverse the above sequence.
I get this information from this web site:
http://www.cctc.demon.co.uk/stepper.htm
Tuesday, August 7, 2007
How to control DC motors
The first thing I needed to do was to find a DC motor that was compatible with the Handy Board. The Handy Board is designed to work with 9V DC motors. The DC motors that I found were for 3V. The default commands to move DC motors are fd() and bk(); these commands move motors clockwise or counter-clockwise. However, applying 9V to a 3V DC motor was not a good thing, so I used the following set of commands to control the motor connected to the port 0.
motor(0, 40); // use 40% of power to move the motor clockwise
sleep(0.2); // keep it on for 0.2 seconds
off(0); // then shut it off
The above set of commands did work for our system, but we needed a stopper to stop the door from opening too much.
motor(0, 40); // use 40% of power to move the motor clockwise
sleep(0.2); // keep it on for 0.2 seconds
off(0); // then shut it off
The above set of commands did work for our system, but we needed a stopper to stop the door from opening too much.
Let's get started with the Handy Board
In order to use the Handy Board, we needed a special software called the Interactive C. We can get a free copy from http://www.botball.org/educational-resources/ic.php.
Your computer must have a serial port to connect to the Handy Board unless your Handy Board comes with a USB port. Unfortunately, most laptops don't have serial ports nowadays. To get around this problem, I purchased a USB to serial adapter. The one I used was made by CP TECHNOLOGIES and its model was CP-US-03. I got it from www.newegg.com and it cost me about $14 including the shipping cost. It worked fine with my Toshiba Portege R100 laptop with WindowsXP. The only thing that I needed to do was to change the port number to COMM1. When I installed the driver software, it automatically picked COMM5. The Interactive C uses either COMM1 or COMM3 to communicate with the Handy Board. So the serial adapter didn't work with the Interactive C by default.
Your computer must have a serial port to connect to the Handy Board unless your Handy Board comes with a USB port. Unfortunately, most laptops don't have serial ports nowadays. To get around this problem, I purchased a USB to serial adapter. The one I used was made by CP TECHNOLOGIES and its model was CP-US-03. I got it from www.newegg.com and it cost me about $14 including the shipping cost. It worked fine with my Toshiba Portege R100 laptop with WindowsXP. The only thing that I needed to do was to change the port number to COMM1. When I installed the driver software, it automatically picked COMM5. The Interactive C uses either COMM1 or COMM3 to communicate with the Handy Board. So the serial adapter didn't work with the Interactive C by default.
What technology should we use?
We came up with two potential technologies for this project. One them was the Handy Board, and the other one was Lego's Mindstorms.
We decided on the Handy Board because it was cheaper and easier to customize. The Mindstorms was relatively easy to use and somewhat customizable. However, our school didn't have software for the Mindstorms and it cost $70. We didn't want to spend $70 to see if the Mindstorms work for our project.
We decided on the Handy Board because it was cheaper and easier to customize. The Mindstorms was relatively easy to use and somewhat customizable. However, our school didn't have software for the Mindstorms and it cost $70. We didn't want to spend $70 to see if the Mindstorms work for our project.
Subscribe to:
Posts (Atom)