View previous topic :: View next topic |
Author |
Message |
Ömer Faruk
Joined: 15 Nov 2018 Posts: 42 Location: Çanakkale
|
Cny70 to Pcf8574 problem |
Posted: Wed Nov 21, 2018 12:46 pm |
|
|
In my project i will use eight Cny70 connected to PCF8574 as inputs. This circuit will be separate module. İ will connect this module to pic circuit with only 4 wires. hen i set this circuit in breadboard the inputs of PCF8574 always high although Cny70 sensors outputs are low. If i put direct 0V in the inputs of PCF8574 it detects that the input is low. Please help me.
[img]https://media.discordapp.net/attachments/514065401622167555/514899392826703874/Adsz.png?width=1202&height=676[/img]
Last edited by Ömer Faruk on Wed Nov 21, 2018 2:29 pm; edited 1 time in total |
|
|
dluu13
Joined: 28 Sep 2018 Posts: 395 Location: Toronto, ON
|
|
Posted: Wed Nov 21, 2018 1:10 pm |
|
|
It's a possible circuit problem... Do you have a schematic?
Also note that when starting up, the PCF8574 defaults to output.
And this isn't really a CCS question... |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19512
|
|
Posted: Wed Nov 21, 2018 1:45 pm |
|
|
You need to write 1's to all the output bits.
You can't use the pins as inputs unless this is done. Without this the pins will read permanently as 0, unless pulled up by a signal that has a very low impedance (<50R). Your direct connection is doing this. |
|
|
Ömer Faruk
Joined: 15 Nov 2018 Posts: 42 Location: Çanakkale
|
|
Posted: Wed Nov 21, 2018 2:34 pm |
|
|
dluu13 wrote: | It's a possible circuit problem... Do you have a schematic?
Also note that when starting up, the PCF8574 defaults to output.
And this isn't really a CCS question... |
I sent FF to PCF8574 in the ccs c code. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9226 Location: Greensville,Ontario
|
|
Posted: Wed Nov 21, 2018 2:37 pm |
|
|
We have to see your entire ,complete program. It could be something else...without seing your code we can only give 'general' hints.
Jay |
|
|
Ömer Faruk
Joined: 15 Nov 2018 Posts: 42 Location: Çanakkale
|
|
Posted: Wed Nov 21, 2018 2:48 pm |
|
|
temtronic wrote: | We have to see your entire, complete program. It could be something else...without seing your code we can only give 'general' hints.
Jay |
Code: | #include <16f877a.h>
#device *=16
#device ADC=10
#use delay (clock=20000000)
#use i2c(Master, sda=PIN_c4, scl=PIN_c3,Slow=100000)
#include <i2c_Flex_LCD.h>
#include <stdlib.h>
#fuses HS,NOWDT,NOPROTECT,NOBROWNOUT,NOLVP,NODEBUG // configura fuses
unsigned int value=0;
#define PORT_BASE_ADDRESS 0x70
unsigned char read_from_port();
void write_to_port(unsigned char data_byte);
unsigned char read_from_port()
{
unsigned char port_byte=0;
i2c_start();
i2c_write((PORT_BASE_ADDRESS + 1));
port_byte=i2c_read(0);
i2c_stop();
return port_byte;
}
void write_to_port(unsigned char data_byte)
{
i2c_start();
i2c_write(PORT_BASE_ADDRESS);
i2c_write(data_byte);
i2c_stop();
}
unsigned int i=0;
void main()
{
setup_psp(PSP_DISABLED);
setup_timer_1(T1_DISABLED); //Timer1 ayarları yapılıyor dahili clock kaynağı ve bölme oranı 1
setup_timer_2(T2_DISABLED,0,1);
setup_CCP1(CCP_OFF);
setup_comparator(NC_NC_NC_NC);
setup_adc(ADC_OFF);
setup_adc_ports(NO_ANALOGS);
lcd_init();
lcd_backlight=ON;
set_tris_b(0x0F);
output_c(0x00);
set_tris_c(0x02);
output_c(0x00);
ext_int_edge(H_TO_L);
disable_interrupts(int_ext);
disable_interrupts(GLOBAL);
write_to_port(0xFF);
while (TRUE)
{
value=read_from_port();
lcd_gotoxy(1,1);
printf(lcd_putc,"\f%x",value);
delay_ms(1000);
}}
|
by the way i use pcf8574A |
|
|
dluu13
Joined: 28 Sep 2018 Posts: 395 Location: Toronto, ON
|
|
Posted: Wed Nov 21, 2018 3:25 pm |
|
|
What happens when you remove your R4 pullup? |
|
|
Ömer Faruk
Joined: 15 Nov 2018 Posts: 42 Location: Çanakkale
|
|
Posted: Wed Nov 21, 2018 3:48 pm |
|
|
dluu13 wrote: | What happens when you remove your R4 pullup? |
I took out the circuit last night and set it up again. It worked. But this time i used qrd1114. I can't try cny70 because it is burned. Thank you all guys. |
|
|
|