Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] sample code for pic 16f

Status
Not open for further replies.

kumar_sunil112

Newbie level 2
Newbie level 2
Joined
Oct 5, 2013
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
21
i made a temperature controller on pic 18f using assembly. but nw i wanna switch to pic 16f.but pic 16f have less instruction so need to write in c. so i need a sample code in c for pic 16f72 to start writing.
plz help
 

Hi,

Also post your 18F assembly code, its probably easier to convert it to 16F assembly than re-writing it all in C, unless you are experienced with C ?

Wonder why you are going for to such an old type of 16F chip that only has an 8 bit ADC, 10 bit on the 18F, no EEprom and no on board oscillator ?
 

i am selling this temp controller regularly & pic 16f much cheaper than 18f.price is issue.thats why i wanna switch......
 

Post the asm code of 18F temperature controller so that it can be modified to 16f. Post the circuit before asking help. 8 bit adc resolution will be very less. 8 bit adc range is 0 to 255 and 10 bit adc is 0 to 1023.

If your temperature range is 0 to 150 deg C then

150/255 = 0.5882352941176471 per step

150/1023 = 0.1466275659824047 per step
 

Hi,

Ok, if the 16F72 is so much cheaper but does its 8bit adc affect you basic adc computations ?

Also do you not use any EEprom on the 18F to store values like Set Temp and Min/Max Temps / Alarm ?

What about the extra cost of a crystal and caps you will have to use on the F72 where you used the internal osc of the 18F ?

Whats the price of the more compatible 10bit adc + eeprom 16F876/A like in your area ?

If you don't want to post your assembly code in the open forum you could PM it.
I've written various temp controllers in assembly using ntc, lm35, DHT11 and DS18B20 sensors for both 16F and 18F chips.
 

Hi,

I've written various temp controllers in assembly using ntc, lm35, DHT11 and DS18B20 sensors for both 16F and 18F chips.

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

I have just started with PIC's. Will you share your temp controller code with us ?
My first test is as always a blinking LED, from there I have plans for a remote controlled weather station,via Web and a
cheap RF link ++

regards,
Nils
 

Couple of question -
You said it is temperature controller -
1) is this is on/off type of controller or there is any other algorithm like PI or PID kind of staff that you are using?
2) what is the temperature sensor chip that you are using( from your post only thing that I came to know is you have resistance of 10k at 25 degree)?
3) dose the sensor have linear response or it is non-linear?

One need to know these aspect to translate your design successfully in other chip. As Flash and RAM both are having different sizes in both 16f and 18f family of chip based on chip that you selected.

Good luck
 

Hello,

Thanks for your valuable reply. You helped me a lot !
 

Hi,

I've written various temp controllers in assembly using ntc, lm35, DHT11 and DS18B20 sensors for both 16F and 18F chips.

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

I have just started with PIC's. Will you share your temp controller code with us ?
My first test is as always a blinking LED, from there I have plans for a remote controlled weather station,via Web and a
cheap RF link ++

regards,
Nils


Hi,

Which chip are you using ? assume you are programming in assembly ?

Am happy to share code snippets to help folk get going, though only provide the .hex code for full projects; example -**broken link removed**


Which sensor are you thinking of using, the DS18B20 is a popular choice for weather stations, though its a difficult one to program from scratch; much better using some existing proven code.

Have a look at this site, it give some good code examples of a ds18b20 sensor and clock. https://bogdi.ro/electronics/digital%20clock/

Suggest you work on one single function / module at a time rather than try all the functions of a weather station in one go.
 

Hi,
Thanks for your reply. Good advice starting with on sensor before moving on to the next.
I wrote a long message to you and suddenly it was gone..
We wil use assembler and some C. Chips are 16f688, 877, 887 , and some others with built in a/d converters.

regards,
Nils
 

Hi,
Thanks for your reply. Good advice starting with on sensor before moving on to the next.
I wrote a long message to you and suddenly it was gone..
We wil use assembler and some C. Chips are 16f688, 877, 887 , and some others with built in a/d converters.

regards,
Nils

Hi,

Yes, its quiet easy to loose your text, tend to manually 'copy' it if I know its a long reply.

Would stick with the more modern 688 and 887 chips with their on board oscillators.

While you can mix Assembly into C, so I am told, think you will be better sticking to one language while you are learning.
These sites might help.
**broken link removed**
http://www.electro-tech-online.com/articles/nigel-goodwins-tutorials-in-c.467/
http://www.winpicprog.co.uk/pic_tutorial.htm
http://www.amqrp.org/elmer160/lessons/
http://www.epemag.wimborne.co.uk/resources.htm
http://www.mikroe.com/chapters/view/5/chapter-4-timers/
 
  • Like
Reactions: nilses

    nilses

    Points: 2
    Helpful Answer Positive Rating
Hi ,
Thank you very much for good advice and many links with useful information.
I have just moved from AVR to PIC's because i want to get more knowledge personally.
In my sparetime I do some volountary work teaching young kids in electronics and programming.
Building Velleman kits , soldering, a little programming in assembler and C.

regards,

Nils
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top