Current Cost Support Forum

A support forum for Current Cost users, partners and developers. Covering hardware, software and web.
Site Announcements

The support forum is moderated Monday to Friday, UK time. To submit a support ticket, please email: helpme [at] currentcost .com

It is currently Tue Sep 16, 2014 2:25 pm

All times are UTC [ DST ]




Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 
Author Message
PostPosted: Sat Sep 10, 2011 3:25 pm 
Offline

Joined: Sat Apr 16, 2011 1:10 pm
Posts: 328
Location: East Sussex
I have not played with C++ since we were rolling out Advanced Novell Netware which needed 640kb rather than 256kb of workstation RAM.

Thus, I wrote a program to check ram size and log to a folder on the server the results.

So I am a little rusty :)

Thus my question...

I guess someone has already done the code to read from the com port and split the data into the various channels.

(I am after a dashboard program that shows in near real time all channels at once on a PC screen).

Compatibility with the new Optismart would also be nice :)

Many thanks

Automan.


Top
 Profile  
 
PostPosted: Sun Sep 11, 2011 2:54 pm 
Offline

Joined: Mon Apr 18, 2011 5:26 pm
Posts: 138
Location: Melbourne, Australia
Automan wrote:
I have not played with C++ since we were rolling out Advanced Novell Netware which needed 640kb rather than 256kb of workstation RAM.
Showing your age olld boy! If we're swapping war stories, my first mainframe had 40K core memory.
Quote:
(I am after a dashboard program that shows in near real time all channels at once on a PC screen).

Compatibility with the new Optismart would also be nice .
Apparently no takers on this. I needed something similar so I tweaked some existing code I had, to display what I needed. At the moment it extracts Ch1->Ch3 from one sensor and displays it on a console. It is rough and ready but you may find it meets some of your need.

My code is written in powershell, because makes manipulating xml a doddle, it but that shouldn't be a problem if you're running Win7 or Vista as the powershell interpreter is built into the OS. (It is also built into XP since SP2, for anything earlier you would need to download powershell from Microsoft).

to use it:
  • download DisplayENVI.ps1 from http://pastebin.com/KTcE26p9.
  • Correct the com port, baudrate and Sensor to be displayed on lines 9-11.
  • execute in a command window using command "powershell .\DisplayENVI.ps1"
  • Stop by keying Ctrl-break or Ctrl-C

Powershell scripts require authorisation to run. The command can be entered manually, but is easier to download DisplayENVI.bat from http://pastebin.com/Snyd60RP. Save this in the same directory as DisplayENVI.ps1 and double-click to execute.

HTH

_________________
Seeker
"The Truth is out there!"


Top
 Profile  
 
PostPosted: Mon Sep 12, 2011 3:37 pm 
Offline

Joined: Sat Apr 16, 2011 1:10 pm
Posts: 328
Location: East Sussex
Thanks for the code which I have "tweaked" to display the Optismart meter readings from my two units.

Code:
### DisplayENVI.ps1 ############################################
#
# Routine to display power recorded by a Current Cost Monitor.
#               
################################################################


$loop_forever = $true
$CommPort_in="COM3"
$BaudRate=57600
$Sensor1=9
$Sensor2=8

#$template=[xml]("<msg><src></src><dsb></dsb><time></time><tmpr></tmpr><sensor></sensor><id></id><type></type><ch1><watts></watts></ch1><ch2><watts></watts></ch2><ch3><watts></watts></ch3></msg>")


[SINGLE]$CH1 = 0
[SINGLE]$CH2 = 0
[SINGLE]$CH3 = 0
[SINGLE]$Meter1 = 62745
[SINGLE]$Meter2 = -71
[SINGLE]$Total1 = 0
[SINGLE]$Total2 = 0
$TimeNow=" "
#########################################3######################
$port_in= new-Object System.IO.Ports.SerialPort $CommPort_in,$BaudRate,None,8,one
$port_in.Open()

$data=$port_in.Readline() #Discard a possibly partial msg
#

