CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

rotary encoder and printf....
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
asunca



Joined: 09 Sep 2005
Posts: 36

View user's profile Send private message

PostPosted: Wed Sep 28, 2005 11:42 am     Reply with quote

i couldnt get what you meant sseidman . your language is tough ..
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Wed Sep 28, 2005 11:51 am     Reply with quote

@sseidman wrote:
Quote:

For many apps, it would be ill advised to give up the ghost on your count to update a display. The count should be inviolate.

Every project has its own hints. By no way I try to give a universal solution.
Anyway I would like to listen @asunca�s result

@asunca project proposal:
Quote:

"count" is incremented and according to timer0 interrupt speed (variable: hiz) is calculated and displayed every seconds.



@asunca in your code:
Code:

while(1)
    {
      //while(input(pin_A1==0));     
      //sayim++;             
      //while(input(pin_A1));   
      if (input(pin_a1))
      {
         sayim++;
         while(input(pin_a1));  // !!!!!! 
      }


while(input(pin_a1)); what if the encoder stop at this condition ?

You need to work around this looking for an escape procedure to prevent this situation, for example:

Code:
 
while(1)
     {
      if (input(pin_a1))
       {
         sayim++;
         timeout = 50;
         do
           {
            timeout--;       
             ....   // here can add a us delay...
           }while(input(pin_a1) && timeout );
       }
     }



Humberto


Last edited by Humberto on Wed Sep 28, 2005 12:08 pm; edited 1 time in total
asunca



Joined: 09 Sep 2005
Posts: 36

View user's profile Send private message

PostPosted: Wed Sep 28, 2005 12:08 pm     Reply with quote

oh i ve got you some.. we are putting a long delay, longer than the isr time. so the count stays cleared.. ??
asunca



Joined: 09 Sep 2005
Posts: 36

View user's profile Send private message

PostPosted: Sat Oct 01, 2005 3:00 am     Reply with quote

but this time nothing seems wrong but the speed is not what it is expected to be. it must be near 160 but now it shows up to ten. what is the problem
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Sat Oct 01, 2005 9:05 am     Reply with quote

Quote:

but this time nothing seems wrong but the speed is not what it is expected to be.
it must be near 160 but now it shows up to ten. what is the problem



In previous post you mentioned an encoder, as your project use only one input,
basically it is more likely a tachometer... but as you are using some non english
variables names (sayac=0; sayim=0; hiz_previous=0; hiz=0; sn=0; etc)
we doesn�t make sense what do they mean.
Also you are using RTCC to know the speed, I doesn�t see any function F=1/P
to convert the Period in Freq.

Pls could you post a clear description of what do you want to do ?
1) What do you want to measure (Speed or Position)
2) Min/Max Freq involved.
3) Range.
4) Sample rate.
5) Aquired data refresh rate display.
6) Expected % count/pos error tolerance.

Humberto
asunca



Joined: 09 Sep 2005
Posts: 36

View user's profile Send private message

PostPosted: Mon Oct 03, 2005 12:25 am     Reply with quote

i am building a measurement device making the calculations of rotates/sec

when "sayac" is 2, the rtcc is on the second interrupt and 65,5*2= 131ms has passed.

there are black short lines on my encoder shaft, you know that kind of counting algorithms, "sayim" is the count of passing lines. say that number of the holes passing on a slotted encoder. sayim is counted and multipled by a number that is calculated according to my pre-calculations for to find the rotational speed of rotor.

when "sn" is approximately 20 , this means one second has passed, we should refresh the lcd.

if you look at the previous entries, i was recommended to use "hiz_previous" to compare actual "hiz", by the way hiz means rotational speed here, and the previous one. if they are not equal there is no need to refresh the lcd. and i should do little things on the isr so i set a flag to show that lcd should be refreshed.

and the slotted optocoupler input is on the A1 input.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group