View previous topic :: View next topic |
Author |
Message |
stijn023
Joined: 28 Sep 2010 Posts: 49
|
|
Posted: Wed Jan 26, 2011 10:11 am |
|
|
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
|
|
Posted: Wed Jan 26, 2011 2:55 pm |
|
|
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
|
|
Posted: Thu Jan 27, 2011 5:11 am |
|
|
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
|
|
Posted: Tue Feb 08, 2011 12:03 pm |
|
|
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
|
|
Posted: Tue Feb 08, 2011 12:28 pm |
|
|
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
|
|
Posted: Tue Feb 08, 2011 12:30 pm |
|
|
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
|
|
Posted: Thu Feb 10, 2011 10:38 am |
|
|
Hi,
how do you declare 4 inputs into one variable?
Thanks for the help |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9245 Location: Greensville,Ontario
|
|
Posted: Thu Feb 10, 2011 10:49 am |
|
|
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
|
|
Posted: Thu Feb 10, 2011 10:51 am |
|
|
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
|
|
Posted: Thu Feb 10, 2011 12:53 pm |
|
|
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
|
|
Posted: Thu Feb 10, 2011 1:04 pm |
|
|
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
|
|
Posted: Thu Feb 10, 2011 1:52 pm |
|
|
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
|
|
Posted: Thu Feb 10, 2011 2:00 pm |
|
|
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
|
|
Posted: Thu Feb 10, 2011 2:02 pm |
|
|
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
|
|
Posted: Thu Feb 10, 2011 2:41 pm |
|
|
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 |
|
|
|