do {
   $data=$port_in.Readline()
   #Write-Host ($data)
   #Remove any chars (probably noise) received before <msg
   if ((!$data.StartsWith("<msg>")) -or (!$data.EndsWith("</msg>")))
      {$Data =$data.substring($data.IndexOf("<"),$data.LastIndexOf(">") - $data.IndexOf("<")+1)
      }
   
   [xml]$data_in=$data #may still have noise inside the message. trap error and continue
   #---------------------------------------------------
   if ($data_in.msg.sensor -eq $Sensor1)
      {$CH1=$data_in.msg.imp     
       $CH2=$data_in.msg.ipu
       $CH3=$data_in.msg.id
      $Total1 = ($CH1 / $CH2) + $Meter1
         $TimeNow=$data_in.msg.time
       
       # Cls

      Write-Host ("Sensor=$Sensor1, Time=$TimeNow Meter Reading=$Total1, Impulse Count=$CH1")
       
       }
   
    elseif ($data_in.msg.sensor -eq $Sensor2)
      {$CH1=$data_in.msg.imp     
       $CH2=$data_in.msg.ipu
       $CH3=$data_in.msg.id
      $Total2 = ($CH1 / $CH2) + $Meter2
         $TimeNow=$data_in.msg.time
       

      Write-Host ("Sensor=$Sensor2, Time=$TimeNow Meter Reading=$Total2, Impulse Count=$CH1")
 
       
      }
       
   else
      {
       # All other sensors ignored
      }
   #----------------------------------------------------
   } While ($loop_forever='true')
$port_in.close()
Write-Host ("DisplayENVI completed")


Meter1 and Meter2 are to set the display to match my electric meters. (odd that one seems to have a stored value higher than my meter).

Automan.


SeekerAfterTruth wrote:
Automan wrote:
I have not played with C++ since we were rolling out Advanced Novell Netware which needed 640kb rather than 256kb of workstation RAM.
Showing your age olld boy! If we're swapping war stories, my first mainframe had 40K core memory.
Quote:
(I am after a dashboard program that shows in near real time all channels at once on a PC screen).

Compatibility with the new Optismart would also be nice .
Apparently no takers on this. I needed something similar so I tweaked some existing code I had, to display what I needed. At the moment it extracts Ch1->Ch3 from one sensor and displays it on a console. It is rough and ready but you may find it meets some of your need.

My code is written in powershell, because makes manipulating xml a doddle, it but that shouldn't be a problem if you're running Win7 or Vista as the powershell interpreter is built into the OS. (It is also built into XP since SP2, for anything earlier you would need to download powershell from Microsoft).

to use it:
  • download DisplayENVI.ps1 from http://pastebin.com/KTcE26p9.
  • Correct the com port, baudrate and Sensor to be displayed on lines 9-11.
  • execute in a command window using command "powershell .\DisplayENVI.ps1"
  • Stop by keying Ctrl-break or Ctrl-C

Powershell scripts require authorisation to run. The command can be entered manually, but is easier to download DisplayENVI.bat from http://pastebin.com/Snyd60RP. Save this in the same directory as DisplayENVI.ps1 and double-click to execute.

HTH


Top
 Profile  
 
PostPosted: Tue Sep 13, 2011 1:57 am 
Offline

Joined: Mon Apr 18, 2011 5:26 pm
Posts: 138
Location: Melbourne, Australia
Automan wrote:
Thanks for the code which I have "tweaked" to display the Optismart meter readings from my two units.

Looking good! Now all we need is a GUI and we can go to market. Any good with Dotnet forms?

P.S. if anyone else is playing with this, you can test you mods by removing the # from the line #Write-Host ($data) to see the input interspersed with the output.

_________________
Seeker
"The Truth is out there!"


Top
 Profile  
 
PostPosted: Sun Jan 15, 2012 2:17 pm 
Offline

Joined: Sun Jan 15, 2012 1:33 pm
Posts: 4
First of all I would like to thank Seeker for his PS example.

