Author Topic: LC meter coding problem  (Read 4000 times)

0 Members and 1 Guest are viewing this topic.

Offline khatusTopic starter

  • Regular Contributor
  • *
  • Posts: 166
  • Country: gl
LC meter coding problem
« on: August 22, 2018, 04:13:00 pm »
Hello,guys I have a code for LC meter using nokia 3310 display and PIC16F876A microcontroller. Which is written by some other person.The code is packed by winrar. When i extract the .rar file i have noticed that inside the folder there are three .c files and as well as three corresponding .h file. The three header files are
1. "display.h" Which probably displays various values and to adjust screen.
2. "lcd3310.h" which is for activate the lcd module
3. "main.h" the main program.


Now inside the main program the above 3 header file is mentioned.Like below

My question is how does the program works?? and which file should be uploaded in to the micro controller??

This time i wanted to use 0.96″ OLED I2C Display Module.And I have a code for this.

But as per my knowledge the entire code should be inside just one .C file not like 3 mentioned above.
My question is
1. What will be the difference if i use 3 separate code instead of just one main program Which consist of three part ?
2. If i write 3 individual code mentioned above then How can i join them and compiled them in to above??

Please give a detailed advise as i am a programming beginner.
 

Offline JS

  • Frequent Contributor
  • **
  • Posts: 947
  • Country: ar
Re: LC meter coding problem
« Reply #1 on: August 22, 2018, 04:24:22 pm »
Inside the main.c you start including all H files, forget about all other C files, just have them there in the folder and the compiler will do the rest.

JS

PS: you should upload a .bin file to the uC, already compiled, not a C file.
« Last Edit: August 22, 2018, 04:26:02 pm by JS »
If I don't know how it works, I prefer not to turn it on.
 

Offline ogden

  • Super Contributor
  • ***
  • Posts: 3731
  • Country: lv
Re: LC meter coding problem
« Reply #2 on: August 22, 2018, 04:37:07 pm »
Please give a detailed advise as i am a programming beginner.

First advise: don't try to make ANY changes to the original design. Change of the display is not that easy as you say "I have code", definitely not for beginner of your level.

There are MANY "PIC microcontroller for beginners" blogs, videos, books and so on. Code is compiled and loaded into chip similar way disregarding what it does  -   so start with some reading or watching videos.
 

Offline khatusTopic starter

  • Regular Contributor
  • *
  • Posts: 166
  • Country: gl
Re: LC meter coding problem
« Reply #3 on: August 22, 2018, 04:48:56 pm »
I am using mikro c pro software for programming. definitely it requires some changes as the previous program is written in mplab. But till now i have never used multiple c files to to make one big program? I don't know what it's called?is this modular programming?? I wanted to about the programming structure ?? Do anyone have any link about this type of programming???
« Last Edit: August 22, 2018, 04:50:34 pm by khatus »
 

Online kripton2035

  • Super Contributor
  • ***
  • Posts: 2908
  • Country: fr
    • kripton2035 schematics repository
Re: LC meter coding problem
« Reply #4 on: August 22, 2018, 05:03:04 pm »
it will be easier to download the free mplab IDE and compile with it
mplab to mikroc conversion is all except easy ...
 

Offline ogden

  • Super Contributor
  • ***
  • Posts: 3731
  • Country: lv
Re: LC meter coding problem
« Reply #5 on: August 22, 2018, 05:07:48 pm »
But till now i have never used multiple c files to to make one big program? I don't know what it's called?is this modular programming?? I wanted to about the programming structure ?? Do anyone have any link about this type of programming???

It's just programming. Mikro C does support multiple source files per project. Just Read The Funny Manual, check examples, check other projects made with your compiler/IDE. Do some research. Answers to your quite basic question about multiple files are all around the place (internet).

 

Offline khatusTopic starter

  • Regular Contributor
  • *
  • Posts: 166
  • Country: gl
Re: LC meter coding problem
« Reply #6 on: August 23, 2018, 03:27:36 am »
So i can not use multiple source file for writing different part of the code. :-BROKE

Does mplab supports multiple source files??
I got this files from http://projectproto.blogspot.com/2009/09/lc-meter-pic16f876a-n3310lcd.html.

 

Online kripton2035

  • Super Contributor
  • ***
  • Posts: 2908
  • Country: fr
    • kripton2035 schematics repository
