Please Help

General discussion on mikroC PRO for AVR.
Post Reply
Author
Message
mikanos
Posts: 4
Joined: 26 Aug 2017 20:14

Please Help

#1 Post by mikanos » 26 Aug 2017 20:21

i need Tachometer or RPM meter code for mikroC PRO for AVR
thanks

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Please Help

#2 Post by filip » 28 Aug 2017 14:08


mikanos
Posts: 4
Joined: 26 Aug 2017 20:14

Re: Please Help

#3 Post by mikanos » 29 Aug 2017 22:09

filip wrote:Hi,

Try this :
https://libstock.mikroe.com/projects/vi ... er-project

Regards,
Filip.

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.

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Please Help

#4 Post by filip » 30 Aug 2017 14:15

Hi,

What exactly is not working here ?
Have you tried this on the real hardware ?

Regards,
Filip.

mikanos
Posts: 4
Joined: 26 Aug 2017 20:14

Re: Please Help

#5 Post by mikanos » 30 Aug 2017 16:20

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

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Please Help

#6 Post by filip » 31 Aug 2017 16:42

Hi,

Could you do a simple debug of this, using UART or LEDs, and see in each iteration what is going on ?

Regards,
Filip.

mikanos
Posts: 4
Joined: 26 Aug 2017 20:14

Re: Please Help

#7 Post by mikanos » 31 Aug 2017 19:21

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

Post Reply

Return to “mikroC PRO for AVR General”