Automaton

MrPLC Member
  • Content count

    23
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Automaton

  • Rank
    Sparky

Profile Information

  • Country Ireland
  1. Cicode problem

    You can configure an event (look under system, events) In the name field select global, and select say 00:00:01 in the period for a 1 second update. Select your cluster in the cluster field. The action field should contain the function you want to call, say MyFunc() In cicode: Function MyFunc() IF (T1a = 1) THEN T2a=0; END END Rgds
  2. Read bit from Word CITECT

    Hello Here is what I use: To read bit 1 in Tag1 use: DigitalBit = ReadTagBit(Tag1,1) To write 1 to bit 1 in Tag1 WriteTagBit("Tag1",1,1) To write 0 to bit 1 in Tag1 WriteTagBit("Tag1",1,0) //////////// INT FUNCTION ReadTagBit(INT Tag, INT Bit) //Bits numbered 0-15 INT TagVal, Power; Power = Pow(2, Bit); IF Tag BITAND Power THEN TagVal = 1; ELSE TagVal = 0; END RETURN TagVal; END FUNCTION WriteTagBit(STRING Tag, INT Bit, INT Val) //Bits numbered 0-15 INT TagVal, Power, NewVAL, Stat; STRING STagVal; STagVal = TagRead(Tag); TagVal = StrToInt(STagVal); Power = Pow(2, Bit); Stat = ReadTagBit(TagVal,Bit); IF Val = 1 AND Stat = 0 THEN NewVal = TagVal + Power; TagWrite(Tag,NewVal); END IF Val = 0 AND Stat = 1 THEN NewVal = TagVal - Power; TagWrite(Tag,NewVal); END END
  3. Cicode Com Function

    Hello I made a bit of progress on this, most of the problem were due to my poor understanding of How the Com functions operate. This might be of use to someone out there as the help files are not great on this subject. It is a test routine reading time from an anonometer ( it uses NMEA ASCII) Call ReadVal() as an event every 2 sec ComData is a local variable string and ComVal is the same value as an integer If anyone has any recommendations on improving this code I would be interested in hearing from you To test copy this into hyperterminal: $GPGGA,183506,5320.8532,N,00612 FUNCTION ReadVal() INT A; STRING SRES,BufRES,VarRES,Char,Temp; ComData = ""; INT Length,hport,OKRES; hPort = ComOpen("Wind",0); OKRES = 0; WHILE OKRES = 0 DO Length = 128; ComRead(hport,BufRES,Length,5); TraceMsg(BufRES); IF Length > 0 THEN Temp = StrTrim(StrClean(BufRES)); OKRES = Process(Temp); END END ComClose(hport); END INT FUNCTION Process(STRING S) INT Pos; STRING A,B,C; Pos = StrSearch(0,S,"$GPGGA"); IF Pos <> -1 THEN A = StrMid(S,Pos + 7,4); ComData = A; IF A <> "" THEN ComVal = StrToInt(A); END RETURN 1; ELSE RETURN 0; END END
  4. Cicode Com Function

    Hello I am trying to interface an anonometer to Citect via a serial port. I have configured a device called "Wind" on com 7 I am trying to use the comread() function to read in a string of text. I can then decode the text string and then convert it to integer data. When I call the Wind() function, I can see the characters in the Debug window ((TraceMsg(sGPS_Buffer) displays this)) The tag TestTag is a local String, this remains blank when I run the application (I have it displayed in a graphics page). Has anyone any advice or recommendations? All I want to do is get the ASCII from the serial port and write it to a string, If someone can help with this I would be most grateful after that I can decode it. This is what I have tried so far (taken from a GPS program I found on the net); FUNCTION Wind() INT hGPS; STRING sPort = "Wind"; hGPS = ComOpen(sPort,0); IF hGPS = -1 THEN Prompt("Cannot open port "+ sPort); ELSE ComReset(hGPS); _Gps_Read(hGPS); ComClose(hGPS); END END FUNCTION _GPS_Read(INT hGPS) INT iReading_Not_valid = 1; INT iGPS_Length; INT iGPS_Error; INT iCR_Position; STRING sGPS_Buffer; STRING sGPS_String; INT i; INT cError = 1; WHILE iReading_Not_valid DO ! must set length as read modifies iGPS_Length = 128; iGPS_Error = ComRead(hGPS,sGPS_Buffer,iGPS_Length,60); TraceMsg(sGPS_Buffer); TestTag = sGPS_Buffer; IF iGPS_Error <> 7 THEN IF iGPS_Error = cError THEN Prompt("Error from port "+ IntToStr(iGPS_Error)); ComReset(hGPS); ELSE iCR_Position = StrSearch(0,sGPS_Buffer,CharToStr(10)); IF iCR_Position <> -1 THEN ! remove control characters and spaces from string sGPS_String = StrTrim(StrClean(sGPS_Buffer)); ! process GPS string iReading_Not_valid = _GPS_Process(sGPS_String); END END END END END INT FUNCTION _GPS_Process(STRING sGPS_String) REAL rTime; INT iGPS_Time_Position; STRING sHH; STRING sMM; STRING sSS; IF StrSearch(0,sGPS_String,"$GPVTG") <> -1 THEN Prompt("GPS Valid sattelite fixing obtained"); GPS_Time_Fix = 0; iGPS_Time_Position = StrSearch(0,sGPS_String,"$GPGGA"); IF iGPS_Time_Position <> -1 THEN ! get greenwich mean time sHH = StrMid(sGPS_String,iGPS_Time_Position + 7,2); sMM = StrMid(sGPS_String,iGPS_Time_Position + 9,2); sSS = StrMid(sGPS_String,iGPS_Time_Position + 11,2); rTime = sHH+sMM+sSS; RETURN 0; END END RETURN 1;
  5. GX Works

    Right, a little trick to look out for when importing IEC Developer function blocks. IEC Developer has an initial value field in the Global variable database, GX Works does not. If you import a project with initial values you will get this error but it wont tell you which records are at fault. The solution: In the Global variables screen, select the record in question ( if you dont know, select all of them) click cut, and then paste them back into the editor (This only copies the fields recognised by GX Works) Now write to the database. Everything compiles and works ok
  6. GX Works

    Hello I have added the attachment, I have looked at the function blocks in IEC developer, they are simple enough. If need be I should be able to modify them for GX Works. The catch is the Global variable error.
  7. GX Works

    Hello I am starting out in GX Works 2 (v1.24A) I have imported an IEC Developer program for CCLink V2 and VSD's When I try to compile the project I get the error " No. Result Data Name Class Content Error Code1 Error Global_Vars Global label check Invalid initial value of label C5004 " See the attached screen shot This seems to come from the global variables initial values but I don't see any where where I can adjust the initial value. The program works fine when compiled in IEC Developer v7.04 Any advice would be appreciated? Sorry here is the attatchement
  8. Ethernet communications with FX1n

    Hi Justin MX OPC is listed at £490 in NI, down south its a lot more expensive!!!! Yes you need it for each installation. Citect does work with FX3U and FX3U Enet module, I have set this up and it works fine. You can also use the FX3G with the FX3U-ENET module. Have a look in the Citect knowledge base, there are a few notes on Citect and Q/FX3 plc's What hmi did you use? If it is E1041 and above or GT15/16 you can bridge between the plc serial port and the ethernet port on the hmi Something to experiment with on a rainy day Regards Automaton
  9. Ethernet communications with FX1n

    Hi Justin You have generally 3 ways of connecting a SCADA to a plc. 1.Use driver provided by Scada manufacturer 2.Use OPC server 3. Use DDE (not commonly used nowadays) In Citect you have a lot of drivers included but other manufacturers supply drivers with their products too. The idea with OPC is this; OPC server manages the connection and updating of Tags. For the OPC to connect to a plc it needs a driver. The OPC connects to the plc via the configured driver. Your SCADA is an OPC client, It sends requests to the Server. The server sends the tag information back to the SCADA. The whole idea of OPC is this: Any major manufacturer of SCADA who is OPC compliant can connect to a certified OPC server irrespective of manufacturer ( brave words but this is the theory) This frees up competition in the SCADA market. The catch is you still need the drivers on the OPC server and some manufacturers will charge you for this. I don't think that Mitsubishi drivers are included in Kepware OPC but MX OPC does include the driver for your Ethernet module. Kepware will supply you with a suitable driver for this card. May be worth comparing the price of Kepware OPC + driver as opposed to Mitsubishi MXOPC. Personally the reason why I stick with Citect is because of the wide range of FREE drivers included. Getting back to your application, what is the main goal? FX on Ethernet is not cheap, but do you need it? The main reason for wanting Ethernet between plc and SCADA is quantity of data and speed of response. Unless you have a lot of data/Tags why don't you use the FX3G ( replacement of the FX1N and costs the same)) It has integrated USB if you plc is close to your SCADA this is a very cheap connection < £5 If you need longer distances you can get usb extenders up to 100m, these are around £80 @ 100m We have used them no problem with Citect HMI @300 Tags. Alternatively you can install a F1N 232 or 485 DB module in the FX1N and use this to link to the SCADA. Doing this removes the need for Ethernet hardware and allows you to use Citect integrated drivers. Regards Automaton
  10. Ethernet communications with FX1n

    Hi Justin I had a quick look at MX Component I think Crossbow is right, you will need a serial to ip address translator. Have a look at http://tibbo.com/downloads/soi.html You can then configure MX Component as a serial connection using the com port defined in Tibbo (com 15 for example). In Tibbo you map com 15 to 10.10.10.1 (your plc ip) Tibbo "tricks" MX Component into thinking that it is connected serially. This would probably work without MXCompont if you configured Citect to use a serial driver. From a ruggedness and reliability perspective I would still recommend OPC. Regards Automaton
  11. Ethernet communications with FX1n

    Hi Justin I used MX OPC but that costs a bit more than £300. You could look at other OPC manufacturers such as Keptware, there might even be some free open source OPC servers out there on the web. I use MX Component 3.12 for VB and plc applications but normally via serial interfaces, If you select Ethernet on the pc side of the wizard there is no FX option in the host side only Q cpu's(maybe that is included in version 3.13) Talk to the Mitsubishi guys in Dublin, they will be able to supply you with a functional demo version of both MX Component and OPC and you can try it before spending any money Regards Automation
  12. Ethernet communications with FX1n

    Hi Justin I have done an application with 3 FX1N's and Citect using MX OPC over ethernet. The FX2N Ethernet module is quite limited but does support OPC client functionality. Very easy to set up the OPC and FX1N Regards Automaton
  13. Citect Cicode Drop down menu

    This is a strange one If I write sBuf to a local variable and run the above code it works fine. It must be related to how the form and combobox objects are instantiated
  14. Citect Cicode Drop down menu

    Hello I am trying to make my own user login form using a drop down menu to select the user name The idea is 3 users, Operator, Supervisor and Engineer. The customer wants to be able to select the role from a combo box menu ( that's why I cant use the default screen), for ease of testing I have set all 3 roles with the same password of "Test" The code that I have tested here creates a pop up screen with a drop down menu no problem, the catch is that the value selected in the drop down menu is not updated when the Yes button is pressed ( the variable sBuf contains the default value of "Role" instead of the value that I selected in the drop down menu) I used the LoginForm command just so that you can see the value of sBuf when the Yes button is clicked. It seems that the combo box selection is not been written to sBuf even though I select it in the combo box Does anybody have any advice as to where I have gone wrong? Any help would be greatly appreciated STRING sBuf = "Role"; INT hForm; FUNCTION TestLog() STRING Msg; Msg = "User Name: " ; hForm = FormNew("",44,3,16); FormButton(15,1," Yes ",LoginNow,0); FormButton(24,1," No ",0,1); FormComboBox(2 ,2, 15, 5, sBuf, 1); FormAddList("Operator"); FormAddList("Supervisor"); FormAddList("Engineer"); FormRead(0); END INT FUNCTION LoginNow() LoginForm(sBuf,"Test"); RETURN 0; END
  15. Citect,Cicode Forms,

    Hi Fredrix Thanks for your reply. Looking at your code, what you say makes sense. For this project I ended up scrapping the Cicode forms and used a pop up form /Supergenie But I will try your method as I do find using Cicode forms great for quick simple Yes/No type forms. Regards Automaton