亿迅智能制造网
工业4.0先进制造技术信息网站!
首页 | 制造技术 | 制造设备 | 工业物联网 | 工业材料 | 设备保养维修 | 工业编程 |
home  MfgRobots >> 亿迅智能制造网 >  >> Manufacturing Technology >> 制造工艺

高级智能电池充电器:多路复用与数字显示

元件与物料

元件数量备注
Arduino UNO1
Arduino Proto Shield1
HC-SR04 超声波测距模块1用于手势控制显示屏亮灭
Adafruit MCP3008 8通道 10位 ADC1扩展模拟输入
5V 双路光耦继电器模块3共 6 路,每路控制一组电池充电回路
LM2596 DC-DC 降压模块 (3A 可调)1为充电电路供电
1kΩ 电阻12MCP3008 分压用
6位接线端子排1电池连接端子,可替换为其他接线方式

必备工具

项目背景

生活在东北,手头有多辆车(1975 MGB、1981 丰田皮卡)、船只、发电机,全是 12V 电池启动。冬天不开车时,每块电池若单独买智能维护充电器(Harbor Freight 约 $29 促销价),5 块电池就要 $150。灵机一动:为什么不买一个充电器,通过多路复用轮流给每块电池充几小时?

于是用 Arduino 实现了自动轮充,并顺手加了不少功能。本版本支持最多 6 块电池自动检测。

工作原理

默认每块电池充电 1 小时(可改)。2 块电池则每天各充 12 次,4 块则各充 6 次,以此类推。

完整代码

Battery Multiplexer Arduino Code(基于 Arduino Uno)

#include 
#include  // v1.2.1
#include 
#include 

auto timer = timer_create_default();
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // 地址可能需调整

int chargeTime = 10 * 1000;      // 每块电池充电时长(ms),演示用 10s,实用改 3600000(1h)
int charge_time_counter = 59;
int charge_time_max = 60;        // 计数器上限
int relay1 = 3, relay2 = 4, relay3 = 5, relay4 = 6; // 继电器引脚
int current_relay = 0;
int max_relays = 3;              // 实际使用的继电器数(0-based)
float volts1, volts2, volts3;    // 前三路电压(演示仅用3路)
int min_volts = 1;               // 低于此电压视为无电池
int volts_update_count = 5;
int volts_update_counter = 0;
int volts_update = 500;          // 电压刷新间隔(ms)
int read_distance_update = 500;  // 超声波刷新间隔(ms)
int time_on_counter = 0;
int time_on_count = 100;         // 亮屏持续计数
int heart_beat = 0;
UltraSonicDistanceSensor distanceSensor(11, 12); // Trig=11, Echo=12
int distance;
int relays[] = { relay1, relay2, relay3 };
int is_live[] = { 0, 0, 0 };
int debug = 5;

void all_change_to(int which) {
  digitalWrite(relay1, which);
  digitalWrite(relay2, which);
  digitalWrite(relay3, which);
}
void toggle_relays(int whichOne) {
  lcd.setCursor(0, 0);
  lcd.print("Relay on:"); lcd.print(current_relay + 1);
  all_change_to(HIGH); // 继电器低电平触发
  digitalWrite(relays[current_relay], LOW);
  lcd.print(" "); lcd.print(++acnt);
}
void checkRelays() {
  charge_time_counter++;
  if (charge_time_counter >= charge_time_max) {
    current_relay++;
    if (current_relay >= max_relays) current_relay = 0;
    toggle_relays(current_relay);
    charge_time_counter = 0;
  }
}
void read_distance() {
  distance = distanceSensor.measureDistanceCm();
  if (distance < 80) { lcd.backlight(); time_on_counter = 0; }
  else { if (++time_on_counter > time_on_count) { time_on_counter = 0; lcd.noBacklight(); } }
}
void read_show_volts() {
  volts1 = analogRead(0) * 0.016;
  lcd.setCursor(0, 1); lcd.print(" ");
  lcd.setCursor(11, 0); lcd.print(volts1);
  volts2 = analogRead(1) * 0.0164;
  lcd.setCursor(4, 1); lcd.print(volts2);
  volts3 = analogRead(2) * 0.0166;
  lcd.setCursor(11, 1); lcd.print(volts3);

  int temp_cnt = 0;
  relays[0] = relays[1] = relays[2] = 0;
  if (volts1 > min_volts) { relays[temp_cnt++] = relay1; }
  if (volts2 > min_volts) { relays[temp_cnt++] = relay2; }
  if (volts3 > min_volts) { relays[temp_cnt++] = relay3; }
  max_relays = temp_cnt;

  lcd.setCursor(0, 1);
  lcd.print(heart_beat ? "<>" : "><");
  heart_beat ^= 1;
  lcd.print(charge_time_counter);
  read_distance();
}
void setup() {
  Serial.begin(19200); Serial.println("Starting");
  lcd.begin(16, 2); lcd.backlight();
  pinMode(relay1, OUTPUT); pinMode(relay2, OUTPUT); pinMode(relay3, OUTPUT);
  all_change_to(HIGH);
  read_show_volts(); checkRelays();
  timer.every(chargeTime, checkRelays);
  timer.every(volts_update, read_show_volts);
}
void loop() { timer.tick(); }

原理图

高级智能电池充电器:多路复用与数字显示

制造工艺

  1. 智能窗帘:基于Arduino与太阳能的自动光控系统
  2. 智能存钱罐:Arduino Nano 控制硬币识别器实现余额显示
  3. Arduino Due 驱动 3.2″ TFT 实现温度监测与实时时钟
  4. Arduino + HC-05 蓝牙控制 LED:MIT App Inventor 手机 App 开发全攻略
  5. Arduino 项目优化供电方案:从按键开关到电池监测与数据记录
  6. 基于 Arduino Mega 与 Nextion 显示屏的交互式气象站
  7. Arduino DIY 电压表:Nokia 5110 屏幕显示,手把手教学
  8. Arduino Mega 2560 综合实训平台 - 传感器/电机/显示/PCB 一体化开发板
  9. 使用 Nextion 显示屏构建 Fridgeye 应用:分步指南
  10. Arduino UNO + 以太网盾板实现低成本太阳辐射测量仪(热电堆原理)
  11. 智能手语手套:柔性传感器 + 加速度计 + 蓝牙将手势转文字/语音
  12. Arduino GPS与TFT触摸屏扩展板:实时定位显示项目