Steins;Lab

某团的自留研究所

[库]一些常用的模块例程和资料库←7.22

[库]一些常用的模块例程和资料库

MAX7219数码管显示控制模块

MAX7219是一种集成化的串行输入/输出共阴极显示驱动器,它连接微处理器与8位数字的7段数字LED显示,也可以连接条线图显示器或者64个独立的LED。其上包括一个片上的B型BCD编码器、多路扫描回路,段字驱动器,而且还有一个8*8的静态RAM用来存储每一个数据。只有一个外部寄存器用来设置各个LED的段电流。

一个方便的四线串行接口可以联接所有通用的微处理器。每个数据可以寻址在更新时不需要改写所有的显示。MAX7219同样允许用户对每一个数据选择编码或者不编码。
整个设备包含一个150μA的低功耗关闭模式,模拟和数字亮度控制,一个扫描限制寄存器允许用户显示1-8位数据,还有一个让所有LED发光的检测模式。

只需要3个IO口即可驱动8位数码管。数码管显示时无闪烁。支持级联。

 

wp-image-994396577jpg

 

代码示例

单连

级联

 

 

 

 

 

 


ADAFRUIT 16-CHANNEL 12-BIT PWM/SERVO DRIVER – I2C INTERFACE

 

16路pwm舵机控制板

基于PCA9685

(tb买的,这迷之做工,目测开源的tb商拿来加工)20160722161433

20160722160918

官方文档

 文件下载:adafruit-16-channel-pwm-slash-servo-shield.pdf

以下摘录官方文档,版权信息

© Adafruit Industries https://learn.adafruit.com/adafruit-16-channel-pwm-slash-servo-shield


Connecting other I2C devices

Since I2C is a ‘shared bus’ you can still connect other I2C devices to the SDA/SCL pins as long as they do not have a conflicting address. The default address for the shield is address 0x40

Powering Servos / PWM

This shield has two power supplies. One is VCC – that is the 5V power from the Arduino, it is used to power the PWM chip and determines the I2C logic level and the PWM signal logic level. When this power supply is working you will see a red LED. The red LED must be lit for the Arduino & shield to work! Plug in the Arduino to USB or a wall adapter to provide it.

To power servos you will need to also connect the V+ power supply – this is the power supply for the servos. (If you are lighting up single LEDs you may not need this power supply.) This power supply should be 5 or 6VDC. You can connect this power through the blue terminal block. There is reverse-polarity protection in case you hook up power backwards.
Nearly all servos are designed to run on about 5 or 6v. Keep in mind that a lot of servos moving at the same time (particularly large powerful ones) will need a lot of current. Even micro servos will draw several hundred mA when moving. Some High-torque servos will draw more than 1A each under load.

Addressing the Shields

Each board in the chain must be assigned a unique address. This is done with the address jumpers on the upper right edge of the board. The I2C base address for each board is 0x40. The binary address that you program with the address jumpers is added to the base I2C address.
To program the address offset, use a drop of solder to bridge the corresponding address jumper for each binary ‘1’ in the address.

这里是对多驱动板级联的制定,制定每个板的物理地址,用短接法。

 

QQ截图20160722161745

 

Using the Adafruit Library

Download the library from Github Start by downloading the library from https://github.com/adafruit/Adafruit-PWM-ServoDriver-Library (http://adafru.it/aQl)-

you can just click the button below

Copy the zip file to the Libraries folder inside your Arduino Sketchbook folder and re-name it to Adafruit_PWMServoDriver. For more details on how to install Arduino libraries, check out our detailed tutorial! (http://adafru.it/aYM)

Download Adafruit PWM/Servo Library:
http://adafru.it/cDw

Test with the Example Code:

First make sure all copies of the Arduino are closed.
Next open a new copy of the IDE and select File->Examples>Adafruit_PWMServoDriver->Servo. This will open the example file in an IDE window.
Plug the shield into your Arduino, and a servo into the left-most ‘port’ as shown on the previous page and upload the example code. Don’t forget you will also have to provide 5V to the V+ terminal block. Both red and green LEDs must be lit.
You should see the servo sweep back and forth over approximately 180 degrees. Calibrating your Servos Servo pulse timing varies between different brands and models. Since it is an analog control circuit, there is often some variation between samples of the same brand and model. For precise position control, you will want to calibrate the minumum and maximum pulse-widths in your code to match known positions of the servo.
Find the MInimum: Using the example code, edit SERVOMIN until the low-point of the sweep reaches the minimum range of travel. It is best to approach this gradually and stop before the physical limit of travel is reached.
Find the Maximum: Again using the example code, edit SERVOMAX until the high-point of the sweep reaches the maximum range of travel. Again, is best to approach this gradually and stop before the physical limit of travel is reached.

 

Converting from Degrees to Pulse Length The Arduino “map()” function (http://adafru.it/aQm) is an easy way to convert between degrees of rotation and your calibrated SERVOMIN and SERVOMAX pulse lengths. Assuming a typical servo with 180 degrees of rotation; once you have calibrated SERVOMIN to the 0degree position and SERVOMAX to the 180 degree position, you can convert any angle between 0 and 180 degrees to the corresponding pulse length with the following line of code:

转换角度和脉冲之间的关系可以使用奇技淫巧:

pulselength = map(degrees, 0, 180, SERVOMIN, SERVOMAX);

 

官方示例代码

© Adafruit Industries https://learn.adafruit.com/adafruit-16-channel-pwm-slash-servo-shield

我连了以下。默认的60Hz我的sg90小舵机会抖个不停。50Hz的比较理想。

连接效果:

然而官网上的效果图比较酷炫

 

 

 

2
说点什么

avatar
1 Comment threads
1 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
2 Comment authors
SPtuanbrotherbiao Recent comment authors
  Subscribe  
最新 最旧 得票最多
提醒
brotherbiao
游客
brotherbiao

洋玩意儿看着真新鲜!!!