加入星計劃,您可以享受以下權(quán)益:

  • 創(chuàng)作內(nèi)容快速變現(xiàn)
  • 行業(yè)影響力擴散
  • 作品版權(quán)保護
  • 300W+ 專業(yè)用戶
  • 1.5W+ 優(yōu)質(zhì)創(chuàng)作者
  • 5000+ 長期合作伙伴
立即加入

基于單片機的電壓電流表設計

09/14 09:02
4748
服務支持:
技術(shù)交流群

完成交易后在“購買成功”頁面掃碼入群,即可與技術(shù)大咖們分享疑惑和經(jīng)驗、收獲成長和認同、領取優(yōu)惠和紅包等。

虛擬商品不可退

當前內(nèi)容為數(shù)字版權(quán)作品,購買后不支持退換且無法轉(zhuǎn)移使用。

加入交流群
掃碼加入
獲取工程師必備禮包
參與熱點資訊討論
放大
實物圖
相關方案
  • 方案介紹
  • 相關文件
  • 相關推薦
  • 電子產(chǎn)業(yè)圖譜
申請入駐 產(chǎn)業(yè)圖譜

#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

相關推薦

電子產(chǎn)業(yè)圖譜