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

PLC like functions

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







PLC like functions
PostPosted: Fri Jan 28, 2005 1:01 pm     Reply with quote

My problem is , I need some of the functions of an PLC hardware.
1 ) As in a PLC , I need to use nearly 30 timers that has a time base of 10ms. and has an Set value , current value, enable input (boolean) and time elapsed output (boolean).

2) logical functions has to be cascaded in a row , nearly 8 functions in a rung.
3) Whole system must work in such a sequence as follows.
main()
{
Init_MCU();
Init_PLC();
while(1)
{ get_inputs();
process_ladder();
write_outputs();
}
}

The main benefit of this approach is the rule based control ability of each discrete input and output. In classical programming, especially time delays causes problems. Let say if you use delay_ms(500) , all the main loop stops for half second.

With above written way , I can use one of the timer as a constant time base.

Did somebody try this way of programming? , can I find some samples?

Thanks to everybody for help.

P.S. Currently, in my spare time , I am working on a programming environment to use PICs and CCS compiler to write classical Ladder algorithms, a sort of ladder to CCS compiler translater. I am going to publish it as open source. Yet have a long way to go.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jan 28, 2005 3:32 pm     Reply with quote

Quote:
I need to use nearly 30 timers that has a time base of 10ms

I don't know if this will help or not, but here are some links:

This thread has links to various multi-tasking sample code.
The links show how to do a few software timers using a
hardware Timer interrupt routine.
http://www.ccsinfo.com/forum/viewtopic.php?t=21260

More multi-tasking examples:
http://www.microchipc.com/Hi-Tech_C_multitask.htm
http://www.bknd.com/cc5x/multitasking.shtml

This "vertical counter" page may be of interest.
I've never found a use for it.
http://www.dattalo.com/technical/software/pic/vertcnt.html
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