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

HX710B .h drive

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



Joined: 15 Feb 2024
Posts: 2

View user's profile Send private message

HX710B .h drive
PostPosted: Thu Feb 15, 2024 1:34 pm     Reply with quote

Hi HX710B digital pressure sensor .h file
I need it with 16f877a.
Ttelmah



Joined: 11 Mar 2010
Posts: 19459

View user's profile Send private message

PostPosted: Fri Feb 16, 2024 2:12 am     Reply with quote

Just write it.
It is a very simple serial protocol. Hold the clock low.
You just read the DOUT pin, when it is low a conversion is available.
Send 25, 26 or 27 clocks. 25 clocks reads the differential input. 26
reads temperature (on the A chip), or Dvdd-Avdd
(on B chip). 27 reads the differential input like 25, but at 4* the rate.
Raising the clock and leaving it high, powers down the chip.
The number of clocks configures what the next conversion will do.
Just be aware the result is in 2's complement form. Code on how to
simply handle this has been posted many times in the main forum.
This should be writable in less than 20 minutes by any competent
programmer.
huseyin



Joined: 15 Feb 2024
Posts: 2

View user's profile Send private message

PostPosted: Fri Feb 16, 2024 1:02 pm     Reply with quote

I cannot measure above 10 kPa



#include <16f877a.h>

#fuses XT,NOWDT,PROTECT,NOBROWNOUT,NOLVP,NOPUT,NOWRT,NODEBUG,NOCPD

#use delay (clock=4000000) // Gecikme fonksiyonu için kullanılacak osilatör frekansı belirtiliyor.
#use spi( SPI1, FORCE_HW, BITS=8, stream=SPI_STREAM)
#include <lcd420.c> // lcd.c dosyası tanıtılıyor
#define HX711_CLK pin_d3
#define HX711_DAT pin_d2
unsigned int32 ADC_DATA=0;
unsigned int32 Get_Load_Cell_Values()
{

unsigned int32 Count;
unsigned char i;
signed int32 Count_C;

Output_low(HX711_CLK);
Count=0;

while(Input(HX711_DAT));
for (i=0;i<24;i++)
{

Output_High(HX711_CLK);

Count=Count<<1;
Output_low(HX711_CLK);

if(Input(HX711_DAT)) Count++;
}
Output_High(HX711_CLK);
Count=Count^0x800000;

Output_Low(HX711_CLK);


return(Count);


}
void main ( )
{
setup_psp(PSP_DISABLED); // PSP birimi devre dışı


setup_timer_1(T1_DISABLED); // T1 zamanlayıcısı devre dışı

setup_adc_ports(NO_ANALOGS); // ANALOG giriş yok
setup_adc(ADC_OFF); // ADC birimi devre dışı
setup_CCP1(CCP_off); // CCP1 birimi devre dışı
setup_ccp2(CCP_off);


lcd_init(); // LCD hazırlanıyor


while(1) // Sonsuz döngü
{

adc_data=Get_Load_Cell_Values();
printf(lcd_putc,"\f %lu ",adc_data);

delay_ms(200);
} }

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