Shop OBEX P1 Docs P2 Docs Learn Events
It is amazing how one project can teach you on another — Parallax Forums

It is amazing how one project can teach you on another

TCTC Posts: 1,019
edited 2014-02-04 18:01 in General Discussion
Hello all,

This is not a question post, but a post to express one victory I had with my self.

A few years ago, I was in a major motorcycle accident that left me with some brain damage. You can add my A.D.D. on top of the damage. So for me to figure A problem takes a little more time than most, but I will never let that stop me.

I am currently working on 3 projects, a power supply, my wife's table, and a reflow oven. I have to do many project at a time (have to change it up), if I don't I lose interest, and I could not figure out problems anymore.

Well for the reflow oven, I have been trying to figure out for weeks how to do a simple PWM for it. I don't need one that can do 1khz, I just needed one that can turn on and off a heating element. But I also didn't want just on/off control.

While doing a little code for my wife's table, I noticed that the TLC5941 uses a 12-bit counter to control the PWM outputs. so I thought, why could I not use a repeat that counts from 4095 down to 0, then have a if that compares the PWM value. Here is what I came up with
    repeat count from 4095 to 0
      if count > C
        dira[16] := 1
        outa[16] := 0

      else
        dira[16] := 1
        outa[16] := 1

The code works great. I'm happy with the output, now to do more work on the PID.

Thanks
TC

