Friday, March 21, 2014

Connect to thingspeak (Python Code)

import httplib
import urllib
import serial
import time
import math
import urllib2



def dglux(device_ID,device_point,value):
    conn = httplib.HTTPConnection("localhost",8080)
    data="/httpds?__device"+'='+str(device_ID)+'&'+str(device_point)+'='+str(value)
    conn.request("GET", data)

def thing_speak(f1,f2): 
    try:       
        para= urllib.urlencode({'field1':f1,'field2':f2,
                                'key':'xxxxxxxxxxxxxxxxxxxxxxxx'})
        headers={"Content-type":"application/x-www-form-urlencoded","Accept":
                 "text/plain"}
        conn=httplib.HTTPConnection("api.thingspeak.com:80")
        conn.request("POST","/update",para,headers)
        response=conn.getresponse()
        print response.status, response.reason
        data=response.read()
        conn.close()
    except:
        print "Network Connection error"
    
ser = serial.Serial("COM3",9600)
while True:
    f1=ser.readline()   
    if eval(f1)>0:       
        #print type(f1)
        f2=eval(f1)*230*0.8
        print f1,f2
        thing_speak(f1,f2)
        #time.sleep(45   
        #dglux("Home","Current",f1)
ser.close()




   
   

Saturday, November 16, 2013

Arduino Python SCADA Mango M2M

Http Data sources
Python code for Test Http receiver

import httplib
import time
def data(device_ID,device_point,value):
    conn = httplib.HTTPConnection("localhost",8080)
    data="/httpds?__device"+'='+str(device_ID)+'&'+str(device_point)+'='+str(value)
    conn.request("GET", data)
for i in range(100):
    data('Home','current',float(i)/100)
    data('Home','voltage',230)
    data('Home','temp',32)
    data('Home','KW',(i*230*0.8/1000))
    #print i
    time.sleep(3)
   
    



Monday, May 23, 2011

Select serial Port


Free PLC Simulator

 In order to setup PLC simulator you must have to download following Products

virtual Serial Port Emulator Downloads





Download the Mod_RSsim .
Download

and it will install to C:\Program Files\EmbeddedIntelligence\Mod_RSsim folder

run this program
 Select the Ouputs / Inputs/Analog/Holding and Extended registers to give some values
and then select

Next : Read PLC data

Password and User Name

Pass= admin
username=admin

opening page looks like



Practical Session

In order to do practical session in SCADA and Automation Systems ,need to be downloaded  Mango M2M .
below link direct to download  MANGO M2M,


make sure that install all the software as instructed by Manago M2M website ,

1. Install Java JD1.6.0_21 above

2. Unzipped apache-tomcat-6.0.20 to C:\ directory

3. Delete C:\apache-tomcat-6.0.20\webapps folder and recreate C:\apache-tomcat-6.0.20\webapps\ROOT

and then Unzipped Mango M2M to that ROOT folder (C:\apache-tomcat-6.0.20\webapps\ROOT)

4. Then right clicked on My Computer and select properties and select Advanced Tab then  select Environmental Variables .


now you almost completed of installing Mango M2M

5.  Now you have to install RXTXcomm.jar and rxtxSerial.dll  in below folders (C:\Program Files\Java\)

  • RXTXcomm.jar: save in <jdk1.6-home>\jre\lib\ext
  • rxtxSerial.dll: save in <jdk1.6-home>\jre\bin
6.  Now go to C:\apache-tomcat-6.0.20\bin folder and you will find startup.bat file , click on that startup.bat file , you will see now Tomcat is running .






7. Open the web browser and type on address bar http://localhost:8080


cheers ....

Next .. Password and User name

Sunday, May 22, 2011

PLC Important Vocabulary



 
address     The unique location assigned to each I/O module so that it may be correctly referenced and signaled by the PLC program.
binary     A number system used for PLCs that has either 0 or 1 as a value. Using binary, a function is either on or off.
bit     A single numerical unit in the binary number system. Bit is short for BInary digiT.
bit number     The numbered location of the specific individual bit being addressed. Bit numbers are typically the last number found in an address.
byte     A series of eight bits.
common     The screw terminal on a PLC that connects to the power source.
counter     A set of PLC instructions that counts, calculates, or keeps a record of the number of times something happens.
digital     Consisting of information that is input or output electronically as a series of pulses or signals often resulting in binary strings of 0s and 1s.
examine off     A basic PLC logic instruction symbol. Also referred to as Examine If Open. Examine Off becomes True if an input is absent.
examine on     A basic PLC logic instruction symbol. Also referred to as Examine If Closed. Examine On becomes TRUE if an input is present.
file     A data register in a PLC that stores bits of information. Files are often referred to as registers.
file identifier     A letter code given to each type of data file to make it easier for the programmer to identify the files.
file number     The specific bit number assigned to each type of data file so that it can be easily found within the ladder logic program.
holding register     The PLC equivalent of traditional relays. Holding registers hold data that will later be executed by the processor.
I/O module     The part of a modular PLC to which input and output devices are connected.
input group register     A type of input register that can receive data from 16 consecutive input terminals. Grouping registers is an efficient way to control multiple inputs.
input register     A register that receives and stores data signaled from a hardwired input.
nibble     Four bits in series, or half an 8-bit byte.
output register     A register that stores data on the status of a hardwired output.
read from     The process of a PLC scanning a register and using the data found within that register in a meaningful way.
real-time value     The exact current value of a bit of data. PLC register data is not considered real-time because values can change between PLC scans.
register     A data file in a PLC that stores bits of information. Some PLCs refer to registers as files.
remote I/O     An input/output module that is located far away from the CPU of the PLC.
scan     One complete cycle of a PLC checking inputs, executing its programs, and updating the status of its outputs.
sequential     Doing one and only one step at a time, followed by the next step in a logical order.
shift register     Shifting bits forward or backward within a word to vary how the outputs respond.
slot number     The numbered location of the specific PLC module being addressed.
terminal block     A device that joins wires or cables. Terminal blocks typically snap into a metal rail or are screw-mounted on the panel of a control enclosure.
timer     A set of PLC instructions that automatically starts or stops machines and other devices when a preset time period has been exceeded.
word     A defined and specific number of digits grouped together. For most PLCs, a word consists of 16 digits.
word number     The numbered location of the specific data word being addressed. Word numbers are found only on advanced PLCs.
written to     The process of a PLC storing data within a register for later use.