Re: LC meter coding problem
« Reply #7 on: August 23, 2018, 06:27:30 am »
use the hex file directly on this page : http://projectproto.blogspot.com/search?q=lc
you don't need to compile the source files (unless you need changes)
but I would start with the already compiled and ready for you hex file.
 
The following users thanked this post: ogden

Online MarkF

  • Super Contributor
  • ***
  • Posts: 3302
  • Country: us
Re: LC meter coding problem
« Reply #8 on: August 23, 2018, 08:20:19 am »
So i can not use multiple source file for writing different part of the code. :-BROKE

Does mplab supports multiple source files??
I got this files from http://projectproto.blogspot.com/2009/09/lc-meter-pic16f876a-n3310lcd.html.

Sorry, I have never used Mikro C.
But I would be surprised if you were able to find a compiler that doesn't support multiple source files.  Even assemblers I used in the 80's supported multiple source files.

I personally use MPLAB X and the XC8 compiler for all my PIC software development.  And all of my projects have multiple source files.
You can just download the two from Microchip.  Install MPLAB X before XC8.  Then create a new PIC16F876A project and add all your source files (*.c and *.h) to it.  At a minimum, you will then need a PicKit 3 to write the .hex file from the "dist" directory within the project to your PIC.

In the XC8 compiler all the PIC specific header files get added by including the "xc.h" file in your main.c or the main.h file since you have one.
If you don't have it at the top of your main.c or main.h file, add a #include <xc.h> statement before all the other standard header include statements.


Here's an example screenshot of a similar MPLAB project I did with a small OLED display.  Note the included files in the left panel.

   
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 14135
Re: LC meter coding problem
« Reply #9 on: August 23, 2018, 09:18:23 am »
The source is written for HiTech C compiler for PIC10/12/16 v9.63.   If you use HiTech C v9.83 (the final one) or any Microchip XC8 v1.xx version, you will have to define _LEGACY_HEADERS globally in the project options. XC8 v2.x is probably too new . . . .

As the project is set up for MPLAB 8, and MPLAB X is notoriously bloated, *UNLESS* you want to move away from the MikroElektronika PIC toolchains to the current Microchip MPLAB X + XC ones, I see no benefit in downloading MPLAB X. 

Once you have a successful build, if you don't have a MPLAB compatible programmer, you can export the HEX file from MPLAB 8 and program it using MikroElektronika's standalone programming software.

-----------------------------------------------------------

As usual, the Microchip website is somewhat borked and legacy downloads are hard to reach, so here are some links to them:

See https://www.microchip.com/forums/FindPost/829198 for how to get old HiTech compilers.  Install it in FREE mode as it can no longer be licenced.


The final MPLAB 8 release (before MPLAB X) is v8.92:  http://ww1.microchip.com/downloads/en/DeviceDoc/MPLAB_IDE_8_92.zip
N.B. there's a patch to install XC8 v1.33 and newer versions for MPLAB v8.92. See http://www.microchip.com/forums/FindPost/874217

-----------------------------------------------------------
So i can not use multiple source file for writing different part of the code. :-BROKE

Does mplab supports multiple source files??
Sorry, I have never used Mikro C.
But I would be surprised if you were able to find a compiler that doesn't support multiple source files.  Even assemblers I used in the 80's supported multiple source files.
That would be CCS C.  It was highly non-standard, definitely *NOT* ANSI C compliant and IIRC you had to #include all source files in a single C file as it didn't use a linker.
« Last Edit: August 23, 2018, 09:24:09 am by Ian.M »
 

Offline khatusTopic starter

  • Regular Contributor
  • *
  • Posts: 166
  • Country: gl
Re: LC meter coding problem
« Reply #10 on: August 23, 2018, 01:30:52 pm »
Is there will be any difference if i didn't use modular programming??
 

Offline ogden

  • Super Contributor
  • ***
  • Posts: 3731
  • Country: lv
Re: LC meter coding problem
« Reply #11 on: August 23, 2018, 06:36:02 pm »
Is there will be any difference if i didn't use modular programming??

No. It's the same as to put different chapters of the book into different files - content does not change. You have smaller manageable files in case you want to edit them, especially if more than one people is working on various chapters. Usually bad things happen (some changes become lost) if two people edit same file at the same time. You see??
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->