Comments

  • JonnyMacJonnyMac Posts: 9,107
    edited 2014-02-04 14:56
    Given the thermal inertia of the heating elements and 60Hz AC being controlled, you may want to slow down the PWM output. Remember, once turned on, the triac will not turn off until it hits the zero-cross. If your loop runs faster than 8ms, it could completely run out within a single AC half-cycle.

    Having previously designed an AC dimmer that uses a zero-cross detector (opto-isolator), I thought I might do heating element control like this:
    pri triac_ctrl(zc, triac, p_ctrl) | mask, level                 ' launch with congnew
    
      outa[triac] := 0                                              ' make triac pin output
      dira[triac] := 1
    
      repeat
        repeat level from 100 to 1
          waitpeq(1 << zc, 1 << zc, 0)                              ' wait for zero-cross
          if (byte[p_ctrl] => level)                                ' on now?
            outa[triac] := 1
          waitcnt(cnt + (clkfreq / 500))                            ' 2ms delay
          outa[triac] := 0                                          ' kill triac output
    


    This input is a byte (0..100), the code counts the cycles, enabling the triac at the zero cross point.
  • TCTC Posts: 1,019
    edited 2014-02-04 15:28
    JonnyMac wrote: »
    Given the thermal inertial of the heating elements and 60Hz AC being controlled, you may want to slow down the PWM output. Remember, once turned on, the triac will not turn off until it hits the zero-cross. If your loop runs faster than 8ms, it could completely run out within a single AC half-cycle.

    HOLY COW! I cant believe I didn't think of that. I have been testing everything with a resistor and a transistor(less chance of getting shocked).
    Having previously designed an AC dimmer that uses a zero-cross detector (opto-isolator), I thought I might do heating element control like this:
    pri triac_ctrl(zc, triac, p_ctrl) | mask, level                 ' launch with congnew
    
      outa[triac] := 0                                              ' make triac pin output
      dira[triac] := 1
    
      repeat
        repeat level from 100 to 1
          waitpeq(1 << zc, 1 << zc, 0)                              ' wait for zero-cross
          if (byte[p_ctrl] => level)                                ' on now?
            outa[triac] := 1
          waitcnt(cnt + (clkfreq / 500))                            ' 2ms delay
          outa[triac] := 0                                          ' kill triac output
    


    This input is a byte (0..100), the code counts the cycles, enabling the triac at the zero cross point.

    That would work, but I have a couple questions;
    1) I am trying to use old parts as much as I can, and I have an old crane machine(the game with the toys inside) board. it has 7 triacs with opto-isolators for each. I was going to use 2 for the oven, 1 for the top heater, and one for the bottom. so that leaves me with 5 left. could I use one of them? there part number is K3023P, and the triacs are.MAC210A8FP.

    2) I was hoping to take that PWM driver combine it with my PID, and my MAX31855 object, so I have one object that all I have to do is pass the set value, and it will make it happen. and I also wanted to be able to read the max31855 from my main program so it can be shown on the display. and last, I wanted to have 2 separate objects that would control the heaters. one for the top, one for the bottom. and to be in its own cog. (i know a lot of stuff) What do you think would be my best option for this?

    Thanks
  • Cluso99Cluso99 Posts: 18,069
    edited 2014-02-04 16:12
    TC wrote: »
    HOLY COW! I cant believe I didn't think of that. I have been testing everything with a resistor and a transistor(less chance of getting shocked).



    That would work, but I have a couple questions;
    1) I am trying to use old parts as much as I can, and I have an old crane machine(the game with the toys inside) board. it has 7 triacs with opto-isolators for each. I was going to use 2 for the oven, 1 for the top heater, and one for the bottom. so that leaves me with 5 left. could I use one of them? there part number is K3023P, and the triacs are.MAC210A8FP.

    2) I was hoping to take that PWM driver combine it with my PID, and my MAX31855 object, so I have one object that all I have to do is pass the set value, and it will make it happen. and I also wanted to be able to read the max31855 from my main program so it can be shown on the display. and last, I wanted to have 2 separate objects that would control the heaters. one for the top, one for the bottom. and to be in its own cog. (i know a lot of stuff) What do you think would be my best option for this?

    Thanks
    Without looking up the specs I don't know if the triacs will work. Remember, the heating elements will draw a lot of power. Why don't you use the SSR's from eBay?
  • kwinnkwinn Posts: 8,697
    edited 2014-02-04 16:15
    That optotriac and triac are fine for what you are doing. Using them to control power to the heating elements by turning the triac on for x out of 4096 AC cycles would give you a PWM frequency of 0.0146Hz which is fine for this application, and very fine control of the power (0.0244% step). An 8 bit value would give a PWM frequency of 0.2353Hz and a power step of 0.392%.
  • TCTC Posts: 1,019
    edited 2014-02-04 16:45
    Cluso99 wrote: »
    Without looking up the specs I don't know if the triacs will work. Remember, the heating elements will draw a lot of power. Why don't you use the SSR's from eBay?

    The datasheet says they have a On-State Current RMS (TC = +70°C) of 10A, Peak Non-repetitive Surge Current of 100A. I am trying to make this as cheap as I can. I already have the triacs, and since they will only be driving one heater each, I should be well under the max current. so far, I have only bought the oven its self.
  • TCTC Posts: 1,019
    edited 2014-02-04 16:51
    kwinn wrote: »
    That optotriac and triac are fine for what you are doing. Using them to control power to the heating elements by turning the triac on for x out of 4096 AC cycles would give you a PWM frequency of 0.0146Hz which is fine for this application, and very fine control of the power (0.0244% step). An 8 bit value would give a PWM frequency of 0.2353Hz and a power step of 0.392%.

    That might just be my final direction, after I get the PID working at 8-bits. right now if I try to change it, I overshoot to much (+10C). But again, that is with a thermocouple hooked to a 1W resistor(as the heater). I know its going to be completely different with the oven.
  • JonnyMacJonnyMac Posts: 9,107
    edited 2014-02-04 17:45
    Attached is the circuit I use (very common from lighting control projects) for zero-cross detection. I've written a PASM dimmer object for AC lighting control, but I think that's a bit much for heating element control, hence the "slow" code I posted above. The H11AA1 allows detection of zero-cross going positive-to-negative, and negative-to-positive. At 60Hz you get a short high-going signal (ZC pin) every 8.33 milliseconds, hence that loop updates every 0.83 seconds.

    If you decide to do phase-angle control, I can show you the PASM code I used to do that.
    520 x 422 - 39K
  • TCTC Posts: 1,019
    edited 2014-02-04 18:01
    JonnyMac wrote: »
    Attached is the circuit I use (very common from lighting control projects) for zero-cross detection. I've written a PASM dimmer object for AC lighting control, but I think that's a bit much for heating element control, hence the "slow" code I posted above. The H11AA1 allows detection of zero-cross going positive-to-negative, and negative-to-positive. At 60Hz you get a short high-going signal (ZC pin) every 8.33 milliseconds, hence that loop updates every 0.83 seconds.

    If you decide to do phase-angle control, I can show you the PASM code I used to do that.

    That is great, and the part is less than $1 each.

    I completely agree, there is no need for a PASM driver for this. I don't think I would ever see a difference between them.

    Thank you so much Jon.
Sign In or Register to comment.