und der Micro-C Code für einen PIC16F628A Teil1
***********************************************************************
Program for counter.
Program Written by MKDas
Email:
mithun060@gmail.com;
abgeändert in einen Schrittmotorimpulsgeber.
***********************************************************************/
// LCD module connections
sbit LCD_RS at RA0_bit;
sbit LCD_EN at RA1_bit;
sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D7 at RB7_bit;
sbit LCD_RS_Direction at TRISA0_bit;
sbit LCD_EN_Direction at TRISA1_bit;
sbit LCD_D4_Direction at TRISB4_bit;
sbit LCD_D5_Direction at TRISB5_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D7_Direction at TRISB7_bit;
// End LCD module connections
// Tact switches and Relay ports
sbit Relay at RA3_bit; //Pulsausgang
sbit SS_Select at RB0_bit; // Start Taste
sbit Hun_Button at RB1_bit; // Set Einer
sbit Ten_Button at RB2_bit; // Set Zehner
sbit Unit_Button at RB3_bit; // Set Hunderter
// Messages
char Message1[]="Pause 1s - 1um";
char Message2[]="Running";
char Message3[]="Stop";
char Message4[]="Anzahl: ";
char Message5[]="Pulse
ca. 500Hz: ";
unsigned int i, j, unit=0, ten=0, hun=0, ON_OFF=0, index=0, clear, time;
char *digit = "000";
// 300ms Delay
void Delay_300(){
Delay_ms(300);
}
void Display_Digits(){
digit[0]=hun+48; // Hunterder
digit[1]=ten+48; //Zehner
digit[2]=unit+48; //Einer
Lcd_Out(2,12,digit);
}
void start_timer(unsigned int MinVal){
unsigned int temp1, temp2, temp3;
//Relay = 1;
ON_OFF = 1;
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1,Message2);
Lcd_Out(2,1,Message5);
OPTION_REG = 0x80 ;
INTCON = 0x90;
Delay_ms((1000));//Neue Wartezeit-Pause vor dem Pulsen
for (i=0; i<MinVal; i++){
temp1 = (MinVal-i)%10 ; //Einerstelle
temp2 = (MinVal-i)/10 ; //Zehnerstelle
temp3 = (MinVal-i)/100 ; //Hunterderstelle
j=1;
do {
//Delay_ms(1000); Pulsausgabe
Relay = 0;
//Delay_us(10); //Mikro statt Millisekunden
Delay_ms(1);
Relay = 1;
//Delay_us(10); //Mikro statt Millisekunden
Delay_ms(1);
j++;