i need Tachometer or RPM meter code for mikroC PRO for AVR
thanks
Please Help
Re: Please Help
Thank you very much in advance I do not work it well
I have a code for the Atmel Studio
converted it to mikroC PRO for AVR
Atmel Studio code is working perfectly
mikroC PRO for AVR It does not work well
two code is same,I do not understand where the error is
////////////////////////////////mikroC PRO for AVR/////////////////////
sbit LCD_RS at PORTB2_bit;
sbit LCD_EN at PORTD7_bit;
sbit LCD_D4 at PORTD3_bit;
sbit LCD_D5 at PORTD4_bit;
sbit LCD_D6 at PORTD5_bit;
sbit LCD_D7 at PORTD6_bit;
sbit LCD_RS_Direction at DDB2_bit;
sbit LCD_EN_Direction at DDD7_bit;
sbit LCD_D4_Direction at DDD3_bit;
sbit LCD_D5_Direction at DDD4_bit;
sbit LCD_D6_Direction at DDD5_bit;
sbit LCD_D7_Direction at DDD6_bit;
char txt1[16];
int count =0 absolute 0x90;
int a=0;
int main() {
DDRD= 0;
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
while(1)
{
WordToStr(count, txt1);
Lcd_Out(2,4,txt1);
if (a==0) {
if ((PIND1_bit==0)||(PIND2_bit==0)){
a= 1;
if (PIND1_bit==0){
if (count<1024){
count++;
}
}
if (PIND2_bit==0){
if (count>0){
count--;
}
}
}
}
if ((PIND1_bit==1)&&(PIND2_bit==1) ) {
a = 0;
}
}
}
//////////////////////////////// Atmel Studio /////////////////////
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include "libs/lcd.h"
int main(void)
{
DDRD= 0;
LCDInit(LS_NONE);
LCDClear();
int count =0;
int a=0;
while(1)
{
LCDWriteIntXY(4,1,count,4);
if (a==0){
if ((bit_is_clear(PIND,1))||(bit_is_clear(PIND,2))) {
a= 1;
if (bit_is_clear(PIND,1) ){
if (count<1024){
count++;
}
}
if (bit_is_clear(PIND,2)){
if (count>0)
{
count--;
}
}
}
}
if ((bit_is_set(PIND,1))&&(bit_is_set(PIND,2) )){
a = 0;
}
}
}
Here is proteus simulation and code files
https://mega.nz/#!gMFQXZ5I!kZujz--hqY8I ... ZBZLnZEzDs
thanks
Last edited by mikanos on 30 Aug 2017 23:33, edited 1 time in total.
Re: Please Help
Hi,
What exactly is not working here ?
Have you tried this on the real hardware ?
Regards,
Filip.
What exactly is not working here ?
Have you tried this on the real hardware ?
Regards,
Filip.
Re: Please Help
filip wrote:Hi,
What exactly is not working here ?
Have you tried this on the real hardware ?
Regards,
Filip.
If i use the mikroC Lcd_Out command Puls are reading less
yes i tried this on the real hardware
For example my Encoder is Pulse Per Revulation 64 Puls
mikroC code read Per Revulation 40 or 55 puls
Atmel Studio read Per Revulation 64
it is same hardware and same configuration
If i use the Lcd_Out command Maybe the reading speed is dropping
Re: Please Help
Hi,
Could you do a simple debug of this, using UART or LEDs, and see in each iteration what is going on ?
Regards,
Filip.
Could you do a simple debug of this, using UART or LEDs, and see in each iteration what is going on ?
Regards,
Filip.
Re: Please Help
filip wrote:Hi,
Could you do a simple debug of this, using UART or LEDs, and see in each iteration what is going on ?
Regards,
Filip.
If i do not use the LCD_OUT command ,It works perfectly
I tested my hardware but if I use the LCD_OUT command then it does not work properly
the problem is only in the LCD_OUT command Slowing down the MCU