加入星计划,您可以享受以下权益:

  • 创作内容快速变现
  • 行业影响力扩散
  • 作品版权保护
  • 300W+ 专业用户
  • 1.5W+ 优质创作者
  • 5000+ 长期合作伙伴
立即加入

基于单片机的电压电流表设计

09/14 09:02
4027
服务支持:
技术交流群

完成交易后在“购买成功”页面扫码入群,即可与技术大咖们分享疑惑和经验、收获成长和认同、领取优惠和红包等。

虚拟商品不可退

当前内容为数字版权作品,购买后不支持退换且无法转移使用。

加入交流群
扫码加入
获取工程师必备礼包
参与热点资讯讨论
放大
实物图
相关方案
  • 方案介绍
  • 相关文件
  • 相关推荐
  • 电子产业图谱
申请入驻 产业图谱

#include "stc15.h"
#include "delay.h"
#include "timer.h"
#include "TM7707.h"
#include "LCD1602.h"
#include "eeprom.h"
#include "stdio.h"
#include "stdlib.h"
#include "math.h"

#if (defined USE_TM7707)
#define TM_ADC_TO_VOLGATE    1.49056e-4 //
#define TM_ADC_TO_CURRENT    2.98023e-4
#elif (defined USE_TM7705)
#define TM_ADC_TO_VOLGATE    3.81469e-2
#define TM_ADC_TO_CURRENT    3.81469e-2
#endif
#define TM_VOLGATE_RATIO    25
#define TM_REAL_VOLGATE        (TM_ADC_TO_VOLGATE*TM_VOLGATE_RATIO)
#define TM_REAL_CURRENT        (TM_ADC_TO_CURRENT)

static void System_Config(void);
static void ChoiceMode(void);
static unsigned char KeyScan(void);

unsigned char code releaseKey[15] = "Release key    ";
unsigned char code input0A[15] = "Input 0.000A   ";
unsigned char code input5V[15] = "Input 5.000V   ";
unsigned char code input3A[15] = "Input 3.000A   ";
unsigned char code calibFinish[15] = "Finish         ";
unsigned char code V_UP[2] = "V+";
unsigned char code V_DOWN[2] = "V-";
unsigned char code I_UP[2] = "A+";
unsigned char code I_DOWN[2] = "A-";

xdata float v_ratio=1.0f;
xdata float i_ratio=1.0f;
xdata long volgate=0;
xdata long current=0, i_offset=0;
xdata long power=0;
xdata long ohm=0;
xdata long AH=0;
xdata unsigned int timer_cnt=0;
xdata unsigned char dis_cnt=0;
xdata unsigned char sec=0;
xdata unsigned char min=0;
xdata unsigned char hour=0;
unsigned long sec_sum=0;
float ah_sec=0;
float ah_sum=0;
xdata unsigned char mode_flag=1;

xdata long mTemp=0;

bit isDisFlag=1;
bit isDisAhStop=1;
bit isUpdataAH = 0;

/***************************************************
*
*
*
*/
void main(void)
{
unsigned char keyCode=0;

System_Config();
LCD1602_Config();
Timer_Config();
TM770x_Config();
EA = 1;
ChoiceMode();
EA = 0;
mode_flag = IapReadByte(EEPROM_MODE_ADDR);
IapReadData(EEPROM_V_RATIO_ADDR, (long*)&volgate);
IapReadData(EEPROM_I_RATIO_ADDR, (long*)&current);
IapReadData(EEPROM_I_ZERO_ADDR, (long*)&i_offset);
EA = 1;
v_ratio = volgate*1e-5;
i_ratio = current*1e-5;
if(mode_flag!=2 && mode_flag!=1)
{
mode_flag = 1;
IapSaveData(EEPROM_MODE_ADDR, (unsigned char*)&mode_flag, 1);
}

volgate = 0;
current = 0;
AH = 0;

LCD1602_Write(LCD_WR_CMD, 0x01);
delay_ms(10);

//    volgate = 123456;
//    DisplayNumber(0,0, volgate, 0xFF);
//    DisplayTimer(hour,min,sec);
//    while(1);
//    mode_flag = 1;

for(;;)
{
keyCode = KeyScan();
if(keyCode==0)
{
if(mode_flag==2)
{
hour = 0;

  • 有需要资料的可了解一下.docx

相关推荐

电子产业图谱