Flowcode8 Modbus with PZEM-004T Power Monitor

For general Flowcode discussion that does not belong in the other sections.
medelec35
Matrix Staff
Posts: 2086
http://meble-kuchenne.info.pl
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 644 times
Been thanked: 702 times

Re: Flowcode8 Modbus with PZEM-004T Power Monitor

Post by medelec35 »

Hi Colin.
Many Thanks for the feedback.
The specifications show the power monitor is used with a 100A transformer.
As you are using a non-specified transformer the values returned are going to be incorrect.
As for the max value, the 9's is not the maximum value of the power module.
I chose a value that should be greater than what the unit is capable of, hence all the 9's
So if you see a value of all 9's then there is a communication issue.
I will look into it tomorrow to see if there is an alternative way.
Martin

colinwoodcock
Posts: 14
Joined: Thu Dec 10, 2020 2:40 pm

Re: Flowcode8 Modbus with PZEM-004T Power Monitor

Post by colinwoodcock »

Hi Martin,

Yes I wasn't suggesting Flowcode was at fault for me having to multiply my values by a factor of three! I was just mentioning it for interest in that you can use other current transformers with this module as long as their output is 100mA and then just apply the appropriate correction factor to the measured value. As for the error checking, unless you find another way then it is easy enough for my program to reject any reading exceeding the modules maximum value which would solve the problem. Regards, Colin.

medelec35
Matrix Staff
Posts: 2086
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 644 times
Been thanked: 702 times

Re: Flowcode8 Modbus with PZEM-004T Power Monitor

Post by medelec35 »

Flowcode does CRC error checking with the module and when CRC error checking fails it returns all 9's which is impossible in real life as the number of 9s exceeds the module's maximum value.
A value needs to be returned if there is an issue with CRC or not.
Can't return a 0 as there might not be any current flow or power consumption etc. in real-life measurement.
Therefore, I thought if all values comprised of just 9's then it would be obviouse there was an issue with the module comms.
What I can do is leave all the 9's in and get the initialise to return a 255 if there is a comms issue, or return 0 if comms is ok.
How does that sound, as all the read functions can be bypassed if initialise returns 255
Martin

colinwoodcock
Posts: 14
Joined: Thu Dec 10, 2020 2:40 pm

Re: Flowcode8 Modbus with PZEM-004T Power Monitor

Post by colinwoodcock »

Hi Martin. Yes, that sounds a great idea! Nice and simple. Regards, Col.

medelec35
Matrix Staff
Posts: 2086
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 644 times
Been thanked: 702 times

Re: Flowcode8 Modbus with PZEM-004T Power Monitor

Post by medelec35 »

Hi Colin.
I have attached the updated component that returns 0 if PZEM-004T is detected and 255 if it's not.
After replacing the new component, if your project is already open you will need to reload it.
Note: As the check is only done during initialisation, if the module comms break after then the value will again be 99999.
Attachments
PZEM004T.fcpx
(11.79 KiB) Downloaded 371 times
Martin

colinwoodcock
Posts: 14
Joined: Thu Dec 10, 2020 2:40 pm

Re: Flowcode8 Modbus with PZEM-004T Power Monitor

Post by colinwoodcock »

Thanks Martin, will try it asap.

medelec35
Matrix Staff
Posts: 2086
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 644 times
Been thanked: 702 times

Re: Flowcode8 Modbus with PZEM-004T Power Monitor

Post by medelec35 »

No problem.
What you can also do is use a decision branch that states if the current > 300 then "CRC fail" etc.
Martin

Post Reply