Newbie remote control question?


Closed Thread
Results 1 to 5 of 5

Hybrid View

  1. #1
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Clodoaldo, you cannot transfer the pulsin value to the duty cycle without some math manipulation.

    Let's assume you want keep the velocity constant.

    You measure the pulse width using the pulsin function (use a word variable)

    You will have your motor running with duty cycle = 50%

    Now the millisecs returned in the word variable is the speed of your motor and you have to decide which value rappresent the speed that you want to keep put this value into the variable Your_Speed.

    Once you have done that, then the math could be as follow:

    Code:
    Read_Speed  Var Word
    Your_Speed  Var Word
    Deviation      Var Word
    Duty            var Byte
    Error_Flag       Var Bit
    
    Duty = 50
    
    Your_Speed = ?????
    
    Calculation:
    
    Deviation = Read_Speed * 100 / Your_speed
    
    Error_Flag = 0
    
    If Deviation > 100 then Duty=Duty-(Deviation-100)
    
    If Deviation <100 the Duty = Duty +(100-Deviation)
    
    If Duty > 100 the Error_Flag = 1
    
    Return
    Check Error_Flag before passing the new duty value to the PWM comand.
    A Pause value, to give the motor the time to gain the new speed is recommended.


    Al.
    Last edited by aratti; - 14th July 2009 at 08:19.
    All progress began with an idea

  2. #2
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Let's assume you want to controll the velocity and you have no feedback from the motor.

    You will give the word variable Max_Speed an arbitrary value that you will never exceed (this will reppresent duty = 100%).

    You measure the pulse width using the pulsin function (using a word variable)

    Once you have done that, then the math could be as follow:

    Code:
    Read_Speed  Var Word ' value that you will send via RC
    Max_Speed  Var Word  ' arbitrary value = to 100 Duty cycle
    Duty            var Byte
    Error_Flag       Var Bit
    
    
    
    Max_Speed = ????? ' you enter here your arbitrary value
    
    Calculation:
    
    Error_Flag = 0
    
    Duty = (Read_Speed * 100 / Max_speed) 
    
    IF Duty > 100 Then Duty = 100 : Error_Flag = 1
    
    Return
    If Error_Flag = 1 then you have sent a value greater than the permissible one.

    You can add a line saying that if Read_Speed is minor then X duty = 0

    (If Read_Speed < xxx then Duty = 0) in case Read_Speed could never be zero.

    Remember that HPWM duty cycle 100% = 255.

    Al.
    Last edited by aratti; - 14th July 2009 at 10:16.
    All progress began with an idea

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,172


    Did you find this post helpful? Yes | No

    Default

    If you loose your RF signal, what should your motor do?

    Please note that frequency in HPWM is a word sized variable, so it must in Pulsin also.

    Ioannis

  4. #4
    Join Date
    Jul 2009
    Posts
    4


    Did you find this post helpful? Yes | No

    Lightbulb New ideas...

    See the speed control does NOT return automatically. It is a simple equipment so if I fail to reset the speed the engine should not stop...

    Now I did NOT know that the variable for (HPWM) is (WORD) ... I try to use the examples of ARATTI and change the code to new test...

    For now thanks for the support. Once back with results.

Similar Threads

  1. Remote PIC input question
    By Adrian in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 1st September 2007, 16:44
  2. IR Remote Control Issues
    By Kamikaze47 in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 28th August 2007, 15:12
  3. No one-way approach to learning ir remote control frequencies
    By selbstdual in forum mel PIC BASIC Pro
    Replies: 41
    Last Post: - 22nd June 2007, 14:26
  4. IR Remote Control
    By mychangl in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 25th March 2007, 08:01
  5. Remote control
    By Radiance in forum General
    Replies: 2
    Last Post: - 6th August 2003, 16:13

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