All About Circuits Forum  

Go Back   All About Circuits Forum > Software, Microcomputing, and Communications Forums > Embedded Systems and Microcontrollers

Notices

Embedded Systems and Microcontrollers Discussion forum for projects and working with embedded systems and microcontrollers (FPGAs, PICs, AVRs). Get help with hardware issues and embedded programming.

Reply   Post New Thread
 
Thread Tools Display Modes
  #1  
Old 03-10-2010, 04:56 PM
Nara Shikamaru's Avatar
Nara Shikamaru Nara Shikamaru is offline
Member
 
Join Date: Nov 2007
Location: San Cristobal, Venezuela
Posts: 92
Default PING))) #28015 with PIC18F2550

Hey Everybody!

Im doing a circuit that must measure constantly the Level inside a Tank, i.ve done the circuit and it works! but after a couple of minutes the Sensor and PIC stops working and just turning it off and on again makes it work for another couple more minutes....i dont know if its the code or what, but how can i fix it!!....

the circuit flow sequence is as follows:

1) System iniciated

2) Start the PING))) #28015

3) If the level in Tank is = to low level, Turn on the Pump

4) If the level in Tank is < than Low Level, Turn on the pump, turn on the Alarm

5) If the Level in tank is = to High Level, Turn off the Pump

6) If the level in tank is > of high level, turn off the pump, turn on the Alarm

That must be Cyclic!, and constantly show the Level in an LCD....


Here i`ll put you the code:

Code:
#include <18F2550.h>
#device adc=10
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN
#use delay(clock=48000000)

 #define USB_CON_SENSE_PIN PIN_B2

 #include <usb_cdc.h>
 
 
#define LCD_RS PIN_C0 //CONTROL
#define LCD_RW PIN_C1
#define LCD_E PIN_C2

#define LCD_DB4 PIN_A0 //DATOS
#define LCD_DB5 PIN_A1
#define LCD_DB6 PIN_A2
#define LCD_DB7 PIN_A3

#include <flex_lcd.h> //LIBRERIA LCD

float ticks,distancia,nivel_tanque;
void main() {
 //  BYTE i, j, address, value;

   setup_adc_ports(NO_ANALOGS);

   usb_cdc_init();
   usb_init();
   lcd_init();  
   
//      while(!usb_cdc_connected()) {}

   do {

      {
       ticks=0;
            SET_TRIS_b(0x00);
            output_low(PIN_B0);
            output_high(PIN_B0);
            delay_us(5);
            output_low(PIN_B0);
            delay_us(750);
            SET_TRIS_b(0x01);
            while(input(PIN_B0))  //se genera el pulso de disparo
             {                       // del sensor de distancia
               ticks=ticks+1;
               delay_us(10);
             } 
             distancia=ticks*300/18500;
             nivel_tanque=distancia*2643/100;
           //  distancia=distancia*255/3000;  //la distancia queda en milimetros
              delay_ms(100);
      printf(lcd_putc,"\f NIVEL \n #:%f n:%f", distancia,nivel_tanque);
      }

      usb_task();
      
      if (usb_enumerated()) 
      {
      printf(usb_cdc_putc,"\r NIVEL #:%f, nivel:%f", distancia,nivel_tanque);
      }
            
      } while (TRUE);
}
im using CCS Compiler and PROTEUS for simulation, ill upload the schematic in the ISIS PROTEUS file and a image if you use another simulator, the ultrasonic sensor im simulating it with a Function gen!!

I Hope you can help me!....Remember!.....i dont understand why it "hangs up" i call the people at parallax and they told me the Circuit can work continuosly!!.....
Attached Files
File Type: doc Circuit.doc (88.5 KB, 0 views)
Reply With Quote
Reply   Post New Thread

Bookmarks

Tags
,

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help 4. Using the USB in a PIC18F2550 KansaiRobot Embedded Systems and Microcontrollers 3 02-26-2010 09:53 AM
PIC18F2550 LED almamater The Projects Forum 1 04-26-2009 12:30 PM
LED Ping Pong without microcontrollers swapnadr The Projects Forum 28 01-13-2009 01:04 PM
PIC18F2550 programmer malalation Embedded Systems and Microcontrollers 5 05-20-2008 07:35 PM


All times are GMT. The time now is 10:30 PM.


User-posted content, unless source quoted, is licensed under a Creative Commons Public Domain License. Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.