speed control


Results 1 to 4 of 4

Thread: speed control

Threaded View

  1. #3
    Kees Reedijk's Avatar
    Kees Reedijk Guest


    Did you find this post helpful? Yes | No

    Default

    Thanks Steve
    Today I managed to get it working using the pulsin command. I use a surplus maxon motor with a 32 step optical encoder, pulse length is not a problem. It works really well. I'm using a pic16F628A.
    Here's part of the code I used:
    p.s.for some reason all my indentation disappears when I posted this message, don't know why
    regards, Kees

    motor CON 3
    sensor VAR PORTB.0
    temp VAR WORD
    setspeed VAR BYTE 'speed set by user
    power VAR WORD 'control variable (CV) , PWM dutycycle
    PV VAR WORD 'process value, or actual speed
    error VAR BYTE 'difference between set speed and actual speed
    Kprop VAR BYTE 'constant for proportional feedback control
    Kprop = 4

    run:
    Pot 5,25,setspeed
    PulsIn sensor,0,temp ' measure speed
    IF temp2 > 0 Then ' check if motor is running
    PV = 10000 / temp ' depends on encoder and motor
    IF PV >255 Then PV = 255
    IF setspeed > PV Then
    error = setspeed - PV
    power = power + (error / Kprop) 'new PWM value
    IF power > 255 Then power = 255 'otherwise overflow
    Else
    error = PV - setspeed
    power = power - (error / Kprop) 'new PWM value
    IF power > 255 Then power = 0 'otherwise overflow EndIF
    Else
    power = setspeed ' so a motor without optical sensor
    EndIF ' can also be used
    HPwm motor,power,10000 ' Send a PWM signal at 10kHz, drive motor
    LCDOut $FE,1,"spd ",DEC3 setspeed 'show on screen
    LCDOut $FE,$C0,"pv ", DEC3 PV 'for debugging
    GoTo run
    Last edited by Kees Reedijk; - 31st March 2005 at 20:24.

Similar Threads

  1. brushless speed control
    By jetpr in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 24th December 2009, 15:23
  2. Replies: 14
    Last Post: - 26th September 2007, 05:41
  3. Speed Control (help Idea)
    By jetpr in forum General
    Replies: 0
    Last Post: - 1st November 2005, 01:51
  4. Replies: 9
    Last Post: - 30th August 2005, 06:33
  5. Electronic speed control
    By actionplus in forum Schematics
    Replies: 10
    Last Post: - 21st June 2004, 19:01

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