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

Storing a stream on a variable

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guest








Storing a stream on a variable
PostPosted: Tue Jun 06, 2006 5:27 am     Reply with quote

Hello,
I am attempting interface of a weigand reader to my pic. My question is, how can i store an incoming pulse stream of highs and lows on a pin and properly set my variable. For instance as a certain pin goes low i want my variable to streams bit value. Example data variable is 00000000 then as pulses come in for 1 and 0 i want to be able to store the proper pulse to the variables bit location. For instance if i receive four pulses for ones and four pulses for zeros my variable must store 11110000. I hope i make any sense.

Thanks!
Christophe



Joined: 10 May 2005
Posts: 323
Location: Belgium

View user's profile Send private message

PostPosted: Tue Jun 06, 2006 5:55 am     Reply with quote

This smells like timers.

At what speed is the pulse train coming?

You can read a pin every X time in an interrupt.

then you have to read the pin and set a bit of an 8 bit variable.

Code:
int8 pulses , j = 0;

timer0_isr()
{
if ( input (PIN_X0))
     bit_set ( pulses, j )
else
     bit_clear (pulses , j )
j++;

if ( j = = 7 )
 j = 0;
}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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