|
发表于 2018-11-28 12:08:42
浏览:7634
|
回复:1
打印
只看该作者
[复制链接]
楼主
android8.1需要控制进步电机,我用shell脚本控制的,控制GPIO高低电平。在之前先用单片机试过,每一步延时1ms,电机正常运行。然后用3399 的android8.1控制,shell内容如下:
- #!/system/bin/sh
- CHENG=124
- HUANG=126
- FEN=125
- LAN=123
- O=out
- HOME=/sys/class/gpio
- TAR=$HOME/export
- UNTAR=$HOME/unexport
- echo $CHENG > $TAR
- echo $HUANG > $TAR
- echo $FEN > $TAR
- echo $LAN > $TAR
- echo $O > $HOME/gpio$HUANG/direction
- echo $O > $HOME/gpio$CHENG/direction
- echo $O > $HOME/gpio$FEN/direction
- echo $O > $HOME/gpio$LAN/direction
- echo 0 > $HOME/gpio$CHENG/value
- echo 0 > $HOME/gpio$HUANG/value
- echo 0 > $HOME/gpio$FEN/value
- echo 0 > $HOME/gpio$LAN/value
- if [ $1 == 1 ]
- then
- while :
- do
- echo 0 > $HOME/gpio$LAN/value
- echo 1 > $HOME/gpio$CHENG/value
- usleep 1000
- echo 1 > $HOME/gpio$HUANG/value
- usleep 1000
- echo 0 > $HOME/gpio$CHENG/value
- usleep 1000
- echo 1 > $HOME/gpio$FEN/value
- usleep 1000
- echo 0 > $HOME/gpio$HUANG/value
- usleep 1000
- echo 1 > $HOME/gpio$LAN/value
- usleep 1000
- echo 0 > $HOME/gpio$FEN/value
- usleep 1000
- echo 1 > $HOME/gpio$CHENG/value
- usleep 1000
-
- done
复制代码
单片机和android都是延时1ms,但是android8.1进步电机的转速明显较慢,而且提不上速度。这个是和android的系统迪奥古有关还是shell控制GPIO有关。
|
|