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 support@ccsinfo.com

I need Help pleaaaase:\

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



Joined: 20 May 2014
Posts: 5

View user's profile Send private message

I need Help pleaaaase:\
PostPosted: Tue May 20, 2014 12:50 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue May 20, 2014 1:29 pm     Reply with quote

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

View user's profile Send private message AIM Address

PostPosted: Tue May 20, 2014 4:32 pm     Reply with quote

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


Very Happy Very Happy
Jhon_ST



Joined: 20 May 2014
Posts: 5

View user's profile Send private message

PostPosted: Tue May 20, 2014 5:30 pm     Reply with quote

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: 9202
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue May 20, 2014 5:35 pm     Reply with quote

Are you using real PIC hardware( your homemae PCB ?) or is this a simulation?

jay
Jhon_ST



Joined: 20 May 2014
Posts: 5

View user's profile Send private message

PostPosted: Tue May 20, 2014 5:40 pm     Reply with quote

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


Very Happy Very Happy
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

View user's profile Send private message

PostPosted: Tue May 20, 2014 5:43 pm     Reply with quote

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: 9202
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue May 20, 2014 5:54 pm     Reply with quote

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: 19447

View user's profile Send private message

PostPosted: Wed May 21, 2014 12:51 am     Reply with quote

_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

View user's profile Send private message

PostPosted: Wed May 21, 2014 5:13 am     Reply with quote

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.
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