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

    Thanks Henrik.

    I thought this might be the case but thought it would be better to confirm my thoughts before pulling out what's left of my hair...
    I had considered changing PIC's after one of your previous posts - I have been looking at 16F1825. What do you think of this as an alternative?
    I would value your recommendations on other alternates.

    For the time being I will just eliminate all display functions and "fly blind". I should at least be able to get the PID routine working, something yet to be achieved since introducing the interrupts!

    Cheers
    Barry
    VK2XBP

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


    Did you find this post helpful? Yes | No

    Default Re: incPID Routine - Help Needed

    Why not 16F1827?

    I used it and think is a little monster.

    Ioannis

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,613


    Did you find this post helpful? Yes | No

    Default Re: incPID Routine - Help Needed

    Barry,
    The 16F1825 looks very nice indeed. Seems to be pin compatible with the '684, has 4 times the amount of program memory and 8 times the amount of RAM and it has the USART. It's a bit more complicated than the '684 with all the peripheral multiplexed across the pins but don't let that put you off. I'd say it's a winner.

    The 16F1827 looks nice but it's got less flash and less RAM compared to the 16F1825 (not a problem if you don't need it) and it's not pin compatible with the 16F684 - which the 16F1825 seems to be.

    /Henrik.

  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

    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

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,139


    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

  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

    "#*&@"!!!!!

    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

  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 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

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