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 CCS Technical Support

Ccs c language question

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



Joined: 12 Jun 2023
Posts: 2

View user's profile Send private message

Ccs c language question
PostPosted: Mon Jun 12, 2023 5:00 pm     Reply with quote

Hey guys, please, I need the code for this circuit in c language, because I got a lot of trouble writing it
Knowing that I need it in complete urgency for a graduation project


I need to modify it to add temperature control buttons only


Code:
#include <16F84A.h>
#fuses XT
#use delay(clock=4000000)

#define LCD_ENABLE_PIN  PIN_B3                                       
#define LCD_RS_PIN      PIN_B1                                       
#define LCD_RW_PIN      PIN_B2                                       
#define LCD_DATA4       PIN_B4                                       
#define LCD_DATA5       PIN_B5                                     
#define LCD_DATA6       PIN_B6                                     
#define LCD_DATA7       PIN_B7

#include <lcd.c>
#include <touch.c>
#include <string.h>
#include <stdlib.h>

#define RELAY PIN_A0
#define TEMP 30
void main() {
   byte buffer[2];
   lcd_init();
   set_tris_a(0x00);
   output_a(0x00);
 
   while (TRUE) {
     if(touch_present()) {
        touch_write_byte(0xCC);
        touch_write_byte (0x44);
        output_high(TOUCH_PIN);
        delay_ms(2000);

        touch_present();
        touch_write_byte(0xCC);
        touch_write_byte (0xBE);
        buffer[0] = touch_read_byte();
        buffer[1] = touch_read_byte();
       
        buffer[0]=(buffer[1]<<5)|(buffer[0]>>3);
       
        lcd_gotoxy(1,1);
        LCD_PUTC("TEMPERATURE:");
       
        lcd_gotoxy(1,2);
        printf(LCD_PUTC,"%c",(buffer[1]&0b11111000)?'-':' ');
        if(buffer[1]&0b11111000) buffer[0]=-buffer[0];
        lcd_gotoxy(2,2);
        printf(LCD_PUTC,"%d.%c C",buffer[0]/2,((buffer[0])&0x01)?'5':'0');
        delay_ms (500);
        lcd_putc("          ");
       
        if((buffer[0]/2)>TEMP) output_high(RELAY);
        else output_low(RELAY);
     }
  }
}
alan



Joined: 12 Nov 2012
Posts: 357
Location: South Africa

View user's profile Send private message

PostPosted: Mon Jun 12, 2023 11:27 pm     Reply with quote

Nobody here are going to do your project for you.
Show code you wrote and we will try and help you fix problems.

DON'T put code from a random website here and expect help.
https://aki-technical.blogspot.com/2020/05/a-temperature-controlled-lamp-by.html
Ttelmah



Joined: 11 Mar 2010
Posts: 19510

View user's profile Send private message

PostPosted: Tue Jun 13, 2023 12:47 am     Reply with quote

and (of course), as drawn, the circuit can't actually work.... Surprised
No supply suppression (the original has an electrolytic, but no small
ceramics - both are needed on something switching a relay).
No crystal!.... Duh!.
The code is written to use touch pads, not normal keys, so the first
thing to do is get rid of all the touch handling, and add a basic key scanner
(in the examples, or the code forum).
temtronic



Joined: 01 Jul 2010
Posts: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Jun 13, 2023 4:49 am     Reply with quote

aside from 4 versions of 'ground' and no power supply, what else is wrong ?

oh wait, it's a Proteus schematic....
sigh....

he's got FOUR unlabeled 'buttons' he could use, if marked warmer, cooler, enable, off.

there ,project is done.

Seriously, though ,I have to wonder what level of education this is for ?
high school, college, PhD in EE ?
PrinceNai



Joined: 31 Oct 2016
Posts: 479
Location: Montenegro

View user's profile Send private message

PostPosted: Tue Jun 13, 2023 5:15 am     Reply with quote

There is also a small question of what the code should do with this circuit.
Ttelmah



Joined: 11 Mar 2010
Posts: 19510

View user's profile Send private message

