Cascading two PICs together


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    personnally i would prefer to choose a single PIC with two internal PWM channel and simply poll the sensor. That will just make things really really easy. Internal PWM module run in background. You start HPWM and then you can do anything else without causing any problem to the PWM signal... this isn't the case with software PWM. Even your task is possible with a single PIC without any internal PWM module like the 16F84 or else other... it's just a bit much tricky.

    As they're not much expensive than the 16F84 AND add much fun, PIC16F873, 16F876,18f242,18f252,18f2220,18f2320 and tons of other could be choose.

    As i can't know all PIC in the whole world but just those i use(d), you can also look at the microchip website and do a search for a PIC with 2 internal PWM module ( also called CCP )

    my 2 cents.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  2. #2
    Join Date
    Apr 2006
    Posts
    29


    Did you find this post helpful? Yes | No

    Default

    Thanks for ur precious helo Mister.

    but one reason that is just stopping me from using this sorts of PICs is this that i donot know how to program HPWM in the way in which i want.


    Lets take an example. Im programming in COde Studio rite..

    I know that there is a command in it called HPWM in which u have to specify the channel, the frequency and duty cycle. Rite?

    Now there are two things which i donot know how to make:


    1) there is no "cycles" option given, so how im going to control the revolutions by specifying the cycles as i wass doing it in PWM command.

    2) During my whole operation, i have to stop the motors, run the motors with variable speed and then stop and all that. SO can u plz give me an example of coding with HPWM.


    I know using HPWM is highly effective but i request u to provide me with some code examples so that i can fully understand how to do it. Please use COde studio in ur examples.

    I shall be thankful to u for this act of kindness.

    take carez

    Good Bye!
    LETS MOVE TOWARDS SOMETHING PRACTICAL---

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Post

    interesting point. But let's assume 1KHZ a frequency. a cycle should be 1mS right?

    Code:
    HPWM 1,127,1000
    pause 1 ' one cycle
    pause 1 ' two cylce
    pause 1 ' three cycle
    CCP1CON=0 stop PWM
    rought and nasty example. Now you have to implement your tests during those cycles.. mmm
    Code:
    HPWM 1,127,1000  ' Start Motor1
    Hpwm 2,127,1000  ' Start Motor2
    For Msec=0 to 300
        PauseUS 10  ' 10uSec * 300 = 3mSec = 3 Cycles
        If SensorX=Something then Doplahplah
        If sensorY=Somethingelse then DoAnotherPlahPlah
        next
    But there's some other way to use only High/LOW on specific Motor pins then using Pause/Pauseus (or loop of) to do the same thing and do your test within a loop.

    Code:
    For Msec=0 to ((Cycle*100)*2)
        Toggle Motor1
        Toggle Motor2
        PauseUS 5
        If sensor...
        If sensor...
        next
    This will create a 50% duty cycle 'PWM' of a XCycle

    Should be something to play 'round.

    Now, if it was me, i would use HPWM to generate both signal to the motor, then use 2 sensor to monitor the revolution of the wheel using interrupts or internal counter. It add flexibility and also if a motor is burn or else, you'll be able to know it.
    Last edited by mister_e; - 24th May 2006 at 14:10.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    Join Date
    Apr 2006
    Posts
    29


    Did you find this post helpful? Yes | No

    Default

    That was just tremendous Mister.

    Im very very thankful to u for this.

    Now im getting that this is really possible to control the cycles in HPWM.

    Now i have some important questions prevailing in my mind rite now.Hope u would not mind answering them.

    HPWM 1,127,1000 ' Start Motor1
    Hpwm 2,127,1000 ' Start Motor2
    For Msec=0 to 300
    PauseUS 10 ' 10uSec * 300 = 3mSec = 3 Cycles
    If SensorX=Something then Doplahplah
    If sensorY=Somethingelse then DoAnotherPlahPlah
    next
    About this coding, i want to ask u that no matter that our sensors will be working while the motor is runnig. But if we take the scenario apart from my sensors. and come towards running a third motor in between then what would u say???

    I mean that this is the scenario:

    my both motors are running with HPWM command, let us suppose they are made to make 3 revolutions.


    now in between those three revolutions, if i want to run a 3rd motor (not thru HPWM) so how i would be using this??????

    I mean should i use it like this that

    HPWM 1,127,1000 ' Start Motor1
    Hpwm 2,127,1000 ' Start Motor2
    For Msec=0 to 300
    PauseUS 10 ' 10uSec * 300 = 3mSec = 3 Cycles
    If SensorX=Something then Doplahplah
    If sensorY=Somethingelse then DoAnotherPlahPlah
    next
    CCP1CON=0 'stop PWM 1
    CCP2CON=0 'stop PWM 2

    HPWM 1,127,1000 ' Start Motor1
    Hpwm 2,127,1000 ' Start Motor2
    For Msec=0 to 300
    PauseUS 10 ' 10uSec * 300 = 3mSec = 3 Cycles
    pwm portB.0, 127, 2000 ' run the motor connected on portB.0 with pwm
    next
    CCP1CON=0 'stop PWM 1
    CCP2CON=0 'stop PWM 2


    Now what im saying that dont u think that it is working still sequentially.

    I think im just unable to make u understand thru coding that what im trying to make. Because im still in the process of learning.

    I can present to u a scenario.

    here it is:

    I HAVE PROGRAMMED MY BOTH DRIVE MOTORS TO TAKE THREE REVOLUTIONS. NOW DURING THESE THREE REVOLUTIONS I WANT TO START A THIRD OPERATION LETS SAY STARTING A THIRD MOTOR WITH NORMAL PWM COMMAND. hOW I WILL DO THIS?

    if u will post a code example, i shall be able to understand it quickly and will be greatly thankful to u.

    Thanks in advance!
    LETS MOVE TOWARDS SOMETHING PRACTICAL---

Similar Threads

  1. Communicating between two PICs over DC bus
    By elec_mech in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 7th May 2009, 12:57
  2. Sharing Max232 with two pics?
    By zx81sp in forum Serial
    Replies: 10
    Last Post: - 28th April 2009, 22:22
  3. 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
  4. Programming Pins of PICs?
    By Kamikaze47 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 15th August 2007, 18:59
  5. Dead PICs
    By CocaColaKid in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 15th August 2007, 13:12

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