Skip to content

Commit

Permalink
Frequency settings matched to standard iicsys#4
Browse files Browse the repository at this point in the history
When FREQ is 16-bit integer, it is considered to be frequency deviation from nominal (in mHz) and it is added to nominal frequency value to get actual value of frequency (see one of my commits) , divided by 1000.
When FREQ is floating points, it is actual frequency value that should be written in Hz (because range is -32767 <= freq<=32767, so max value would be 32.767Hz if we use mHz for input).

This is only my understanding of standard and should be checked by others.
  • Loading branch information
veljkoDjurkovic committed Jul 29, 2022
1 parent 9789343 commit a744942
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions synchrophasor/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -2140,13 +2140,13 @@ def _freq2int(freq, data_format):
if isinstance(data_format, int):
data_format = DataFrame._int2format(data_format)

if data_format[3]: # FREQ/DFREQ floating point
if not -32.767 <= freq <= 32.767:
raise ValueError("FREQ must be in range -32.767 <= FREQ <= 32.767.")
if data_format[3]: # FREQ/DFREQ floating point, actual frequency value, input in Hz.
if not -32767 <= freq <= 32767:
raise ValueError("FREQ must be in range -32767 <= FREQ <= 32767.")

freq = unpack("!I", pack("!f", float(freq)))[0]
else:
if not -32767 <= freq <= 32767:
if not -32767 <= freq <= 32767: #FREQ 16-bit integer, should be frequency deviation from nominal(mHz). It is divided by 1000 and added to FNOM.
raise ValueError("FREQ must be 16-bit signed integer. -32767 <= FREQ <= 32767.")
freq = unpack("!H", pack("!h", freq))[0]

Expand Down

0 comments on commit a744942

Please sign in to comment.