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 support@ccsinfo.com

12F1822 IR Remote Receiver
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Denny9167



Joined: 15 Feb 2021
Posts: 49

View user's profile Send private message Send e-mail

PostPosted: Sat Mar 20, 2021 11:06 am     Reply with quote

What about something like this:

Code:


While(ir_code == 0xFF22DD)
output_high(PIN_A4);
delay_ms(500);



And the same code with PIN_A5?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Mar 20, 2021 11:39 am     Reply with quote

Don't sit there hanging on our every word. Just try it. If you have a
problem then post it.
Denny9167



Joined: 15 Feb 2021
Posts: 49

View user's profile Send private message Send e-mail

PostPosted: Sat Mar 20, 2021 1:39 pm     Reply with quote

PCM programmer wrote:
Don't sit there hanging on our every word. Just try it. If you have a
problem then post it.


Point taken, thanks
Denny9167



Joined: 15 Feb 2021
Posts: 49

View user's profile Send private message Send e-mail

PostPosted: Sat Mar 20, 2021 2:04 pm     Reply with quote

Ttelmah wrote:
Of course it is.

If you just have the code for button 1 turn on it's pin, and turn the others
off, then button 2 does the same, 3 etc. etc..
Then if you push 1, this pin will go on, and all others off. Staying on
till another button is pressed.


It works!! I added the “else” statement after each “if” statement, and the output_low() directive after. It now cycles through each button press. I appreciate all the patience with my discoveries.

I will post final code for this project when finished.
Denny9167



Joined: 15 Feb 2021
Posts: 49

View user's profile Send private message Send e-mail

PostPosted: Sun Mar 21, 2021 1:37 pm     Reply with quote

Is it possible to isolate 2 of the PINS from the while loop, to where any changes to the other 3 don’t affect the 2? Thanks again.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Mar 22, 2021 6:09 am     Reply with quote

Post your current while() loop so we can see what you're doing.
temtronic



Joined: 01 Jul 2010
Posts: 9081
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Mar 22, 2021 6:48 am     Reply with quote

You can probably 'mask' them.
'Masking' allows you to select or eliminate bits from bytes using logical AND and OR as required.
There may be info in the FAQ section of the manual, check some of the examples in the Example folder and of course ask Google !
Denny9167



Joined: 15 Feb 2021
Posts: 49

View user's profile Send private message Send e-mail

PostPosted: Mon Mar 22, 2021 9:57 am     Reply with quote

PCM programmer wrote:
Post your current while() loop so we can see what you're doing.


I’ve decided to just go with the code as is for now, the original code, I will just have to toggle each switch for an on/off.

When I do the final design on the PCB, I will include a programming header on the board so that I can update the firmware, when I finally getting right.

Here is the code for the three pins(A0 - A2),using the “if-else” directive, and it works great, but the pins I want to use for the motorized potentiometer(A4,A5) are effected by this code.

Code:


if(ir_code == 0xFF30CF)
output_high(PIN_A0);
else
output_low(PIN_A0);
if(ir_code == 0xFF18E7)
output_high(PIN_A1);
else
output_low(PIN_A1);
if(ir_code == 0xFF7A85);
output_high(PIN_A2);
else
output_low(PIN_A2);



I need to be able to isolate PIN_A4, and PIN_A5 from the other if -else statements. I’m going to put this one away for awhile and just use the original code. I have to now work on getting the Tx done. Thanks for the help.
Denny9167



Joined: 15 Feb 2021
Posts: 49

View user's profile Send private message Send e-mail

PostPosted: Mon Mar 22, 2021 10:01 am     Reply with quote

temtronic wrote:
You can probably 'mask' them.
'Masking' allows you to select or eliminate bits from bytes using logical AND and OR as required.
There may be info in the FAQ section of the manual, check some of the examples in the Example folder and of course ask Google !


Thanks I’ll do some research on that.
Denny9167



Joined: 15 Feb 2021
Posts: 49

View user's profile Send private message Send e-mail

PostPosted: Mon Mar 22, 2021 10:40 am     Reply with quote

temtronic wrote:
You can probably 'mask' them.
'Masking' allows you to select or eliminate bits from bytes using logical AND and OR as required.
There may be info in the FAQ section of the manual, check some of the examples in the Example folder and of course ask Google !


Something like this?

Code:


void stepper(int8 step){
  if(Direction == 0){
    switch(step){
      case 0: output_d(0b00000011); break;
      case 1: output_d(0b00000110); break;
      case 2: output_d(0b00001100); break;
      case 3: output_d(0b00001001); break;

Denny9167



Joined: 15 Feb 2021
Posts: 49

View user's profile Send private message Send e-mail

PostPosted: Mon Mar 22, 2021 11:11 am     Reply with quote

temtronic wrote:
You can probably 'mask' them.
'Masking' allows you to select or eliminate bits from bytes using logical AND and OR as required.
There may be info in the FAQ section of the manual, check some of the examples in the Example folder and of course ask Google !


Something like this?

Code:


void stepper(int8 step){
  if(Direction == 0){
    switch(step){
      case 0: output_d(0b00000011); break;
      case 1: output_d(0b00000110); break;
      case 2: output_d(0b00001100); break;
      case 3: output_d(0b00001001); break;

Denny9167



Joined: 15 Feb 2021
Posts: 49

View user's profile Send private message Send e-mail

PostPosted: Mon Mar 22, 2021 9:02 pm     Reply with quote

Just from reading the original code, there is nothing written in the code that tells the chip what to do when there are no commands coming from the IR sensor. From code we don’t know the state of the input pin, A3(low or high), so it’s only acting on the hexadecimal commands being sent by the transmitter, not what isn’t sent. I very well could be wrong and it wouldn’t be the first time.

I have a program for a 10F200, using SIRC protocol, that has just 3 outputs, 2 of which can be changed from latched to momentary by changing only a few directives. But it’s written in assembly code, a mile long!! It does a good job on my volume Control but very limited.
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, 3
Page 3 of 3

 
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