Digital 2 channel 10 Amp Meter
History
This project is a 2 channels amp meter. Those channels are completely isolated up to 2000 volts. I'm sure you don't need isolation like this but it could be very interesting to measure the charge current for 110V AC input or on the output of something like 12V DC. That is, it provides auto detection for AC or DC current. The main part of this project is the current sensor ZMC10 a cool DIP 14, which supports up to 10 A. The current is measured inside by hall effect sensor. I had used a graphic LCD to show very big numbers of the read current and max peek value, DC or AC
Ok now, this was supposed to be simple, but I had to overcome a
lot of problems doing this project. First the datasheet of the ZMC10
have a big 2 pages!
How an IC like that can have 2 pages documentation when LED
datasheet have more than 15 pages? Not having proper documentation
was my biggest challenge. First the slope is non linear I had to
make calibration at first to use it from 0 to 10 amps. The software
calculates the slope from 0 to 1, 1 to 2, 2 to 3, with the formula
Y2 - Y1 / X2 - X1 | B = Y - M * X | X = Y - B / M | Y = M
* X + B. After I faced another problem, any metal pieces from 2
inches will completely false the reading. For example, if your
charge is 5 A. Moving a screw driver at 2 inches of the ZMC10 you
will give something like 1A or less. The other problem that I had
faced is if the 2 sensors are closed to each other the current will
interfere and will give you false reading. I had to rebuild another
PCB for that to separate each channel. Also at 0 A the sensor will
not give you zero, you must calculate the offset from one part to
the other since the values are not the same. In last all the
values, slopes and offset are not the same if the current pass from
A to B or B to A. I think this caused enough problems for a simple
amp meter.
The MCU has two jobs: measure (calculate) the value from the analog board and display that value. I drove the LCD in graphical mode. I had written the character generator for fonts 1x, 2x and 4x other function like draw line, square, clear screen and more. Also the MCU board has the power supply for itself and for the analog part.
Features
|
|
2 Channel |
|
|
From 0 to 10amp |
|
|
Resolution of 0.1amp |
|
|
Isolation between each channel of 2000 volt |
|
|
Automatic AD/DC detection |
|
|
Very big LCD and character |
Pictures
Click to enlarge
|
Analog part 1 of 2 |
Graphic LCD with a SED1330 |
MCU board mounted on back of the LCD |
Click to enlarge
|
Analog part 1 of 2 |
Final work in right position |
Final work in slope position |
Sources codes & Schematics
-Schematic of the Digital part
//*****************************************************************************
// AmpVoltMeter
// Version 10.0 Janv 2007
//
// 1.0 -> New code
//
// Sylvain Bissonnette
//*****************************************************************************
// Editor : UltraEdit32
//*****************************************************************************
//
//
R E T U R N S T A C K 6 4
//
X T A L 16 MHZ
//
BootLoader of 1024 word
//
//*****************************************************************************
//
//
F U S E B I T
//
//( )7 ( )6
(X)BL12 (X)BL11 ( )BL02 ( )BL01
( )Lock2 ( )Lock1
//( )7 ( )6
( ) ( ) ( )
( )M103C ( )WDTON ( )
//( )RSTDIS ( )WDON (X)SPIEN(X)CKOPT
(X)EESAVE ( )BOOTSZ1 (X)BOOTSZ0 (X)BOOTRST
//(X)BODLEV (X)BODEN ( )SUT1 ( )SUT0
( )CKSEL3 ( )CKSEL2 ( )CKSEL1 ( )CKSEL0
//
//*****************************************************************************
//
P I N U S A G E
//
// PA0 -> Key Switch SW7
// PA1 -> Key Switch SW8
// PA2 -> Key Switch SW9
// PA3 -> Key Switch SW1
// PA4 -> Key Switch SW2
// PA5 -> Key Switch SW3
// PA6 -> Key Switch SW4
// PA7 -> Key Switch SW5
//
// PB0 -> n/c
// PB1 -> n/c
// PB2 -> n/c
// PB3 -> n/c
// PB4 -> n/c
// PB5 -> n/c
// PB6 -> LCD BackLight
// PB7 -> Piezo
//
// PC0 -> LCD Data bit 0
// PC1 -> LCD Data bit 1
// PC2 -> LCD Data bit 2
// PC3 -> LCD Data bit 3
// PC4 -> LCD Data bit 4
// PC5 -> LCD Data bit 5
// PC6 -> LCD Data bit 6
// PC7 -> LCD Data bit 7
//
// PD0 -> n/c
// PD1 -> n/c
// PD2 -> RS485 RX
// PD3 -> RS485 TX
// PD4 -> RS485 TXE
// PD5 -> LCD RESET
// PD6 -> LCD RD
// PD7 -> LCD WR
//
// PE0 -> n/c
// PE1 -> n/c
// PE2 -> n/c
// PE3 -> n/c
// PE4 -> n/c
// PE5 -> n/c
// PE6 -> n/c
// PE7 -> n/c
//
// PF0 -> n/c
// PF1 -> n/c
// PF2 -> n/c
// PF3 -> n/c
// PF4 -> n/c
// PF5 -> n/c
// PF6 -> Key Switch SW10
// PF7 -> Key Switch SW6
//
// PG0 -> LCD A0
// PG1 -> n/c
// PG2 -> n/c
// PG3 -> n/c
// PG4 -> n/c
//*****************************************************************************
//
T I M E R U S A G E
//
// Timer 0 is use by TaskManager
// Timer 1 is use for Sound generetor
1.265KHz
// Timer 2 not use
// Timer 3 not use
//
//*****************************************************************************
//*****************************************************************************
//
I N C L U D E
//*****************************************************************************
#include <iom32v.h>
#include <shortnametype.h>
#include <macros.h>
#include <stdlib.h>
#include <STRING.H>
#include <stdio.h>
#include <eeprom.h>
#include "TaskManager.h"
//*****************************************************************************
//
D E F I N E
//*****************************************************************************
#define VERSION
100
#define DEVICE
1280
#define XTAL
8000000
// ADC
#define ADC0
(1<<REFS0) + 0
#define ADC1
(1<<REFS0) + 1
#define ADC2
(1<<REFS0) + 2
#define ADC3
(1<<REFS0) + 3
#define ADC4
(1<<REFS0) + 4
#define ADC5
(1<<REFS0) + 5
#define ADC6
(1<<REFS0) + 6
#define ADC7
(1<<REFS0) + 7
// LCD
#define LCDDATA_DDR
DDRC
#define LCDDATA_PIN
PINC
#define LCDDATA_PORT
PORTC
#define LCDCTRL_DDR
DDRD
#define LCDCTRL_PIN
PIND
#define LCDCTRL_PORT
PORTD
#define LCD_A0
(1<<PD4)
#define LCD_WR
(1<<PD5)
#define LCD_RD
(1<<PD6)
#define LCD_RES
(1<<PD7)
#define LCD_X
256
#define LCD_Y
128
#define LCD_XTAL
6000000
#define FONT_1X
1
#define FONT_2X
2
#define FONT_4X
4
// Switch
#define SWITCH_DDR
DDRB
#define SWITCH_PIN
PINB
#define SWITCH_PORT
PORTB
#define LEFT
0x01
#define RIGHT
0x02
#define BOTH
0x03
// Eprom
#define SLOPE1
0
#define SLOPE2
50
#define SLOPE3
100
#define SLOPE4
150
#define FOWARD
0
#define REVERSE
1
// Interrupt
#define INT_DDR
DDRD
#define INT_PIN
PIND
#define INT_PORT
PORTD
#define INT_INPUT_0
0x04
#define INT_INPUT_1
0x08
// AC/DC
#define AC
TRUE
#define DC
FALSE
//**************************************
//
P R O T O T LCD_Y P E
//**************************************
void InitCode(void);
void RedrawTick(void);
void Delay(ushort
Del);
void IntInit(void);
void SplashScreen(void);
void DrawScreen(void);
void DrawDC1(void);
void DrawDC2(void);
void DrawAC1(void);
void DrawAC2(void);
void LoadSlope(ushort
Polarity);
void CalculateMB(void);
void Calibration(void);
void PrintAmp1(int
X, int Y,
uint Value, int Size,
ushort ACDC);
void PrintAmp2(int
X, int Y,
uint Value, int Size,
ushort ACDC);
// Slope
float SlopeGetM
(float X1,
float Y1, float X2,
float Y2);
float SlopeGetB
(float X,
float Y, float M);
float SlopeGetX
(float Y,
float B, float M);
float SlopeGetY
(float X,
float B, float M);
// LCD
void LCDInit(void);
void LCDWriteData(ushort
byte);
void LCDWriteCmd(ushort
byte);
ushort LCDReadData(void);
void LCDClrSCR(void);
void LCDGotoXY(ushort,
ushort);
void LCDWriteString(char
*ptr);
void LCDWriteConstString(const
char *ptr);
void LCDCursor(ushort
LCDCursor);
void LCDTextBox(int
x, int y,
int length,int
stat);
void LCDDelay2ms(void);
void LCDDelay1us(void);
void LCDGraphClrSCR(void);
void LCDGraphGotoXY(ushort
x, ushort y);
void LcdGraphString
(ushort X,
ushort Y, ushort Size,
char *Ptr );
void LcdGraphConstString
(ushort X,
ushort Y, ushort Size,
const char *Ptr );
void LcdGraphChr(ushort
X, ushort Y,
ushort Size, char Ch);
void LCDGraphSetRamPointer(int
Address);
void LCDGraphPix(int
x, int y,
ushort stat);
void LCDGraphBox(int
x1, int y1,
int x2, int y2,int
stat);
void LCDGraphLine(int
x1, int y1,
int x2, int y2);
// ADC
void ADInit(void);
void AD_interrupt(void);
// Switch
void SwitchInit(void);
void SwitchScan(void);
// AD/DC
void Int_0_AC(void);
void Int_1_AC(void);
void CheckAC(void);
//*****************************************************************************
//
C O N S T A N T
//*****************************************************************************
static const ushort FontLookup
[][7]
=
{
{
0x00, 0x00,
0x00,
0x00,
0x00,
0x00,
0x00 },
// Space
{ 0x04,
0x04,
0x04,
0x04,
0x04,
0x00,
0x04 },
// !
{ 0x0A,
0x0A,
0x0A,
0x00,
0x00,
0x00,
0x00 },
// "
{ 0x0A,
0x0A,
0x1F,
0x0A,
0x1F,
0x0A,
0x0A },
// #
{
0x04,
0x0F,
0x14,
0x0E,
0x05,
0x1E,
0x04 },
// $
{
0x18,
0x19,
0x02,
0x04,
0x08,
0x13,
0x03 },
// %
{
0x0C,
0x12,
0x14,
0x08,
0x15,
0x12,
0x0D },
// &
{
0x0C,
0x04,
0x08,
0x00,
0x00,
0x00,
0x00 },
// '
{
0x02,
0x04,
0x08,
0x08,
0x08,
0x04,
0x02 },
// (
{
0x08, 0x04,
0x02,
0x02,
0x02,
0x04,
0x08 },
// )
{ 0x00,
0x04,
0x15,
0x0E,
0x15,
0x04,
0x00 },
// *
{ 0x00,
0x04,
0x04,
0x1F,
0x04,
0x04,
0x00 },
// +
{ 0x00,
0x00,
0x00,
0x00,
0x00,
0x0C,
0x04 },
// ,
{
0x00,
0x00,
0x00,
0x1F,
0x00,
0x00,
0x00 },
// -
{
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x0C },
// .
{
0x00,
0x01,
0x02,
0x04,
0x08,
0x10,
0x00 },
// /
{
0x0E,
0x11,
0x13,
0x15,
0x19,
0x11,
0x0E },
// 0
{
0x04,
0x0C,
0x04,
0x04,
0x04,
0x04,
0x0E },
// 1
{ 0x0E,
0x11,
0x02,
0x04,
0x08,
0x10,
0x1F },
// 2
{ 0x1F,
0x02,
0x04,
0x02,
0x01,
0x11,
0x0E },
// 3
{ 0x02,
0x06,
0x0A,
0x12,
0x1F,
0x02,
0x02 },
// 4
{
0x1F,
0x10,
0x1E,
0x01,
0x01,
0x11,
0x0E },
// 5
{
0x06,
0x08,
0x10,
0x1E,
0x11,
0x11,
0x0E },
// 6
{
0x1F,
0x01,
0x02,
0x04,
0x08,
0x08,
0x08 },
// 7
{
0x0E,
0x11,
0x11,
0x0E,
0x11,
0x11,
0x0E },
// 8
{
0x0E,
0x11,
0x11,
0x0F,
0x01,
0x02,
0x0C },
// 9
{ 0x00,
0x0C,
0x0C,
0x00,
0x0C,
0x0C,
0x00 },
// :
{ 0x00,
0x0C,
0x0C,
0x00,
0x0C,
0x04,
0x08 },
// ;
{ 0x01,
0x02,
0x04,
0x08,
0x04,
0x02,
0x01 },
// <
{
0x00,
0x00,
0x1F,
0x00,
0x1F,
0x00,
0x00 },
// =
{
0x10,
0x08,
0x04,
0x02,
0x04,
0x08,
0x10 },
// >
{
0x0E,
0x11,
0x01,
0x02,
0x04,
0x00,
0x04 },
// ?
{
0x0E,
0x11,
0x17,
0x15,
0x17,
0x10,
0x0E },
// @
{
0x0E,
0x11,
0x11,
0x11,
0x1F,
0x11,
0x11 },
// A
{ 0x1E,
0x11,
0x11,
0x1E,
0x11,
0x11,
0x1E },
// B
{ 0x0E,
0x11,
0x10,
0x10,
0x10,
0x11,
0x0E },
// C
{ 0x1C,
0x12,
0x11,
0x11,
0x11,
0x12,
0x1C },
// D
{
0x1F,
0x10,
0x10,
0x1E,
0x10,
0x10,
0x1F },
// E
{
0x1F,
0x10,
0x10,
0x1E,
0x10,
0x10,
0x10 },
// F
{
0x0E,
0x11,
0x10,
0x17,
0x11,
0x11,
0x0F },
// G
{
0x11,
0x11,
0x11,
0x1F,
0x11,
0x11,
0x11 },
// H
{
0x0E,
0x04,
0x04,
0x04,
0x04,
0x04,
0x0E },
// I
{ 0x07,
0x02,
0x02,
0x02,
0x02,
0x12,
0x0C },
// J
{ 0x11,
0x12,
0x14,
0x18,
0x14,
0x12,
0x11 },
// K
{ 0x10,
0x10,
0x10,
0x10,
0x10,
0x10,
0x1F },
// L
{
0x11,
0x1B,
0x15,
0x15,
0x11,
0x11,
0x11 },
// M
{
0x11,
0x11,
0x19,
0x15,
0x13,
0x11,
0x11 },
// N
{
0x0E,
0x11,
0x11,
0x11,
0x11,
0x11,
0x0E },
// O
{
0x1E,
0x11,
0x11,
0x1E,
0x10,
0x10,
0x10 },
// P
{
0x0E,
0x11,
0x11,
0x11,
0x15,
0x12,
0x0D },
// Q
{ 0x1E,
0x11,
0x11,
0x1E,
0x14,
0x12,
0x11 },
// R
{ 0x0E,
0x11,
0x10,
0x0E,
0x01,
0x11,
0x0E },
// S
{ 0x1F,
0x04,
0x04,
0x04,
0x04,
0x04,
0x04 },
// T
{
0x11,
0x11,
0x11,
0x11,
0x11,
0x11,
0x0E },
// U
{
0x11,
0x11,
0x11,
0x11,
0x11,
0x0A,
0x04 },
// V
{
0x11,
0x11,
0x11,
0x11,
0x15,
0x15,
0x0A },
// W
{
0x11,
0x11,
0x0A,
0x04,
0x0A,
0x11,
0x11 },
// X
{
0x11,
0x11,
0x11,
0x0A,
0x04,
0x04,
0x04 },
// Y
{ 0x1F,
0x01,
0x02,
0x04,
0x08,
0x10,
0x1F },
// Z
{ 0x0E,
0x08,
0x08,
0x08,
0x08,
0x08,
0x0E },
// [
{ 0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00 },
// Space
{
0x0E,
0x02,
0x02,
0x02,
0x02,
0x02,
0x0E },
// ]
{
0x04,
0x0A,
0x11,
0x00,
0x00,
0x00,
0x00 },
// ^
{
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x1F },
// _
{
0x06,
0x04,
0x02,
0x00,
0x00,
0x00,
0x00 },
// `
{
0x00,
0x00,
0x0E,
0x01,
0x0F,
0x11,
0x0F },
// a
{ 0x10,
0x10,
0x1E,
0x11,
0x11,
0x11,
0x1E },
// b
{ 0x00,
0x00,
0x0F,
0x10,
0x10,
0x10,
0x0F },
// c
{ 0x01,
0x01,
0x0F,
0x11,
0x11,
0x11,
0x0F },
// d
{
0x00,
0x00,
0x0E,
0x11,
0x1E,
0x10,
0x0E },
// f
{
0x03,
0x04,
0x1F,
0x04,
0x04,
0x04,
0x04 },
// e
{
0x00,
0x00,
0x0F,
0x11,
0x0F,
0x01,
0x0E },
// g
{
0x10,
0x10,
0x16,
0x19,
0x11,
0x11,
0x11 },
// h
{
0x04,
0x00,
0x0C,
0x04,
0x04,
0x04,
0x0E },
// i
{ 0x02,
0x00,
0x06,
0x02,
0x02,
0x12,
0x0C },
// j
{ 0x10,
0x10,
0x12,
0x14,
0x18,
0x14,
0x12 },
// k
{ 0x0C,
0x04,
0x04,
0x04,
0x04,
0x04,
0x0E },
// l
{
0x00,
0x00,
0x1E,
0x15,
0x15,
0x15,
0x15 },
// m
{
0x00,
0x00,
0x16,
0x19,
0x11,
0x11,
0x11 },
// n
{
0x00,
0x00,
0x0E,
0x11,
0x11,
0x11,
0x0E },
// o
{
0x00,
0x00,
0x1E,
0x11,
0x1E,
0x10,
0x10 },
// p
{
0x00,
0x00,
0x0F,
0x11,
0x0F,
0x01,
0x01 },
// q
{ 0x00,
0x00,
0x16,
0x18,
0x10,
0x10,
0x10 },
// r
{ 0x00,
0x00,
0x0F,
0x10,
0x0E,
0x01,
0x1E },
// s
{ 0x04,
0x04,
0x1F,
0x04,
0x04,
0x04,
0x03 },
// t
{
0x00,
0x00,
0x11,
0x11,
0x11,
0x13,
0x0D },
// u
{
0x00,
0x00,
0x11,
0x11,
0x11,
0x0A,
0x04 },
// v
{
0x00,
0x00,
0x11,
0x11,
0x15,
0x15,
0x0A },
// w
{
0x00,
0x00,
0x11,
0x0A,
0x04,
0x0A,
0x11 },
// x
{
0x00,
0x00,
0x11,
0x11,
0x0F,
0x01,
0x0E },
// y
{ 0x00,
0x00,
0x1F,
0x02,
0x04,
0x08,
0x1F },
// z
{ 0x06,
0x08,
0x08,
0x10,
0x08,
0x08,
0x06 },
// {
{ 0x04,
0x04,
0x04,
0x00,
0x04,
0x04,
0x04 },
// :
{
0x0C,
0x02,
0x02,
0x01,
0x02,
0x02,
0x0C },
// }
{
0x00,
0x04,
0x02,
0x1F,
0x02,
0x04,
0x00 },
// Right arrow
{
0x00,
0x04,
0x08,
0x1F,
0x08,
0x04,
0x00 },
// Left arroe
{
0x1f,
0x1f,
0x1f,
0x1f,
0x1f,
0x1f,
0x1f }
// Fill
};
//*****************************************************************************
//
G L O B A L V A R I A B L E
//*****************************************************************************
// KeySwitch
ushort Switch;
// LCD
char Text[20];
// ADC
uint Amp1DC, Amp2DC;
uint Amp1AC,Amp2AC;
ushort Amp1ACDC, Amp2ACDC;
ushort Amp1DCSlope, Amp2DCSlope;
uint Amp1Max, Amp2Max;
// Correction Factor
float Sensor1Slope[11];
float Sensor1B[11];
float Sensor1Value[11];
float Sensor2Slope[11];
float Sensor2B[11];
float Sensor2Value[11];
// AD/DC
uint Sensor1ACCounter;
uint Sensor2ACCounter;
//*****************************************************************************
//
M A I N
//*****************************************************************************
void main()
{
TaskInit();
LCDInit();
ADInit();
SwitchInit();
IntInit();
WDR();
WDTCR = 0x0f;
// Watch Dog enable
SEI();
//re-enable interrupts
LCDClrSCR();
LCDGraphClrSCR();
SplashScreen();
Delay(50);
DrawScreen();
TaskRegister(RedrawTick,T500MS,TRUE);
TaskRegister(SwitchScan,T100MS,TRUE);
while(1)
{
_StackCheck();
if (Switch
== (LEFT+RIGHT))
{
Switch = NULL;
Calibration();
}
if (Switch
== LEFT)
{
Switch =
NULL;
Amp1Max =
0;
}
if (Switch
== RIGHT)
{
Switch =
NULL;
Amp2Max =
0;
}
WDR();
}
}
/******************************************************************************
Name:
void _StackOverflowed(char c)
Description: This function is
automaticaly called if
the stack crash.
Input:
none
Output:
none
Misc:
******************************************************************************/
void _StackOverflowed(char
c)
{
int i;
LCDClrSCR();
LCDGraphClrSCR();
LCDGotoXY(5,12);
LCDWriteConstString("S
T A C K O V E R F L O W !!!!!\0");
LCDGotoXY(5,13);
LCDWriteConstString("--------------------------------\0");
for (i=0;i<1000;i++)
LCDDelay2ms();
CLI();
while(1);
}
/******************************************************************************
Name:
void Delay(ushort Del)
Description: This function make a
delay
Input:
none
Output:
none
Misc:
******************************************************************************/
void Delay(ushort
Del)
{
int i,j;
for (i=0;i<Del;i++)
for (j=0;j<32000;j++)
WDR();
}
/******************************************************************************
Name:
void LoadSlope(ushort Polarity)
Description: This function
Input:
none
Output:
none
Misc:
******************************************************************************/
void LoadSlope(ushort
Polarity)
{
ushort i;
for (i=0;i<11;i++)
{
EEPROMReadBytes(SLOPE1+(i*4)+(Polarity*100),&Sensor1Value[i],4);
EEPROMReadBytes(SLOPE2+(i*4)+(Polarity*100),&Sensor2Value[i],4);
}
CalculateMB();
}
/******************************************************************************
Name:
void CalculateMB(void)
Description: This function calculate
M & B for all the 11 points
Input:
none
Output:
none
Misc:
******************************************************************************/
void CalculateMB(void)
{
ushort i;
for (i=0;i<10;i++)
{
Sensor1Slope[i]
= SlopeGetM(i,Sensor1Value[i],
i+1,Sensor1Value[i+1]);
Sensor1B[i]
= SlopeGetB(i,
Sensor1Value[i],
Sensor1Slope[i]);
Sensor2Slope[i]
= SlopeGetM(i,Sensor2Value[i],
i+1,Sensor2Value[i+1]);
Sensor2B[i]
= SlopeGetB(i,
Sensor2Value[i],
Sensor2Slope[i]);
}
}
/******************************************************************************
Name:
void Calibration(void)
Description: This function is to
equalibrate the non linear curve of the sensor
Input:
none
Output:
none
Misc:
******************************************************************************/
void Calibration(void)
{
int i,j;
TaskUnRegister(RedrawTick);
Switch = NULL;
LCDGraphClrSCR();
LCDGraphBox(15,
14,
242,
113,
1);
LCDGraphBox(1,
1,
256,
128,
1);
LCDGraphBox(1,
1,
256,
128,
1);
LcdGraphConstString (10,
4, FONT_1X,
"Amp Meter V:1.0\0"
);
LcdGraphConstString (6,
20,
FONT_2X,
"Calibration\0" );
LcdGraphConstString (4,
50,
FONT_1X, "Set the
current to :\0" );
LcdGraphConstString (5,
60,
FONT_1X, "IN THIS
WAY ---------->>\0" );
LcdGraphConstString (9,
70,
FONT_1X, "and
press any key\0" );
LcdGraphConstString (6,
90,
FONT_1X, "both
amp meter must be\0" );
LcdGraphConstString (8,
100,
FONT_1X,
"connected in series\0" );
csprintf(&Text[0],"%d\0",i);
LcdGraphConstString (24,
43,
FONT_2X, "1");
LcdGraphConstString (28,
50,
FONT_1X, "Amp\0"
);
while(!Switch)
WDR();
Switch = NULL;
for (i=0;i<