We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]
posted on 2012/12/14 01:03:59 PM CET
i need a sample code to read loadcell from ad7190 (http://www.analog.com analog device)
i write this code but i dont give result
// LCD module connections
sbit LCD_RS at RD2_bit;
sbit LCD_EN at RD3_bit;
sbit LCD_D4 at RD4_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_D7 at RD7_bit;
sbit LCD_RS_Direction at TRISD2_bit;
sbit LCD_EN_Direction at TRISD3_bit;
sbit LCD_D4_Direction at TRISD4_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D7_Direction at TRISD7_bit;
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
//unsigned short read_adc[3] = {0, 0, 0};
unsigned char read_adc[3] = {0, 0, 0}; //araye
char arr[11]={0,0,0,0,0,0,0,0,0} ;
char sum;
char avr;
char i=0 ;
char j=0 ;
char ddd[6];
char rdy ;
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
// adc7190 module connections
//sbit Chip_Select at RB2_bit;
//sbit Chip_Select_Direction at TRISB2_bit;
sbit Chip_Select at LATB2_bit;
sbit Chip_Select_Direction at TRISB2_bit;
// End adc7190 module connections
//------------------------------------------------------------------------------
void reset7190(){
Chip_Select = 0 ;
Delay_ms(350);
SPI1_WRITE(0b11111111);
SPI1_WRITE(0b11111111);
SPI1_WRITE(0b11111111);
SPI1_WRITE(0b11111111);
Chip_Select = 1 ;
}
void configurationregister(){
Chip_Select = 0 ;
Delay_ms(350);
SPI1_WRITE(0b00010000) ;//configuration register
SPI1_WRITE(0b00000000) ;//Chop 00 { REFIN1(+) and REFIN1(-) } 0000
SPI1_WRITE(0b00000000) ;//Channel select bits 3taye akhar ya 000 ya 001 ya 010
SPI1_WRITE(0b00010111) ;//Burn REFDET 0 BUF U/B (111 ±39.06 mV )
Chip_Select = 1 ;
}
void moderegister(){
Chip_Select = 0 ;
Delay_ms(350);
SPI1_WRITE(0b00001000) ;// mode register
SPI1_WRITE(0b11101000) ;//(000 Continuous conversion mode / 110 System zero-scale calibration/ 111 full-scale calibration) DAT_STA (10 Internal 4.92 MHz clock ) 00 0b11001000
SPI1_WRITE(0b00000000) ;// SINC3 0 ENPAR 0 Single REJ60
SPI1_WRITE(0b00000000) ;// Filter output data rate select bits.
Chip_Select = 1 ;
}
void moderegister2(){
Chip_Select = 0 ;
Delay_ms(350);
SPI1_WRITE(0b00001000) ;// mode register
SPI1_WRITE(0b00001000) ;
SPI1_WRITE(0b00000000) ;
SPI1_WRITE(0b00000000) ;
Chip_Select = 1 ;
}
void rdy_dataready(){
Chip_Select = 0 ;
Delay_ms(350);
SPI1_WRITE(0b01000000); //status register error ham dare
rdy = SPI1_Read(0);
rdy= rdy & 0b10000000 ;
rdy=rdy>>7 ;
Chip_Select = 1 ;
}
void read7190(){
Chip_Select = 0 ;
Delay_ms(350);
spi1_write(0b01011000); // 01 (011 Data register/data register plus status information ) 0 00
read_adc[0] = SPI1_Read(0);
read_adc[1] = SPI1_Read(0);
read_adc[2] = SPI1_Read(0);
Chip_Select = 1 ;
LongWordToStrWithZeros(read_adc, ddd); //dd=0123456789
}
void bpdsw(){
Chip_Select = 0 ;
Delay_ms(350);
j=40 ; //0b00101000
SPI1_WRITE(j) ;
//j=64 ; //0b01000000
SPI1_WRITE(0b01000000) ;
Chip_Select = 1 ;
}
//------------------------------------------------------------------------------
void InitMain() {
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(1,1,"Loadcell test");
Lcd_Out(2,1,"starting...");
Chip_Select = 1; // Deselect DAC
Chip_Select_Direction = 0; // Set CS# pin as Output
//SPI1_Init(); // Initialize SPI module
SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV4, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);
Delay_ms(2000);
}
//------------------------------------------------------------------------------
void main() {
InitMain();
reset7190();
configurationregister();
moderegister();
while (1){
Lcd_Out(2,1,"amir ");
moderegister2();
rdy_dataready();
// if ( rdy=1) {
read7190();
Lcd_Out(1,1,rdy);
Lcd_Out(2,1,read_adc[0]);
Lcd_Out(3,1,read_adc[1]);
Lcd_Out(4,1,ddd);
// }
}
}
posted on 2012/12/07 04:33:09 PM CET
Dear,
I am very much interested in PIC micro-controller and i also start my work. But i can't proceed ahead because i don't have any PIC burner. I will be very much happy if any one can give me PIC burner circuit diagram, necessary code. I will be very much thankful to that person.
email: ridoy092478@gmail.com
Thank you.
posted on 2012/12/01 04:36:44 AM CET
Hi There,
I am starting out with this new compiler(mikroc pro) and looking to make some device that uploads to cosm/pachube.
I need a simple example to get started, maybe one analog input and one output.
I have tried looking in google but, not much luck with mikroc example.
Cheers.
posted on 2012/11/30 10:59:14 AM CET
we need a ready project for PIC32 GSM to send and receive sms with the one click gsm (GL865)
posted on 2012/11/29 05:26:20 AM CET
can someone please give a schema for Easybee3 and pic18f45k22 for a breadboard setup (and maybe code to transmit like in example provided in the forum) using the internal oscillator btw i have the easypic7 developement board setuped as reciever with another easybee3 and pic18f45k22 on board
i hope you people understand my request/question?