搜索
bottom↓
回复: 3

请教 关于AVRLIB中的SERVO部分?

[复制链接]

出0入0汤圆

发表于 2009-4-14 12:04:44 | 显示全部楼层 |阅读模式
/*! \file servoconf.h \brief Interrupt-driven RC Servo configuration. */
//*****************************************************************************
//
// File Name        : 'servoconf.h'
// Title                : Interrupt-driven RC Servo function library
// Author                : Pascal Stang - Copyright (C) 2002
// Created                : 07/31/2002
// Revised                : 09/30/2002
// Version                : 1.0
// Target MCU        : Atmel AVR Series
// Editor Tabs        : 4
//
// NOTE: you need the latest version (3.2+) of the AVR-GCC compiler to use this
//        function library.  Download it from http://www.avrfreaks.net/AVRGCC
//
// Description : This code allows you to drive up to 8 RC servos from any
//                combination of ports and pins on the AVR processor. Using interrupts,
//                this code continuously sends control signals to the servo to maintain
//                position even while your code is doing other work.
//
//                The servoInit and servoOff effectively turn on and turn off servo
//                control.  When you run ServoInit, it automatically assigns each
//                "channel" of servo control to be output on the SERVO_DEFAULT_PORT.
//                One "channel" of servo control can control one servo and must be
//                assigned single I/O pin for output.
//
//                If you're using all eight channels (SERVO_NUM_CHANNELS = 8), then
//                then by default the code will use SERVO_DEFAULT_PORT pins 0-7.
//                If you're only using four channels, then pins 0-3 will be used by
//                default.
//
//                The command servoSetChannelIO(channel, port, pin) allows you to
//                reassign the output of any channel to any port and I/O pin you
//                choose.  For exampe, if you have an RC servo connected to PORTC, pin 6,
//                and you wish to use channel 2 to control it, use:
//
//                servoSerChannelIO( 2, _SFR_IO_ADDR(PORTC), 6)
//
//                (NOTE: you must include the "_SRF_IO_ADDR()" part around your port)
//
//                The servoSetPostion and servoGetPosition commands allow you to command
//                a given servo to your desired position.  The position you request must
//                lie between the SERVO_MIN and SERVO_MAX limit you defined.
//
// This code is distributed under the GNU Public License
//                which can be found at http://www.gnu.org/licenses/gpl.txt
//
//*****************************************************************************

#ifndef SERVOCONF_H
#define SERVOCONF_H

// set number of servo channels (1 to 8)
//                This is the number of servos you would like to drive
//                Each "Channel" can control one servo and by default will
//                map directly to the port pin of the same number on the
//                SERVO_DEFAULT_PORT.  You can change this default port/pin
//                assignment for a given channel to any port/pin you like.
//                See the "servoSetChannelIO" function.
#define SERVO_NUM_CHANNELS                8
// set default SERVO output port
//                This is the AVR port which you have connected to your servos
//                See top of file for how servo "channels" map to port pins
#define SERVO_DEFAULT_PORT                PORTD
// set servo characteristics (min and max raw position)
//                You must find these by testing using your brand/type of servos.
//                The min/max settings will change proportional to F_CPU, the CPU
//                clock frequency.
// The numbers below good for parallax servos at an F_CPU of ~8MHz.
#define SERVO_MAX                                71
#define SERVO_MIN                                17
// The numbers below good for parallax servos at an F_CPU of ~14.745MHz.
//#define SERVO_MAX                                138
//#define SERVO_MIN                                34

// set servo scaled range
//                This sets the scaled position range of the servo.  Allowed scaled
//                positions are 0 -> SERVO_POSITION_MAX, and correspond to raw
//                positions of SERVO_MIN -> SERVO_MAX.
#define SERVO_POSITION_MAX                255

#endif


上述代码中的SERVO_MAX  SERVO_MIN  表示什么??有没有高手使用过这个代码??

阿莫论坛20周年了!感谢大家的支持与爱护!!

曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……

出0入0汤圆

 楼主| 发表于 2009-4-14 12:05:24 | 显示全部楼层
使用16MHZ晶振是否也可以???

出0入0汤圆

发表于 2014-11-25 08:41:43 | 显示全部楼层
这个代码是干嘛的?没用过的咧

出0入0汤圆

发表于 2014-11-25 09:05:58 | 显示全部楼层
这是啥!
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片。注意:要连续压缩2次才能满足要求!!】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-8-26 06:19

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表