PostPosted: Wed Jun 14, 2023 6:52 am     Reply with quote

I'd say kindergarden.... Very Happy
As PrinceNai points out basic first steps needed.


temtronic wrote:
aside from 4 versions of 'ground' and no power supply, what else is wrong ?

oh wait, it's a Proteus schematic....
sigh....

he's got FOUR unlabeled 'buttons' he could use, if marked warmer, cooler, enable, off.

there ,project is done.

Seriously, though ,I have to wonder what level of education this is for ?
high school, college, PhD in EE ?
ahmed_99



Joined: 12 Jun 2023
Posts: 2

View user's profile Send private message

thnx
PostPosted: Sun Jun 18, 2023 9:48 am     Reply with quote

Honestly, I submitted a question on this forum, but I was surprised by the amount of harsh and sarcastic criticism
I want to remind you that man is not and will not be born educated, but acquires it through experience
Thanks to everyone who bullied me for being a vulgar
temtronic



Joined: 01 Jul 2010
Posts: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Jun 18, 2023 10:01 am     Reply with quote

well, WRT to my reply...

#1 Proteus is well known to have MAJOR faults and problems(see PIC101 ) and over the YEARS of seeing schematics posted here, NONE of them will actually work in the 'real world.

#2 re: schooling. As I said , I am curious as to what level you're in. In high school I was taught to have a power switch, and for it to be in the 'off' state. In college(Honours Avionics graduate ) , I was taught to be accurate and consistent when drawing schematics ( NO E-cad back then.....)
I understand different countries have different standards of 'course content', but it'd be nice to know what 'level' posters are in the school system.
PrinceNai



Joined: 31 Oct 2016
Posts: 479
Location: Montenegro

View user's profile Send private message

PostPosted: Sun Jun 18, 2023 11:23 am     Reply with quote

Technically you haven't asked any question, if you look at the original post. Since you haven't tell us at all what you want from the circuit and what the code should do, the code snippet below might do exactly what you need, just put it in main:

Code:

while(TRUE);


No sarcasm meant, I assure you. Give the people here something to work with and you'll find out that you'll get nothing but help.

An it is true, like it or not, there is no way the circuit as drawn can work, regardless of the code. Proteus will forgive the lack of capacitors, maybe even no crystal. But if you build education and experience with electronics on such examples, I'm afraid it won't be of any use in the real world.

Regardless of the country and the required level, I simply can not believe that some teacher requested from you to do a graduation project without at least the minimum amount of lectures and guidance on the subject beforehand.
newguy



Joined: 24 Jun 2004
Posts: 1907

View user's profile Send private message

PostPosted: Sun Jun 18, 2023 1:45 pm     Reply with quote

PrinceNai wrote:
Regardless of the country and the required level, I simply can not believe that some teacher requested from you to do a graduation project without at least the minimum amount of lectures and guidance on the subject beforehand.


I believe it. I spent many years in academia as both a student and also as an instructor. Think back to the worst instructor you've ever had.

Now imagine a country or culture where that person enjoys an almost god-like status because they're an instructor/professor. They are perfect (just ask them). Now imagine a confused student who goes to them for help.

Why is this person coming to me for clarification when my lectures are perfect? They must be trying to make me, a god, look bad. I'll make them regret trying to make me look bad!

^ That plays out far more often than you think.
PrinceNai



Joined: 31 Oct 2016
Posts: 479
Location: Montenegro

View user's profile Send private message

PostPosted: Sun Jun 18, 2023 2:07 pm     Reply with quote

Quote:
That plays out far more often than you think.


Never had such an experience, not at school, anyway. But, as I said, with a few explanations and thought-out questions the OP will surely get all the help possible here.
Ttelmah



Joined: 11 Mar 2010
Posts: 19510

View user's profile Send private message

PostPosted: Mon Jun 19, 2023 6:20 am     Reply with quote

We have had them several times here.

The original post here had all the 'symptoms'.... Sad

No detail of what was wanted really.
No attempt to actually do the work himself.
Instead a badly modified version of an online project, and nothing much
else.
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