data logger
-
- Posts: 16
- Joined: 12 Jul 2015 15:06
data logger
hello . i have made a data logger. with 18f4550 . this board following blow sections:
1.DS1307 with i2c connect to :RB0 & RB1
2.MAX232 connect to : RC7&RC6
3.SDcard????
for sd card i have to connect to pins: CLOCK:RB1 SDI:RB0 SDO:RC7 But this pins use at the ds1307 and max232 .now I'm confused.
what can i do???
1.DS1307 with i2c connect to :RB0 & RB1
2.MAX232 connect to : RC7&RC6
3.SDcard????
for sd card i have to connect to pins: CLOCK:RB1 SDI:RB0 SDO:RC7 But this pins use at the ds1307 and max232 .now I'm confused.
what can i do???
- biljana.nedeljkovic
- mikroElektronika team
- Posts: 1043
- Joined: 30 Jun 2015 15:15
Re: data logger
Hello,
mikroSD card click board uses SPI Interface. You can try to manage to work with the devices with software, in your code.
For example if you have more devices that work with SPI you only need to be careful to have separate CS lines for each of them.
I2C communication also can have multiple devices connected, it just needs to know the slave addresses so it can call each device.
You can consider to use another high-count pin microcontroller, or use the peripherals in the way they don't interfere in the program.
Kind regards,
Biljana
mikroSD card click board uses SPI Interface. You can try to manage to work with the devices with software, in your code.
For example if you have more devices that work with SPI you only need to be careful to have separate CS lines for each of them.
I2C communication also can have multiple devices connected, it just needs to know the slave addresses so it can call each device.
You can consider to use another high-count pin microcontroller, or use the peripherals in the way they don't interfere in the program.
Kind regards,
Biljana
-
- Posts: 16
- Joined: 12 Jul 2015 15:06
Re: data logger
can you give that code? i cant find codes for interface software spi with sd card
-
- Posts: 16
- Joined: 12 Jul 2015 15:06
Re: data logger
hello
can i use Peripheral Pin Select Library?????
please answerrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
can i use Peripheral Pin Select Library?????
please answerrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
- biljana.nedeljkovic
- mikroElektronika team
- Posts: 1043
- Joined: 30 Jun 2015 15:15
Re: data logger
Hello,
The code for microSD click board is available on the Libstock:
http://www.libstock.com/projects/view/2 ... ck-example
You can see how to use Software SPI library in the Help file in the compiler:
http://www.mikroe.com/download/eng/docu ... ibrary.htm
The PPS library is also available in the Help file. But unfortunately that library is not available for the PIC18F4550.
Best regards,
Biljana
The code for microSD click board is available on the Libstock:
http://www.libstock.com/projects/view/2 ... ck-example
You can see how to use Software SPI library in the Help file in the compiler:
http://www.mikroe.com/download/eng/docu ... ibrary.htm
The PPS library is also available in the Help file. But unfortunately that library is not available for the PIC18F4550.
Best regards,
Biljana
Last edited by biljana.nedeljkovic on 28 Dec 2015 14:38, edited 1 time in total.
-
- Posts: 16
- Joined: 12 Jul 2015 15:06
Re: data logger
thanks.
but now i wiring the circuit similar 18f4550 datasheet .and writing code similar example to the microcontroller. but dont have any action(file or any other at the micro sd).do you have 18f4550+mmc prog ?????
but now i wiring the circuit similar 18f4550 datasheet .and writing code similar example to the microcontroller. but dont have any action(file or any other at the micro sd).do you have 18f4550+mmc prog ?????
- biljana.nedeljkovic
- mikroElektronika team
- Posts: 1043
- Joined: 30 Jun 2015 15:15
Re: data logger
Hello,
I am not sure I understood your issue now.
Can you explain more, how did you experienced the problem with your project? You can share some small code if you want.
Please check the Libstock for more examples and projects.
http://www.libstock.com/
Best regards,
Biljana
I am not sure I understood your issue now.
Can you explain more, how did you experienced the problem with your project? You can share some small code if you want.
Please check the Libstock for more examples and projects.
http://www.libstock.com/
Best regards,
Biljana
-
- Posts: 16
- Joined: 12 Jul 2015 15:06
Re: data logger
dont find!! please help me. i only want a sample code from (18f4550+ micro sd).with micro basic. can you write for me??
- biljana.nedeljkovic
- mikroElektronika team
- Posts: 1043
- Joined: 30 Jun 2015 15:15
Re: data logger
Hello,
I can only suggest you to look at the example projects already provided for SD card.
Take a look at the MMC library in the Help in the compiler.
Or you can consider to change microcontroller.
You can also try to write code and submit it here so we can give an advice.
Best regards,
Biljana
I can only suggest you to look at the example projects already provided for SD card.
Take a look at the MMC library in the Help in the compiler.
Or you can consider to change microcontroller.
You can also try to write code and submit it here so we can give an advice.
Best regards,
Biljana
-
- Posts: 16
- Joined: 12 Jul 2015 15:06
Re: data logger
program MyProject
' Declarations section
DIM FILE_CONTENTS AS CHAR[10]
dim
Mmc_Chip_Select as sbit at LATC0_bit ' for writing to output pin always use latch (PIC18 family)
Mmc_Chip_Select_Direction as sbit at TRISC0_bit
main:
ADCON1=%00001111
CMCON = CMCON or 7
SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV4, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH)
WHILE(1)
Mmc_Fat_Set_File_Date(2010, 4, 19, 9, 0, 0) ' Set file date & time info
Mmc_Fat_Assign("aaaaa.TXT", 0xa0) ' Will not find file and then create file
Mmc_Fat_Rewrite
FILE_CONTENTS="aaaaaa"
if (Mmc_Fat_Init() = 0) then
Mmc_Fat_Append()
Mmc_Fat_Write(file_contents, 27)
delay_ms(1000)
end if
WEND
i writed this code.but dont work. i have not any file(aaaaa.txt) at the micro sd
' Declarations section
DIM FILE_CONTENTS AS CHAR[10]
dim
Mmc_Chip_Select as sbit at LATC0_bit ' for writing to output pin always use latch (PIC18 family)
Mmc_Chip_Select_Direction as sbit at TRISC0_bit
main:
ADCON1=%00001111
CMCON = CMCON or 7
SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV4, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH)
WHILE(1)
Mmc_Fat_Set_File_Date(2010, 4, 19, 9, 0, 0) ' Set file date & time info
Mmc_Fat_Assign("aaaaa.TXT", 0xa0) ' Will not find file and then create file
Mmc_Fat_Rewrite
FILE_CONTENTS="aaaaaa"
if (Mmc_Fat_Init() = 0) then
Mmc_Fat_Append()
Mmc_Fat_Write(file_contents, 27)
delay_ms(1000)
end if
WEND
i writed this code.but dont work. i have not any file(aaaaa.txt) at the micro sd
- biljana.nedeljkovic
- mikroElektronika team
- Posts: 1043
- Joined: 30 Jun 2015 15:15
Re: data logger
Hello,
Please use the code for the mikroSD card click as a reference.
http://www.libstock.com/projects/view/2 ... ck-example
I will also double check the code and let you know what is the problem.
Kind regards,
Biljana
Please use the code for the mikroSD card click as a reference.
http://www.libstock.com/projects/view/2 ... ck-example
I will also double check the code and let you know what is the problem.
Kind regards,
Biljana
-
- Posts: 16
- Joined: 12 Jul 2015 15:06
Re: data logger
HELLO
I wrote this prog. but portb.0 is not light. and i dont have any text at MMC.
i think the mmc not init. what is problem.?please help me.
char filename[] = "UART.TXT";
unsigned char txt[] = "Writing to SD Card...";
// MMC module connections
sbit Mmc_Chip_Select at LATA5_bit; // for writing to output pin always use latch (PIC18 family)
sbit Mmc_Chip_Select_Direction at TRISA5_bit;
void main()
{
OSCCON = 0b01110111;
ADCON1 |= 0x0F; // Configure AN pins as digital
CMCON |= 7; // Turn off comparators
// Configure all PORTS at the standard Slew Rate
//
TRISD=0;
LATB0_BIT=1 ;
// Initialise the SPI bus
//
SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV16,_SPI_DATA_SAMPLE_MIDDLE,_SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);
// use fat16 quick format instead of init routine if a formatting is needed
if (Mmc_Fat_Init() == 0) {
// reinitialize spi at higher speed
LATD=1;
delay_ms(200);
SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV4, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);
Mmc_Fat_Assign(&filename, 0x80); // Find existing file or create a new one
Mmc_Fat_Rewrite();
LATD=7;
Mmc_Fat_Write(txt,21);
}
for(;;);
}
I wrote this prog. but portb.0 is not light. and i dont have any text at MMC.
i think the mmc not init. what is problem.?please help me.
char filename[] = "UART.TXT";
unsigned char txt[] = "Writing to SD Card...";
// MMC module connections
sbit Mmc_Chip_Select at LATA5_bit; // for writing to output pin always use latch (PIC18 family)
sbit Mmc_Chip_Select_Direction at TRISA5_bit;
void main()
{
OSCCON = 0b01110111;
ADCON1 |= 0x0F; // Configure AN pins as digital
CMCON |= 7; // Turn off comparators
// Configure all PORTS at the standard Slew Rate
//
TRISD=0;
LATB0_BIT=1 ;
// Initialise the SPI bus
//
SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV16,_SPI_DATA_SAMPLE_MIDDLE,_SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);
// use fat16 quick format instead of init routine if a formatting is needed
if (Mmc_Fat_Init() == 0) {
// reinitialize spi at higher speed
LATD=1;
delay_ms(200);
SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV4, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);
Mmc_Fat_Assign(&filename, 0x80); // Find existing file or create a new one
Mmc_Fat_Rewrite();
LATD=7;
Mmc_Fat_Write(txt,21);
}
for(;;);
}
- biljana.nedeljkovic
- mikroElektronika team
- Posts: 1043
- Joined: 30 Jun 2015 15:15
Re: data logger
Hello,
Please try to use the same logic as in our example - write the content into the file by using a loop and Mmc_Fat_Write() function.
Also, try to assign the file by using
Mmc_Fat_Assign(&filename, 0xA0);
Kind regards,
Biljana
Please try to use the same logic as in our example - write the content into the file by using a loop and Mmc_Fat_Write() function.
Also, try to assign the file by using
Mmc_Fat_Assign(&filename, 0xA0);
Kind regards,
Biljana
-
- Posts: 16
- Joined: 12 Jul 2015 15:06
Re: data logger
tnks. i wrote a prog. and this true at the proteus(with winimage). i have a good reply.
this prog is at the blow. but at the board , i dont have any thing at the MMC.
#define BUFFER_SIZE 15
//Memory Card Chip Select Connection
sfr sbit Mmc_Chip_Select at RB4_bit;
sfr sbit Mmc_Chip_Select_Direction at TRISB4_bit;
//
// End LCD module connections
unsigned char filename[] = "Temp.TXT";
unsigned char error;
unsigned char i;
unsigned int adc_value;
unsigned char Temperature_Log[BUFFER_SIZE];
void main()
{
unsigned char ones,tens,hundreds;
unsigned int temp;
TRISD = 0x00;
Delay_ms(100);
Delay_ms(1000);
ADCON0 = 0b00000001; //A/D Converter Power Up
ADCON1 = 0b00001110; //All Analog Channels
ADCON2 = 0b10111110; //Right Justfied and Slowest Clock for better accuracy
ADC_Init();
SPI1_Init();
SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV64, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);
Delay_us(10);
error = MMC_Init();
while(error == 1)
{
error = MMC_Init();
}
MMC_Fat_Init();
SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV4, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);
Mmc_Fat_Assign(&filename,0xA0);
while(1)
{
adc_value = ADC_Read(0); //Read Temperature from ADC
adc_value = adc_value*488;
adc_value = adc_value/10;
temp = adc_value/100;
Temperature_Log[0] = 'N';
Temperature_Log[1] = 'E';
Temperature_Log[2] = 'M';
Temperature_Log[3] = 'P';
Temperature_Log[4] = '=';
ones = temp%10;
temp = temp/10;
tens = temp%10;
temp = temp/10;
hundreds = temp%10;
ones = ones|0x30;
tens = tens|0x30;
hundreds = hundreds|0x30;
Temperature_Log[5] = hundreds;
Temperature_Log[6] = tens;
Temperature_Log[7] = ones;
Temperature_Log[8] = '.';
ones = adc_value%10;
adc_value = adc_value/10;
tens = adc_value%10;
ones = ones|0x30;
tens = tens|0x30;
Temperature_Log[9] = tens;
Temperature_Log[10] = ones;
Temperature_Log[11] = ' ';
Temperature_Log[12] = 'C';
Temperature_Log[13] = '\r';
Temperature_Log[14] = '\n';
Mmc_Fat_Append();
Mmc_Fat_Write(Temperature_Log,15);
Delay_ms(300);
}
}
my circuit is true but...
this prog is at the blow. but at the board , i dont have any thing at the MMC.
#define BUFFER_SIZE 15
//Memory Card Chip Select Connection
sfr sbit Mmc_Chip_Select at RB4_bit;
sfr sbit Mmc_Chip_Select_Direction at TRISB4_bit;
//
// End LCD module connections
unsigned char filename[] = "Temp.TXT";
unsigned char error;
unsigned char i;
unsigned int adc_value;
unsigned char Temperature_Log[BUFFER_SIZE];
void main()
{
unsigned char ones,tens,hundreds;
unsigned int temp;
TRISD = 0x00;
Delay_ms(100);
Delay_ms(1000);
ADCON0 = 0b00000001; //A/D Converter Power Up
ADCON1 = 0b00001110; //All Analog Channels
ADCON2 = 0b10111110; //Right Justfied and Slowest Clock for better accuracy
ADC_Init();
SPI1_Init();
SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV64, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);
Delay_us(10);
error = MMC_Init();
while(error == 1)
{
error = MMC_Init();
}
MMC_Fat_Init();
SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV4, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);
Mmc_Fat_Assign(&filename,0xA0);
while(1)
{
adc_value = ADC_Read(0); //Read Temperature from ADC
adc_value = adc_value*488;
adc_value = adc_value/10;
temp = adc_value/100;
Temperature_Log[0] = 'N';
Temperature_Log[1] = 'E';
Temperature_Log[2] = 'M';
Temperature_Log[3] = 'P';
Temperature_Log[4] = '=';
ones = temp%10;
temp = temp/10;
tens = temp%10;
temp = temp/10;
hundreds = temp%10;
ones = ones|0x30;
tens = tens|0x30;
hundreds = hundreds|0x30;
Temperature_Log[5] = hundreds;
Temperature_Log[6] = tens;
Temperature_Log[7] = ones;
Temperature_Log[8] = '.';
ones = adc_value%10;
adc_value = adc_value/10;
tens = adc_value%10;
ones = ones|0x30;
tens = tens|0x30;
Temperature_Log[9] = tens;
Temperature_Log[10] = ones;
Temperature_Log[11] = ' ';
Temperature_Log[12] = 'C';
Temperature_Log[13] = '\r';
Temperature_Log[14] = '\n';
Mmc_Fat_Append();
Mmc_Fat_Write(Temperature_Log,15);
Delay_ms(300);
}
}
my circuit is true but...
- biljana.nedeljkovic
- mikroElektronika team
- Posts: 1043
- Joined: 30 Jun 2015 15:15
Re: data logger
Hello,
Have you tried to debug the code?
Unfortunately, Proteus is not certified software for the mikroE compilers, so we do not suggest to test the code generated in our compilers using the Proteus.
Please attach th project in a zipped file, with all the necessary files.
Kind regards,
Biljana
Have you tried to debug the code?
Unfortunately, Proteus is not certified software for the mikroE compilers, so we do not suggest to test the code generated in our compilers using the Proteus.
Please attach th project in a zipped file, with all the necessary files.
Kind regards,
Biljana