I too wanted to graph my use; generation; export and IAMs. My skill level is ungifted tinkerer. The bespoke software I found out there was either inflexible or omitted features I required.

The PS example showed me how simply PS will parse the XML so all I really added was a little logic and call Invoke-Expression RRDtool update ... to enter the data into RRDtool.
RRDtool is the ideal place to store your history data. It is simple to set up, doesn't treat Windows as a poor brother to Lx and is easy as pie to produce graphs from.
Hey presto! and I have capture, database and graphing.
e.g. this took less than 20mins to setup and an hour to watch it collect the data

Image

Happy to provide examples if anyone is as baffled as I was a few days ago.

S
...now all I have to get to work is the CGI graphing code.


Top
 Profile  
 
PostPosted: Thu Feb 02, 2012 11:28 am 
Offline

Joined: Sat Apr 16, 2011 1:10 pm
Posts: 328
Location: East Sussex
Very cool...

Indeed, if you could post the code that would help....

Also I guess looking direct at the xml you get a more accurate graph than the every six minute average the website gives you.

Automan.

sashton wrote:
First of all I would like to thank Seeker for his PS example.

I too wanted to graph my use; generation; export and IAMs. My skill level is ungifted tinkerer. The bespoke software I found out there was either inflexible or omitted features I required.

The PS example showed me how simply PS will parse the XML so all I really added was a little logic and call Invoke-Expression RRDtool update ... to enter the data into RRDtool.
RRDtool is the ideal place to store your history data. It is simple to set up, doesn't treat Windows as a poor brother to Lx and is easy as pie to produce graphs from.
Hey presto! and I have capture, database and graphing.
e.g. this took less than 20mins to setup and an hour to watch it collect the data

Image

Happy to provide examples if anyone is as baffled as I was a few days ago.

S
...now all I have to get to work is the CGI graphing code.


Top
 Profile  
 
PostPosted: Wed Mar 07, 2012 9:50 am 
Offline

Joined: Sun Jan 15, 2012 1:33 pm
Posts: 4
I'm sorry for the delay in replying. I had one of the opti-smart transmitters freezing once every couple of days and eventually gave up fiddling with it and bought a replacement one. Here's hoping that this isn't a portent that the transmitters will fail on a regular basis.
The graphs are now published on a local Windows box via IIS at http://www.bowmill.net - Solar PV menu
I'll publish a "how I did this" page there this weekend which will include the script reading the EnviR along with the RRD create and graph definitions.
S


Top
 Profile  
 
PostPosted: Fri Mar 09, 2012 6:36 pm 
Offline

Joined: Sun Jan 15, 2012 1:33 pm
Posts: 4
Automan
Did you ever get a reply from CC about the Optismart continuously incrementing the counter at about 0.64Kw when connected to a meter with the LED solidly on? The Elster A100Cs I have behave like this.

While not exporting or generating, like your experiences in the hardware forum, I was seeing the counters incrementing by about 640/hour when no power was being passed.
I wanted to capture the incremental power used over a day and found the only way I could acheive this was to increment the base counter reading while the rate was indicated as 0Kw. A bit of a kludge but it works.

The problem with this that I now have used all my free sensor slots on the EnviR so I now have two IAMs I cannot use without buying another receiver.

I guess I could return the kit to CC but hopefully you can tell me they fixed the problem for you.

S


Top
 Profile  
 
PostPosted: Thu Mar 15, 2012 3:52 pm 
Offline

Joined: Sun Jan 15, 2012 1:33 pm
Posts: 4
I have been tried to post a reply including my code/sertup to this forum three times now.
For some reason they are not showing. I have had no notification that my proposed posting breaks any rules.
Examples of what I have put together can be seen at www.bowmill.net under the Solar PV button.

I have had to compensate for a steady increase in the counter value from the Optismart when no current is flowing (at about 640 Watts). Essentially I increase the base counter at this rate when the power value returned from the device indicates 0 Watts.

S


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group