0

I am programing a solarcell tracker with the use of Wago PFC100 and Ecockpit software.

I have a principle problem regarding converting some counter values in a 16-bit WORD to a pulsetrain in form of BOOL.

The 16-bit word register counts up/down from 0 to 12621. I need to convert this to BOOL pulses.

when word counter goes from 0 to 1 I need a BOOL pulse 0->1->0, and on next count from 1 to 2 I need a new BOOL pulse of 0->1->0.

I also need pulses in the case that the word register counts down: 2 to 1 needs to also generate a BOOL pulse 0->1->0.

I am programing this with structured text (ST), and I don't know how I could get this part running.

1 Answers1

1

There are a couple of ways to accomplish this.

If you are not expecting the counter to increment more than once per program scan, you can simply look at bit 0 of the counter. Every time it changes, pulse the output.

If it might count more than one per program scan, then on each program scan you need to look at the current counter value and compare it to the counter value on the last scan. The difference between the current value and the last value is how many times you need to pulse the output.

  • This was a nice solution, but sadly the counter is much faster then the program cycle. –  Mar 15 '17 at 15:12
  • Does your pulse train output also need to run faster than the program scan? Do you have a high speed pulse train output on your PLC? – Ben Miller - Remember Monica Mar 15 '17 at 15:15
  • yes it runs faster and the counted value is bufferd in the 750-638 counter. so no realtime peak on that. also the frequency of the counted pulses is changing. –  Mar 16 '17 at 08:54
  • 1
    Wago support sugested this solution: wCounterValue := (BYTE_TO_WORD(bCounterValueHighByte) * 16#0100) + BYTE_TO_WORD(bCounterValueLowByte); TOF_PulseOut(IN:= (wCounterValue <> wCounterValueOld), PT:= tPulseDuration, Q=> xPulseOut); wCounterValueOld := wCounterValue; This seems to fix the problem. Thank you Ben Miller for your help. i have to notice this stackoverflow is a hostile enviroment. iam not using this anymore. –  Mar 16 '17 at 08:57