incPID Routine - Help Needed


Closed Thread
Results 1 to 40 of 64

Hybrid View

  1. #1
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    172


    Did you find this post helpful? Yes | No

    Default Re: incPID Routine - Help Needed

    Sweet

    Thanks Henrik. I had already placed an order on Element 14 for two pieces as a precautony measure. They were quoting 2-3 days delivery so I hope to have the chips in time for the weekend.

    I will study up on the datasheet and try to sort out what "critical" registers need to be set for my application. This sort of thing is not rely my forte so any hints or recommendations wold be greatly appreciated. It took me ages to work out tht the comparitors needed to be disabled on the '684 to make it work!

    Cheers
    Barry
    VK2XBP

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

    Default Re: incPID Routine - Help Needed

    Barry, as I said I used the 1827 and it was a pain to find all correct settings. I had to enable PWM for two outputs.

    I do not claim that the settings may be complete, and according to your needs you have to change some.

    But is is a good start:

    Code:
    ASM
      __config _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_ON & _MCLRE_ON & _CP_ON & _CPD_OFF & _BOREN_ON & _CLKOUTEN_OFF & _IESO_OFF & _FCMEN_OFF
      __config _CONFIG2, _WRT_OFF & _PLLEN_ON & _LVP_OFF & _STVREN_OFF & _BORV_25
    ENDASM
    
    DEFINE OSC 32                       'Internal RC Oscillator with PLL
     
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 24h
    DEFINE HSER_BAUD 115200
    DEFINE HSER_SPBRG 68
    DEFINE HSER_CLROERR 1
    
    DEFINE ADC_BITS 10 ' Set number of bits in result (8, 10 or 12)
    DEFINE ADC_CLOCK 3 ' Set clock source (rc = 3)
    DEFINE ADC_SAMPLEUS 50 ' Set sampling time in microseconds
    
    OSCCON= %11110000   'PLL enabled, Internal RC-8MHz and PLL x 4
     
    PORTB = 0:PORTA=0
    TRISB = %10110111
    TRISA = %00111111
    
    ADCON0 = %00000001
    ADCON1 = %10100011
    
    ANSELA = %00000001           'ANS0 analog in, all ohters digital I/O
    ANSELB = %00000110           ' PB1,PB2 Analog inputs
    
    APFCON0 = %00000000
    APFCON1 = %00000001
    
    BAUDCON = %00011000          'Bit 4: 1 Inverted data on Tx, 0 Non inverted for direct serial use
    
    CCP1CON = %00111100          'Control of CCPx modules
    CCP2CON = %00111100
    CCP3CON = %00000000
    CCP4CON = %00000000
    
    CM1CON0.7=0
    CM2CON0.7=0
    
    CPSCON0 = 0
    CPSCON1 = 0 
    
    DACCON0 = 0
    
    FVRCON = %10000011
    
    INTCON = %11000000   ' global & peripheral ints enabled
    
    OPTION_REG = %01000111    'Tmr0 from 256 presc and Int Clock
    
    WPUB=%10110001              ' Weak pullup individual settings. See also on Option_Reg
    
    DEFINE CCP1_REG PORTB
    DEFINE CCP1_BIT 3    
    DEFINE CCP2_REG PORTB
    DEFINE CCP2_BIT 6    
    CCPTMRS=0
    
    PR2=255
    
    CCP1CON=$0C
    CCP2CON=$0C
    T2CON=%00000110        'Prescaller / 16, Timer2 ON
    Ioannis

  3. #3
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    172


    Did you find this post helpful? Yes | No

    Default Re: incPID Routine - Help Needed

    "#*&@"!!!!!

    I don't think I could have worked that out in a month of Sundays! - Thanks Ioannis.

    As Henrik stated, the 16F1825 is pin compatible with the '684 that I am currently using but your "head start" on setups will be invaluable in my future endeavours.

    Henrik also asked the question
    Why do you need me for this ? ;-)
    I think the answer to that is now self explanitory...

    Thanks for all your help guys. I am sure I will be back with more questions very soon

    Cheers
    Barry
    VK2XBP

  4. #4
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    172


    Did you find this post helpful? Yes | No

    Default Re: incPID Routine - Help Needed

    Hi All,

    I have had a bit of time to think about where I am going with this project and what my ultimate goal is.
    As stated in my original message

    The end use for this project is to re-power my 9x20 lathe using a treadmill motor (180Vdc 2HP).
    I could spend time tweaking the current system, change the PIC (along with the extended learing curve associated with the new settings) but is it really worth it? At this stage I have proved the concept using the 24Vdc motor; proved it well enough to move forward to the final platform. I have decided to take the plunge and jump straight to the full blown design. Yeah, scary huh!

    The final system will require forward and reverse motor operation. This will be achieved using four IGBT's configured in an H-Bridge arrangement. The IGBT's will be fired by dedicated high-side and low-side gate drivers. All control circuitry will be isolated from the power circuit by opto-isolators (5kV isolation). Forward, reverse and stop (emergency) functions will be performed by switches on digital I/O lines, speed to be set by ADCin via a pot, feedback via photo-interrupter/shaft encoder wheel with an interrupt driven counter (eg. TMR0 and TMR1). As in the prototype system, gain terms will be set via individual pots with ADCin routines. Settings to be displayed on a serial LCD.

    I have searched the Microchip website for an appropriate device and decided on the 18F2431. Quite a powerful device with lots of in-built functions dedicated to motor drive applications.

    I now have lots of new information to try and get my head around. The 18F2431 datasheet is mammoth! I plan to piece the circuit diagram together, lay out a new pcb and then begin to learn the ways of driving the 18F2431. This won't happen overnight - but it will happen

    Thanks to all those who have helped me get to this stage. I am sure I will be calling on you again in the very near future.

    Any recommendations, suggestions or comments on what I am trying to do, before I embark on this adventure, would be greatly appreciated.

    Cheers
    Barry
    VK2XBP

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: incPID Routine - Help Needed

    Hi Barry,
    The 18F2431 is a wonderful device (a bit expensive but there's really no alternative in the 8bit line-up of PICs) and it is the chip I personally use with the PID routine (for info please see with a bit of "bench test demo".

    I haven't used the PCPWM module in full bridge mode but I think there's a post somewhere around here, made by Bruce, with a nice example. Apart from that I know the 2431 pretty well so you won't be alone.

    Keep it up!
    /Henrik.

  6. #6
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    172


    Did you find this post helpful? Yes | No

    Default Re: incPID Routine - Help Needed

    Hi Henrik,

    Nice to know I won't be flying blind with my choice of PIC. I am really getting in WAY above my head with this beast but what the heck - it only set me back $10
    I will send you a copy of the new circuit diagram once I have finished it. Hopefully the pin-out for my needs should be relaitvely straight forward.
    I will also do some forum searches on the 2431 and see what I can find.

    I was very impressed with your Youtube video. Nice bit of motor control. Once I get my 9x20 lathe re-powered I will be looking to do a CNC conversion on my X2 mill. So much to do, so little spare time available...

    Onwards and upwards

    Cheers
    Barry
    VK2XBP

  7. #7
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    172


    Did you find this post helpful? Yes | No

    Default Re: incPID Routine - Help Needed

    Hi Henrik,

    It has been quite some time since I last posted on this subject. A lot of water has flowed under the bridge since then but I am pleased to advise that I have my 1500W H-Bridge power board up and running via PIC18F2431 in PCPWM mode.
    I have forward, reverse and emergency stop functions operating on a test motor (24V 200W scooter motor) and nice clean rotary encoder signals from a home made encoder wheel and IR photo-interrupter - 60 steps per revolution.
    My next stage of the project is to try and implement your incPID routine.
    My question is this: Should I take the approach you outlined above (ie use DT-Ints to set up a timer interrupt at around 100Hz and then feed the pulses to another timer/counter) or would there be a better way of doing it on the 18F2431 using some of the available Motion Feedback modules?

    Your advice and direction would be greatly appreciated.

    Cheers
    Barry
    VK2XBP

Members who have read this thread : 1

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