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

SHT15,MPX4115A and external pulse counter with PIC16F72
Goto page Previous  1, 2, 3, 4, 5  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
stijn023



Joined: 28 Sep 2010
Posts: 49

View user's profile Send private message

PostPosted: Wed Jan 26, 2011 10:11 am     Reply with quote

I use 5V as Vcc so it needs to work and the resistor is to limit the current through the reed contact.

Is the scheme good that I use?

Thanks for replying
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jan 26, 2011 2:55 pm     Reply with quote

I have no idea if your circuit will work. Look at the signal coming from it
with an oscilloscope and make sure it goes from 0v to 4v (minimum).
If it does, then it will probably work. Just do it.
stijn023



Joined: 28 Sep 2010
Posts: 49

View user's profile Send private message

PostPosted: Thu Jan 27, 2011 5:11 am     Reply with quote

I have test it with an oscilloscope and I get readings from 0 to 4.5 V so it need to work.

Thanks for the help
stijn023



Joined: 28 Sep 2010
Posts: 49

View user's profile Send private message

PostPosted: Tue Feb 08, 2011 12:03 pm     Reply with quote

Hi,

would this program works?
Code:

#include <16F876.h>
#device adc=10    *=16

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES HS                       //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES NOPUT                    //No Power Up Timer
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD                    //No EE protection
#FUSES NOWRT                    //Program memory not write protected
#FUSES NODEBUG                  //No Debug mode for ICD

#use delay(clock=4000000)

#include <lcd_driver.c>

void main()
{
   lcd_init();
   set_tris_b(11000011);
   lcd_gotoxy(1,4);
   
   if(input(PIN_C1)){
   printf(lcd_putc,"\fNOORD");}
   if(input(PIN_C0)){
   printf(lcd_putc,"\fOOST");}
   if(input(PIN_C6)){
   printf(lcd_putc,"\fZUID");}
   if(input(PIN_C7)){
   printf(lcd_putc,"\fWEST");}
   
   while(1);
}


It need to see what level there is on this input of the pic.

I test it with Proteus but there it doesn't work.

Thanks for the help.
temtronic



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

View user's profile Send private message

PostPosted: Tue Feb 08, 2011 12:28 pm     Reply with quote

As previoulsy stated Proteus is FULL of BUGs...
it's a simulator, NOT the real World!

You should always burn a PIC to properly test code.
stijn023



Joined: 28 Sep 2010
Posts: 49

View user's profile Send private message

PostPosted: Tue Feb 08, 2011 12:30 pm     Reply with quote

OK, I will try it in the real world.

temtronic wrote:
As previoulsy stated Proteus is FULL of BUGs...
it's a simulator, NOT the real World!

You should always burn a PIC to properly test code.
stijn023



Joined: 28 Sep 2010
Posts: 49

View user's profile Send private message

PostPosted: Thu Feb 10, 2011 10:38 am     Reply with quote

Hi,

how do you declare 4 inputs into one variable?

Thanks for the help
temtronic



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

View user's profile Send private message

PostPosted: Thu Feb 10, 2011 10:49 am     Reply with quote

depends on what your four inputs are !
Are they individuals bits or byte wide inputs or 'wider'.
If bits are they from one port or from several ports ?

There are plenty of examples that CCS provides in the examples folder as well as some in the manual.
stijn023



Joined: 28 Sep 2010
Posts: 49

View user's profile Send private message

PostPosted: Thu Feb 10, 2011 10:51 am     Reply with quote

Hi,

the inputs are pin C0, C1, C6 and C7.
I want to put them in one variable.

So is this possible?

Thanks for replying
stijn023



Joined: 28 Sep 2010
Posts: 49

View user's profile Send private message

PostPosted: Thu Feb 10, 2011 12:53 pm     Reply with quote

Code:
int8 waarde;
   waarde = input(opto1) & input(opto2) & input(opto3) & input(opto4);


If I set this in a variable I can only use this 1111 declaration because this four inputs are high.

Is there some kind of declaration I can have the code from 0000 till 1111.

Thanks for the help.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Feb 10, 2011 1:04 pm     Reply with quote

Use multiple lines of code. Use the input() function to read the pin,
and use the bit_set() function to set a specific bit in a variable.

Download the CCS manual and put it on your desktop.
http://www.ccsinfo.com/downloads/ccs_c_manual.pdf

There are usually several CCS functions for each feature of the PIC.
You're interested in I/O pin functions and bit operations, so look in these sections for a list of these functions:
Quote:

FUNCTIONAL OVERVIEWS
- General Purpose I/O

and
Quote:

BUILT-IN-FUNCTIONS:

- Discrete I/O

- BIT/BYTE MANIPULATION


Also see the last example program in this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=18949
stijn023



Joined: 28 Sep 2010
Posts: 49

View user's profile Send private message

PostPosted: Thu Feb 10, 2011 1:52 pm     Reply with quote

Thanks for responding.

But are in this link: http://www.ccsinfo.com/forum/viewtopic.php?t=18949 the pins in or outputs?

Thanks for replying

PCM programmer wrote:
Use multiple lines of code. Use the input() function to read the pin,
and use the bit_set() function to set a specific bit in a variable.

Download the CCS manual and put it on your desktop.
http://www.ccsinfo.com/downloads/ccs_c_manual.pdf

There are usually several CCS functions for each feature of the PIC.
You're interested in I/O pin functions and bit operations, so look in these sections for a list of these functions:
Quote:

FUNCTIONAL OVERVIEWS
- General Purpose I/O

and
Quote:

BUILT-IN-FUNCTIONS:

- Discrete I/O

- BIT/BYTE MANIPULATION


Also see the last example program in this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=18949
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Feb 10, 2011 2:00 pm     Reply with quote

There are two programs by me in that thread. The first one is outputting
to i/o pins. The 2nd program is reading i/o pins, and setting bits in a variable.
stijn023



Joined: 28 Sep 2010
Posts: 49

View user's profile Send private message

PostPosted: Thu Feb 10, 2011 2:02 pm     Reply with quote

OK, thanks for the help.
I will search it to understand what I need to do.

Thanks for the quick responding.

PCM programmer wrote:
There are two programs by me in that thread. The first one is outputting
to i/o pins. The 2nd program is reading i/o pins, and setting bits in a variable.
stijn023



Joined: 28 Sep 2010
Posts: 49

View user's profile Send private message

PostPosted: Thu Feb 10, 2011 2:41 pm     Reply with quote

Hi,

I test it with a simple program and it works so thank you for the help.
The program works I will post it in the next few days.

@PCM programmer: Because your great help I would like to mention you in my thesis. Is this allright for you?

Thanks for the great help
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, 4, 5  Next
Page 4 of 5

 
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