Ds1820 -> pid -> pwm


Closed Thread
Results 1 to 24 of 24

Hybrid View

  1. #1
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by gadelhas View Post
    @malc-c

    I Allready have that code, however this code don't permite changing the variables with hiperterminal like you said, can you give me the one that does?
    I'll configure the EasyPIC5 board for use with a 16F877A and 20Mhz crystal and try the code, probably have to be tomorrow afternoon now as I won't be home from work until late. But I'm sure it does allow you to change and set the values of PID etc as it contains the code to do so (snippet attached)

    Code:
    ;----[handle incoming serial Terminal data]---------------------------------
    Term_RX:
        HSERIN [Char]
        SELECT CASE Char
            CASE "R","r"   ' Refresh
                GOSUB TerminalMenu
            CASE "S","s"   ' Enter Setpoint
                X=1 : Y=22 : GOSUB MoveCursor
                HSEROUT ["Enter SetPoint ... (340=34.0",$F8,"): "]
                HSERIN [DEC SetPoints(EditChannel)]
                GOSUB  TerminalMenu
                LOOKUP2 EditChannel,[EE_SetPoint1,EE_SetPoint2, _
                                     EE_SetPoint3,EE_SetPoint4],Bvar
                WRITE Bvar, WORD SetPoints(EditChannel)
            CASE "P","p"
                X=1 : Y=22 : GOSUB MoveCursor
                HSEROUT ["Enter P term as HEX4 ... : "]
                HSERIN [HEX4 pid_Kp(EditChannel)]
                GOSUB  TerminalMenu
                LOOKUP2 EditChannel,[EE_pid_Kp1,EE_pid_Kp2, _
                                     EE_pid_Kp3,EE_pid_Kp4],Bvar
                WRITE Bvar, WORD pid_Kp(EditChannel)
            
            CASE "I","i"
                X=1 : Y=22 : GOSUB MoveCursor
                HSEROUT ["Enter I term as HEX4 ... : "]
                HSERIN [HEX4 pid_Ki(EditChannel)]
                GOSUB  TerminalMenu
                LOOKUP2 EditChannel,[EE_pid_Ki1,EE_pid_Ki2, _
                                     EE_pid_Ki3,EE_pid_Ki4],Bvar
                WRITE Bvar, WORD pid_Ki(EditChannel)
            
            CASE "D","d"
                X=1 : Y=22 : GOSUB MoveCursor
                HSEROUT ["Enter D term as HEX4 ... : "]
                HSERIN [HEX4 pid_Kd(EditChannel)]
                GOSUB  TerminalMenu
                LOOKUP2 EditChannel,[EE_pid_Kd1,EE_pid_Kd2, _
                                     EE_pid_Kd3,EE_pid_Kd4],Bvar
                WRITE Bvar, WORD pid_Kd(EditChannel)
            
            CASE "T","t"
                X=1 : Y=22 : GOSUB MoveCursor
                HSEROUT ["Enter Ti term as DEC ... : "]
                HSERIN [DEC pid_Ti(EditChannel)]
                GOSUB  TerminalMenu
                LOOKUP2 EditChannel,[EE_pid_Ti1,EE_pid_Ti2, _
                                     EE_pid_Ti3,EE_pid_Ti4],Bvar
                WRITE Bvar, pid_Ti(EditChannel)
    
            CASE "C","c"
                X=1 : Y=22 : GOSUB MoveCursor
                HSEROUT ["Enter I term Clamp as DEC ... : "]
                HSERIN [DEC pid_I_Clamp(EditChannel)]
                GOSUB  TerminalMenu
                LOOKUP2 EditChannel,[EE_pid_I_Clamp1,EE_pid_I_Clamp2, _
                                     EE_pid_I_Clamp3,EE_pid_I_Clamp4],Bvar
                WRITE Bvar, WORD pid_I_Clamp(EditChannel)
             
            CASE "O","o"
                X=1 : Y=22 : GOSUB MoveCursor
                HSEROUT ["Enter Output Clamp as DEC ... : "]
                HSERIN [DEC pid_Out_Clamp(EditChannel)]
                GOSUB  TerminalMenu
                LOOKUP2 EditChannel,[EE_pid_Out_Clamp1,EE_pid_Out_Clamp2, _
                                     EE_pid_Out_Clamp3,EE_pid_Out_Clamp4],Bvar
                WRITE Bvar, WORD pid_Out_Clamp(EditChannel)
            CASE "M","m"
                X=1 : Y=22 : GOSUB MoveCursor
                HSEROUT ["Manual Mode not available.      "]
    
            CASE "1","2","3","4"                       ; select channel
                IF EditChannel != Char -49 THEN
                    GOSUB ClearBox
                    EditChannel = Char -49
                    GOSUB DrawBox
                ENDIF
            CASE ELSE
                HSEROUT [7]     ; bad key, send Bell
        END SELECT
    RETURN
    It might not work with the version in MCS, but works fine with the version that came with windows XP - maybe google for a similar application

    You should get something like

    Last edited by malc-c; - 13th October 2010 at 13:02.

  2. #2
    Join Date
    Aug 2008
    Location
    Portugal
    Posts
    240


    Did you find this post helpful? Yes | No

    Default

    Hi;
    @Henrik;

    Thanks for the answer, i understand now what it means! I will have some more questions, so please don't be mad with me!!

    @malc-c
    Thanks for the code, but i'm not understanding how this piece of code works with the other. Where is the "terminalMenu", "clearBox", "Movecursor" routines?
    When i post the schematic of the hardware, was according to my EasyPic6 Board. I will build the circuit and try the codes in the next Saturday. I think EasyPic5 has the same conections that EasyPic6.
    Please if you try the code posted, tell me the results, if possible, of course. Thanks again!
    Thanks and Regards;
    Gadelhas

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


    Did you find this post helpful? Yes | No

    Default

    I will have some more questions, so please don't be mad with me
    Don't worry, I'll try to answer/explain what I can.

  4. #4
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by gadelhas View Post

    @malc-c
    Thanks for the code, but i'm not understanding how this piece of code works with the other. Where is the "terminalMenu", "clearBox", "Movecursor" routines?
    When i post the schematic of the hardware, was according to my EasyPic6 Board. I will build the circuit and try the codes in the next Saturday. I think EasyPic5 has the same conections that EasyPic6.
    Please if you try the code posted, tell me the results, if possible, of course. Thanks again!
    The code I pasted above was a snippet - It was taken from the zip file attached to the 1st post in my thermostat post you linked to above.

  5. #5
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    OK, I've just confirmed that the files in the first post of my thermostat thread compile and display the output in hyperterminal as per the image shown in a post above. This version is nothing fancy, it will display the temperature of 4 x DS18B20's on a 4 line 20 chr LCD and drive 4 outputs which can be connected to SSR's to switch main voltage devices, It also allows the values of the PID to be tuned by entering values via hyperterminal on a PC connected via a serial cable.

    Ive re-attached all the files here, inc the compiled HEX - please see the hardware inc file which defines the connections to the LCD etc. You are welcome to use this as the basis for your learning....
    Attached Files Attached Files

  6. #6
    Join Date
    Mar 2005
    Location
    Cocoa, Florida
    Posts
    44


    Did you find this post helpful? Yes | No

    Default Pid

    We have a complex temperature control on a 16F777 with 20 temperature sensors (5 DS18S20s, the rest analog LM50 and a couple of MCP9701, plus a Sensirion for ambient T/H.) The poor PIC PWMs 3 sets of fans, reads a flowmeter, drives a heater, talks to another brain and handles two sets of serial out. Just as well, driving temperature, you're not in a hurry.

    Temperature with a large thermal inertia has such a long time domain that it's not a great place to demonstrate PID. A few years back I did a motor PID with a PIC that worked great - just one axis and it was slow but moving a 500lb weight. Motor tuning is the quickest way to illustrate the effect of each PID component.

    Back to temperature: PID is a wonderful thing but in the real world may need a lot of tweaks. First off we abandoned the Derivative as all-but-meaningless on these timescales and now use a setpoint and hysteresis band system with PI(D) only above the upper threshhold. The temperature moves in a slow triangular waveform inside the band (like any thermostat with hysteresis) and only invokes PI when things get warm. Also we have an emergency threshhold up there that drives everything to safety levels. (We are not allowed to power down.)

    Good luck with your project.

  7. #7
    Join Date
    Aug 2008
    Location
    Portugal
    Posts
    240


    Did you find this post helpful? Yes | No

    Default

    Hi Everyone;

    Sorry, but only now had time to get to the fórum!

    [quote]
    Don't worry, I'll try to answer/explain what I can. [/quote}
    @HenrikOlsson
    Once again thank you for your support!

    @malc-c
    Like i said before, this weekend i'll try the code posted, and then i put here the result. Thank you for the code!

    @kenif
    Thanks for your opinion and support, I will take it into consideration!!
    Thanks and Regards;
    Gadelhas

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