connect two pics


Closed Thread
Results 1 to 29 of 29

Hybrid View

  1. #1
    Join Date
    Mar 2006
    Location
    China
    Posts
    266


    Did you find this post helpful? Yes | No

    Default so..

    You say you have 2 pics, one small and one big and then you use the same code in both. In the small pic everything is dandy but with the 877A it is not working properly.

    the code.... I agree.. what can go wrong... so the answer is probably not in the lines you posted.

    What FQ do your run the pics on, and where do you get this one from?
    Maybe DEFINE OSC XX in the beginning could help ....

    Configurations bits... a long story.. and the bigger the pic.... the longer the story.. the best way to set configuration bits is by adding them to the code. How this is done depends if you use MPASM or not. Search the forum and add these bits into the top of your program... These have a significant effect on the pics behaviour.

    OSC XT HS RC LP
    Watchdog on off
    Brown out or not
    etc etc.. add all config bits you have for the device in the code

    all these you can find in the datasheet....


    And you still didnt answer how you power the pic and if you have caps close to the power pins.



    /me
    Last edited by Jumper; - 19th September 2008 at 16:57.

  2. #2
    Join Date
    Mar 2006
    Location
    China
    Posts
    266


    Did you find this post helpful? Yes | No

    Default Good

    OK,

    more questions... your 9V battery. What kind is that? Is that the normal small flat one or something with some real juice in?

    How many mA does the motor take in start up current?

    Nothing wrong with PORTB, this is a different problem.. but please power the L293D separetly. Add config bits to make sure at least brown out off and watchdog off.

    /me
    Last edited by Jumper; - 19th September 2008 at 17:03.

  3. #3
    Join Date
    Jun 2006
    Posts
    14


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Jumper View Post
    You say you have 2 pics, one small and one big and then you use the same code in both. In the small pic everything is dandy but with the 877A it is not working properly.

    the code.... I agree.. what can go wrong... so the answer is probably not in the lines you posted.

    What FQ do your run the pics on, and where do you get this one from?
    Maybe DEFINE OSC XX in the beginning could help ....

    Configurations bits... a long story.. and the bigger the pic.... the longer the story.. the best way to set configuration bits is by adding them to the code. How this is done depends if you use MPASM or not. Search the forum and add these bits into the top of your program... These have a significant effect on the pics behaviour.

    OSC XT HS RC LP
    Watchdog on off
    Brown out or not
    etc etc.. add all config bits you have for the device in the code

    all these you can find in the datasheet....


    And you still didnt answer how you power the pic and if you have caps close to the power pins.



    /me
    See the schematic attachment about how I power the PIC. I will try those configurations bits! Thanks!

  4. #4
    Join Date
    Mar 2006
    Location
    China
    Posts
    266


    Did you find this post helpful? Yes | No

    Default Yepp

    Try to add caps (2* 0.1 uF) close to the power pins on the pic (one on each side).

    and was it a regular 9V battery or something more powerful?

    /me
    Last edited by Jumper; - 19th September 2008 at 17:34.

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Oh ya...
    If that's a regular ol' 9v battery (little flat one like Jumper said), that isn't going to work well at all, at least not for very long.
    Dropping the operating frequency of the PIC might help.
    And of course, as Jumper said, put extra cap's everywhere.
    Your PIC16F877A is probably brown-out resetting every time you start moving a motor (or maybe one motor or both or whatever). The smaller PICs might be a bit less sensitive to power dropoffs, or maybe they're LF versions whereas the '877A isn't an LF version.
    Who knows...
    One thing I do know is that the schematic shown above could use a bit of redesign to make it more reliable.

  6. #6
    Join Date
    Jun 2006
    Posts
    14


    Did you find this post helpful? Yes | No

    Default

    Help guys Iam starting loose hair for this project

    I think the problem must be the normal 9V battery, what I can use as alternative? Will be an alcaline 9V battery or something else be better choice. I notice also in LCD screen somehow the 2 power sources (9V battery and the 4x1.5V AA batteries are interfacing) maybe is the L293D drive chip to blame and try another one?

    I also replace resonator 4mhz with crystal 4mhz with 33pf capacitors so can be more accurate. I also defined osc 4 in program. I also use pbp247 compiler and mpasmwin520 assempler(this is from Compile and Program Options) and I use an usb programmer I bought on ebay with the following settings when I program the chip the watchdog is disabled (see the first attachment).

    I connected l293d chip successful with RC ports so to have only one chip, but my problem is that after some loops the circuit stop working!

    See the complete schematic in the second attachment. Please help me to do it more reliable!

    The code of the program is:


    DEFINE OSC 4
    DEFINE LCD_DREG PORTB ' LCD Data bits on PORTB
    DEFINE LCD_DBIT 0 ' PORTB starting address
    DEFINE LCD_RSREG PORTB ' LCD RS bit on PORTB
    DEFINE LCD_RSBIT 5 ' LCD RS bit address
    DEFINE LCD_EREG PORTB ' LCD E bit on PORTB
    DEFINE LCD_EBIT 4 ' LCD E bit address
    DEFINE LCD_BITS 4 ' LCD in 4-bit mode
    DEFINE LCD_LINES 2 ' LCD has 2 rows
    '
    ' Define A/D converter parameters
    '
    DEFINE ADC_BITS 8 ' A/D number of bits
    DEFINE ADC_CLOCK 3 ' Use A/D internal RC clock
    DEFINE ADC_SAMPLEUS 50 ' Set sampling time in us
    Res Var Word ' A/D converter result
    Volts1 Var Word ' First part of result in mV
    Volts2 Var Word ' Second part of result in mV
    '
    ' Constants
    '
    Conv1 Con 19 ' 5000/256 = 19.53, this is the decimal part
    Conv2 Con 53 ' This is the fractional part
    TRISA = 1 ' RA0 (AN0) is input
    TRISB = 0 ' PORTB connected with lcd is output
    TRISC = 0 ' PORTC connected with l293d is output
    PORTC.0 = 1 ' l293d enable1 high
    PORTC.3 = 1 ' l293d enable2 high
    PAUSE 1500 ' Wait 1.5sec for LCD to initialize
    '
    ' Initialize the A/D converter
    '
    ADCON1 = 0 ' Make AN0 to AN4 as analog inputs,
    ' make reference voltage = VDD
    ADCON0 = %11000001 ' A/D clock is internal RC, select channel AN0
    ' Turn on A/D converter
    LCDOUT $FE, 1 ' Clear LCD
    AGAIN:
    '
    ' Start A/D conversion
    '
    ADCIN 0, Res ' Read Channel 0 data
    Volts1 = Res * Conv1 ' Multiply by 19
    Volts2 = Res * Conv2 ' Multiply by 53
    Volts2 = Volts2 / 100
    Volts1 = Volts1 + Volts2 ' Result in mV
    IF Volts1 > 1800 THEN DOKIM
    LCDOUT $FE,2,"V = ",DEC4 Volts1 ' Display result
    PAUSE 1000 ' Wait 1 second
    GOTO AGAIN ' Repeat
    DOKIM: ' move one dc motor for testing
    PORTC.1 = 1
    PORTC.2 = 0
    PAUSE 3000
    PORTC.1 = 0
    PORTC.2 = 1
    PAUSE 3000
    PORTC.1 = 0
    PORTC.2 = 0
    GOTO AGAIN
    END
    Attached Images Attached Images   

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    -Get rid of that 9v battery and make up another battery pack. Get a bunch of NiMH AA's and make another battery pack, anything but that stupid 9v battery.

    -Put decoupling cap's across Vdd and Vss on the PIC.

    -Turn off the brown out detect on the PIC in the config fuse options.

    -4Mhz osc - accuracy isn't going to help here. As long as it runs, it should be good.

    -USB programmer from eBay - spend the money and buy a PICKIT2. You'll be happier in the long run.

    -One power supply for the PIC, one power supply for the motors - good idea.... Separate grounds, not a good idea. Connect the grounds together.

    -Put low value inline resistors on the lines between the PIC and the L293D.

  8. #8
    Join Date
    Jun 2006
    Posts
    14


    Did you find this post helpful? Yes | No

    Thumbs up

    Thank you skimask for your suggestions. I will try them! Thanx again!

Similar Threads

  1. Free Project - 245 LED Display
    By T.Jackson in forum Code Examples
    Replies: 221
    Last Post: - 16th August 2009, 04:59
  2. Retrieving infos from multiple PICs on a bus/chain
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 15th October 2007, 04:42
  3. connect 2 PICs
    By drama in forum mel PIC BASIC
    Replies: 1
    Last Post: - 4th October 2007, 16:55
  4. Multiple PIC's with 1 crystal
    By puma in forum Schematics
    Replies: 11
    Last Post: - 20th March 2007, 17:02
  5. Replies: 5
    Last Post: - 20th August 2006, 23:09

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts