Problem 7: How to add netctl service to the init process in Arch Linux
Before talking about the new progress on the AutoCar project, we need to solve a very specific problem. Though we can connect to the home wifi after login, it is quite inconvenient. Is there a way to connect to wifi in the init process?
Usually, we can put init script in /etc/init.d folder or /etc/rc.d. But Arch Linux does not have such folders.
According to ArchLinux Wiki, Arch Linux uses a modern alternative called systemd to handle the init scripts. For more details, please refer to the wiki link.
There are two steps to auto start the netctl service:
$
netctl enable your-network-profile
This steps will create a unit file of your profile. You can check the /etc/systemd/system folder.
The format looks like netctl@your-profile-name. There are some strange characters in the filename. The problem is that if there is "-" in the profile file name, the unit file will convert it to the hex value (\x2d). This issue is reported here and it is not a bug.
The format looks like netctl@your-profile-name. There are some strange characters in the filename. The problem is that if there is "-" in the profile file name, the unit file will convert it to the hex value (\x2d). This issue is reported here and it is not a bug.
Step 2: enable netctl service
$
systemctl enable netctl
This step creates a unit file for netctl.service in the /etc/systemd/system/multi-user.target.wants folder.
Raspberry Pi & Servo Motor
Now we can give a update of the AutoCar. We are now able to move the wheel (finally). However, this time, we use part of the Parallax 32500 ActivityBot Robot Kit.
- wheel and tire
- high speed servo motor
- robot chassis
- battery holder (currently not in use)
The high speed servo motor allows us control the speed and direction of the motor, which is essential to us because we want to adjust the speed and direction of the robot based on the distance to the obstables.
The documentaion of the high speed servo motor can be found here. Essentially, we can use the output pin of raspberry pi to send signal to the motor. The communcation protocol is that if we send 1.5ms pulse to the motor and have a 20ms pause between pulses, the motor will be still and this is called the "central position". If the pulse's duration is longer than 1.5 ms, the motor spins anti-clockwisely; if the pulse's duration is less than 1.5ms, the motor spins clockwisely.
The raspberry pi's 5V voltage lies in the range of the voltage required to drive the motor and the input(signal) voltages.
Note that for some reasons, the central position is not exactly 0.0015ms pulse. It turns out to be 0.00145 in my case.
The wiring part is quite straightforward and the official documentation is very clear and easy to understand.
Finally, the video!
x
No comments:
Post a Comment