PDA

View Full Version : HPWM min freq ?



swordman
- 6th September 2004, 08:04
Hi,
Can I use hpwm 0.1 hz out for on/off kontrol?
For example 2sec on 2sec off.

Acetronics2
- 6th September 2004, 09:48
Hi Sword,

NO ...there are min. frequencies ( see manual ...) but you could much better use Timer 1 for your project ...

Alain

Melanie
- 6th September 2004, 10:31
Do a search for 'Slow Software PWM' or 'SSPWM' in the MeLabs archives.

swordman
- 6th September 2004, 11:06
Hi,
I need hpwm , becouse must work always in background,
for control (PID control) temperature .

Melanie
- 6th September 2004, 11:34
Don't quote me, but I vaguely recall that example does run in background.

I can see where you're going with this though... proportional switching of Thyristor/Triac Packs for Heating as an example... if that is the case, then putting in a PIC with HPWM is overkill as you can do that in a couple of hundred bytes in a 12C509... If on the other hand you're using the PWM to generate an output voltage proportional to temperature, then you really should be using a much higher frequency.

swordman
- 6th September 2004, 11:57
Hi,
I need for SSR control , like industrial temp(PID,PI,on/off) controllers.
When reading value is near to set point , out pic pin.x (to SSR) must switching(pulses between 0.5-3 sec).
Also when main program work, thats (temp control)application must work in background.


Hardware: 16f877a-4mhz + LCD+5 buttons(Set &IN) + 1 ADC In (THermocouple read)

Acetronics2
- 6th September 2004, 12:09
Hi,

If you run a PID regulator ... there's a timebase somewhere, so, just count n cycles for 10 seconds and switch on if required ...n cycles and switch out ... etc.

you said ON/OFF output, it seems ...not real PWM with %.

then you can make a very simple output drive !!!

Alain

swordman
- 6th September 2004, 12:24
Hi,
Application (Temp control)will be set : SSR out:
1.ON/OFF
2. PI
3.PID

The idea is two in one : 1.Temp cont(Like industrial) , 2.Main Program

Acetronics2
- 6th September 2004, 12:49
Where' the problem ???

Alain

Melanie
- 6th September 2004, 13:22
Conventionally, PID Controls take the temperature as an input and give a proportional 0-10v as an output, which is accepted practice for all BMS.

You then have separate heating/refridgeration controllers which accept the 0-10v proportional signal as an input and control the SSR's.

As separate units they give you many advantages - least of which is versatility. You can have single and three phase SSR's in dozens of sizes from less than 1kW to 100's of kW, yet they'll all accept the common 0-10v proportional input.

Seems a case of reinventing the wheel by welding the tyre to the hub as a single entity...

swordman
- 6th September 2004, 13:24
The problem is when main program work in background temp control(time based for pid) must work.

For example(time based):
Set Point = 200 C
When adread 190C out(to SSR) must 3sec-on, 1 sec - off
When adread 195C out(to SSR) must 2sec-on, 0.5 sec - off(aproximate)

etc.

Melanie
- 6th September 2004, 13:43
Since the PID calculation will probably take less than 5mS why not just calculate it during one mains cycle... you've got 8mS to play with at 60Hz... and if you miss one cross-over point, simply wait for the next one 8mS later... even if you miss ten cross-overs (80mS), it's no big deal in Heating... there's probably so much Thermal Lag nobody would notice anyway.

Acetronics2
- 6th September 2004, 14:08
As the drive calculation is a part of the PID regulator section, why do you want to switch on and off outside the background work ???

IF you had a constant time period for switching ( 2 sec on, 2 off ; 1 sec on, 3 off ...) it would be so easier to drive ...

I do not understand why you want so much difficulties ...

Definitely bye !

Alain

swordman
- 6th September 2004, 14:41
Hi,
In main program I have many pause command, if I use
pidout:
high pidout :pause (error*100):low pidout: (pause error*50)
goto pidout

the work very slow and unstable.I must use gosub adread in loops(for/next) becouse loops are 1-180min.When I use that sample (pidout) pic work unstable(slow).



Timed out must be like this:
----_______-------------_______--------____-----___----__--_-____
~~!~~~~~~~~~~~ Error ~ ~~~~~~~~~~~~~~~~~~~~~~~!Set Point





main:
gosub button
gosub adread
high portc.2 : pause 2000
gosub adread
high portc.4 : pause 1000
gosub adread
low portc.2 : pause 2000
gosub adread
for x

gosub adread
next x
gosub lcd: gosub lcd

goto main

adread:

adcin 0,read1 : pauseus 16 : adcin 0,read2 : pauseus 16
adcin 0,read3 : pauseus 16 : adcin 0,read4 : pauseus 16

readt = (read1 + read2 + read3 + read4 ) / 4
z = ( readt*40 )/130
error = t -z
....... PID calculation+ PID controlled out
return


lcd:...........return
loop:........return
button:....return

end