View previous topic :: View next topic |
Author |
Message |
ahmed_99
Joined: 12 Jun 2023 Posts: 2
|
Ccs c language question |
Posted: Mon Jun 12, 2023 5:00 pm |
|
|
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);
}
}
} |
|
|
![](templates/subSilver/images/spacer.gif) |
alan
Joined: 12 Nov 2012 Posts: 357 Location: South Africa
|
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19358
|
|
Posted: Tue Jun 13, 2023 12:47 am |
|
|
and (of course), as drawn, the circuit can't actually work....
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). |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9168 Location: Greensville,Ontario
|
|
Posted: Tue Jun 13, 2023 4:49 am |
|
|
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 ? |
|
![](templates/subSilver/images/spacer.gif) |
PrinceNai
Joined: 31 Oct 2016 Posts: 463 Location: Montenegro
|
|
Posted: Tue Jun 13, 2023 5:15 am |
|
|
There is also a small question of what the code should do with this circuit. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19358
|
|
Posted: Wed Jun 14, 2023 6:52 am |
|
|
I'd say kindergarden....
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 ? |
|
|
![](templates/subSilver/images/spacer.gif) |
ahmed_99
Joined: 12 Jun 2023 Posts: 2
|
thnx |
Posted: Sun Jun 18, 2023 9:48 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9168 Location: Greensville,Ontario
|
|
Posted: Sun Jun 18, 2023 10:01 am |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
PrinceNai
Joined: 31 Oct 2016 Posts: 463 Location: Montenegro
|
|
Posted: Sun Jun 18, 2023 11:23 am |
|
|
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:
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. |
|
![](templates/subSilver/images/spacer.gif) |
newguy
Joined: 24 Jun 2004 Posts: 1903
|
|
Posted: Sun Jun 18, 2023 1:45 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
PrinceNai
Joined: 31 Oct 2016 Posts: 463 Location: Montenegro
|
|
Posted: Sun Jun 18, 2023 2:07 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19358
|
|
Posted: Mon Jun 19, 2023 6:20 am |
|
|
We have had them several times here.
The original post here had all the 'symptoms'....
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. |
|
![](templates/subSilver/images/spacer.gif) |
|