In the actual customer's application, the pulse frequencies sent to INPUTs 1,3 and 5 are not related to each other in any way. The pulses originate from 3 pulse flow sensors. To make it more interesting the pulses tend to be "jittery" and from one pulse to the next both the duty cycle and frequency may change by as much as 10%!
I have been simulating the customer's pulse sources using the PLC PWM and a set of equations that model the relationship between the flow rate and pump speed measured in Hz (VFDCurrenHz). Just to give you an idea of the complexity of the simulation, this is a snippet of the actual Fx code that I am using to generate the simulated project flows and then simulate them with the PWM system:
' The equations to covert VFD Hz to flows are based on a "science project" performed
' at Tomar on 1/13/2016 on a 15 hp "POOL" system. These are the "best fit"
' equations to relate Pump speed (Hz) to flow rates in GPM
'
SimProductGPM = 0.0072 * VFDCurrentHz * VFDCurrentHz + 0.0644 * VFDCurrentHz + 8.6493
SetPWM 1, 5000, SimProductGPM / 60.0 * ProductPPG
SimBrineGPM = 0.0009 * VFDCurrentHz * VFDCurrentHz + 0.033 * VFDCurrentHz + 3.8351
SetPWM 2, 5000, SimBrineGPM / 60.0 * BrinePPG
SimRecircGPM = 0.4988 * VFDCurrentHz - 0.951
SetPWM 3, 5000, SimRecircGPM / 60.0 * RecircPPG
[/font][/color]
I know that the simulation is an approximation to the nearest Hz for the SetPWM commands. In some cases I have summed in a bit of random noise to make the simulated pulses "look" more like what I see from the actual flow sensors. However, even with the customers real system, the values returned by the PulsePeriod(1) function and the HSC[1] can be in error by significanly more that the the jitter that I can "see" with test equipment.
I'd be happy to test stuff. At present I am using an interrupt routine to measure the pulse period on INPUT #1 but am using the high speed counter mechanism and PulsePeriod() for INPUTs 3 and 5. I don't see a pattern of wrong measurements on INPUTs 3 and 5 and the interrupt routine that I am using is working without a problem.
What I started to do, was to write the simplest code that could demo the problem. However, it was too simple and the problem did not show up. As soon as I can get a break from my client's issues, I'll go back and see if I can a demo program that you can use to "see" the issues.
I have another issue with the PLC firmware and I see it on both the Fx and the FMD/Nano PLCs. I have problems with error rates over the the RS485 ports. As an example, I get measurable error rates with Modbus RTU and the native host commands over serial cables that are less than a foot in length. I would expect an error rate of 0. What I am seeing is both missing data bytes and corrupted data bytes. The error rate correlates directly with BAUD rate, but even at 4800 BAUD I can still find a measurable error rate. I have, also, written by own Modbus RTU routines in TBASIC so that I could better observe what was the nature of the data corruption. Once we get the HSC/Pulse measurements system figured out, I'll attack this issue, next.
Best regards,
Gary D*ickinson