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

Unable to call and compare integer in pic18f4620

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



Joined: 14 Jun 2012
Posts: 3

View user's profile Send private message AIM Address

Unable to call and compare integer in pic18f4620
PostPosted: Thu Jun 14, 2012 9:07 am     Reply with quote

Code:
while(TRUE)
       {
       if(!input(Button1))             // when Button1 pressed
      {  while(!input(Button1))   //take action after Button1 released
         {}
        delay_ms(1000);//
        i++;
      }

      if (kbhit())
      {x = getc();}
      if (x=='a')     // if signal 'a' is received via xbee after call button is pressed at counter

      {
      if(j<i)
      {j++;}     //increase current display number
      }
       
     


Dear all,

Thanks temtronic for helping me in solving the xbee communication problem. Now, i am able to communicate between two panels via XBEE.

However, i am not able to get the output desired.
My sistem is doing counting for queue management system.
There are two numbers:
i - customer input number which will be input by customer arriving via button 1
j - internal counter which will be increased to be displayed on the display panel, increased when call button is pressed.

When a customer come in, he will press button 1 and increasing number i.
Then when the counter press the button, zigbee signal 'a' will be transmitted and once the signal 'a' is received, the number j should be increased, and show the current value of number j on display.

However, using the code above, there is no problem if only one customer in waiting list. But when there are customers waiting, the display is not correct.

Theoritically, if initial number displayed is 000, if three customer came in and pressed button 1, internal number should be 003, but when signal come in via zigbee, display should only show 001, follow by 002 and 003 after button pressed one by one.

But when i press the button at counter, the number straight go to 003, the last number. Any idea how to solve this?
John Morley



Joined: 09 Aug 2004
Posts: 97

View user's profile Send private message

PostPosted: Thu Jun 14, 2012 9:28 am     Reply with quote

Hi,

The formatting of your code is really ugly and non-standard, so I didn't even bother to try to follow the logic. You might want to clean it up first before posting because other members will probably have the same reaction.

Here is a resource that might help: http://en.wikipedia.org/wiki/Indent_style

Further, the best way to solve a problem like this is to do it yourself by inserting some diagnostic printf statements, and use them to follow the flow of the code. IOW, see what the code is actually doing at each stage, and compare that to what you expect. If you dedicate a single I/O pin to diagnostic messages, you won't regret it. Connect this pin via a MAX232 IC to the serial port of your PC.

John
_________________
John Morley
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