View previous topic :: View next topic |
Author |
Message |
Jhon_ST
Joined: 20 May 2014 Posts: 5
|
I need Help pleaaaase:\ |
Posted: Tue May 20, 2014 12:50 pm |
|
|
hello everyone I'm new in this forum I need your help my project is to generate a excitation signal for pump_injector
=> This signal is composed of two phase. a call phase (1000 us) fixed.
and maintaining a phase variable
the maintenance phase is made even small pulse (50 us) variation is to add a pulse of 50 us , every time we push a button I want to know how to program the pic for this type of signal
this is the picture of signal thinks a lot [/url] |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Tue May 20, 2014 1:29 pm |
|
|
Hi,
A couple of questions:
1. Are you using the CCS 'C' Compiler, or some other?
2. What PIC are you planning to use?
John |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Tue May 20, 2014 4:32 pm |
|
|
this sure looks like a familiar CLASS PROJECT item i have seen here before.
you need to show some effort and come back when you are stuck.
if already at that point -perhaps you could drop the course.
i don't do homework for free or love or $$
after all what would you learn ?
see
http://www.ccsinfo.com/forum/viewtopic.php?t=51592&highlight=injector
|
|
|
Jhon_ST
Joined: 20 May 2014 Posts: 5
|
|
Posted: Tue May 20, 2014 5:30 pm |
|
|
ezflyr wrote: | Hi,
A couple of questions:
1. Are you using the CCS 'C' Compiler, or some other?
2. What PIC are you planning to use?
John |
hello ezflyr yes i use ccs c i do this example but i used the delay function and i use PIC 16f877a
Fand i use Code: | #include <main.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
void main()
{
int i, old_state0,new_state0,old_state1,new_state1;
int x=5;
while (true){
new_state0 = input(pin_a3); //button 1 var + the signal
new_state1 = input(pin_a4); // button 2 var - the signal
if ((old_state0 != new_state0)|(old_state1 != new_state1)){ // when the button 1 is pressed var +
if (((new_state0 == 1))&&(x<=20)){
x=x+1;
delay_ms(100);
}
else {
if((new_state0 == 0)&(new_state1== 1)&(x>=5)) { //when the button 2 is pressed var -
x=x-1;
delay_ms(100);
}
}
}
if(input(pin_a0)==1){ // signal from a sensor whén =1
delay_us(100);
output_high(pin_D2);
delay_us(1000);
output_low(pin_D2);
delay_us(100);
for(i=0;i<x;i++)
{
output_high(pin_D2);
delay_us(50);
output_low(pin_D2);
delay_us(10);
}
}
}
} | and the result |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9246 Location: Greensville,Ontario
|
|
Posted: Tue May 20, 2014 5:35 pm |
|
|
Are you using real PIC hardware( your homemae PCB ?) or is this a simulation?
jay |
|
|
Jhon_ST
Joined: 20 May 2014 Posts: 5
|
|
Posted: Tue May 20, 2014 5:40 pm |
|
|
asmboy wrote: | this sure looks like a familiar CLASS PROJECT item i have seen here before.
you need to show some effort and come back when you are stuck.
if already at that point -perhaps you could drop the course.
i don't do homework for free or love or $$
after all what would you learn ?
see
http://www.ccsinfo.com/forum/viewtopic.php?t=51592&highlight=injector
| thanks a lot for the advice :p but the problém is how i do the signal with pwm or replace the delay with a timer function you see in the picture that the signale was composed in 2 parts , the second one is variable |
|
|
Jhon_ST
Joined: 20 May 2014 Posts: 5
|
|
Posted: Tue May 20, 2014 5:43 pm |
|
|
temtronic wrote: | Are you using real PIC hardware( your homemae PCB ?) or is this a simulation?
jay | this is a simple simulation with porteus isis just for testing the program |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9246 Location: Greensville,Ontario
|
|
Posted: Tue May 20, 2014 5:54 pm |
|
|
Well your program will NEVER work as Proteus is busted !!!
Please read PIC101.
Almost everyone here( the regulars ) know full well Proteus is full of bugs, errors and faulty DRCs.
As a simple example consider in your schematic...
1) NO power (Vdd or Vss )to PIC
2) _mclr NOT connected correctly
3) NO xtal/caps or other clock source
4) NO pulldown resistors on your two active high switches
5) RA4 is a 'special' pin I believe,requires a pullup resistor to function as an input
ANY of these will NOT allow the PIC to perform....
Do yourself a big, big favour. Buy a current PIC( the 877 is EOL ),breadboard and a handful of parts.The only thing you'll learn wasting time with Proteus is, well, that it's a great waste of time. Life is too short....
jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19552
|
|
Posted: Wed May 21, 2014 12:51 am |
|
|
_Any_ input needs a pull up resistor (RA4 is no different in this). It needs a pull up to function as an output.
Neither input is going to see anything reliably, being either pulled to ground, or floating. And a floating pin in Isis, is a thing that very definitely does _not_ behave like the real world at all.... |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Wed May 21, 2014 5:13 am |
|
|
Learn the difference between the 'logical' operators (&& and ||) and the 'binary' operators (& and |).
In your program you are now mixing both. I think you are lucky and the code does even work correctly but this is by chance and not by good design.
As a simple rule of thumb: logical operators are used for testing, like in an if-statement. Binary operators are almost exclusively used when you want to change a value, like in calculations. |
|
|
|