txturbo

Members
  • Content Count

    12
  • Joined

  • Last visited

Community Reputation

0 Neutral

About txturbo

  • Rank
    Member
  1. txturbo

    Configuration file at startup

    Thanks, it's working now. 1. I got rid of the local debug = 2. I changed the file open from this private handle = file.Open(rootDirectory + "\Settings.json",1,,,1) private handle = file.Open(rootDirectory + "\Settings.json",,,1,,1) to this private handle = file.Open(rootDirectory + "\Settings.json",1,0,0,1) private handle = file.Open(rootDirectory + "\Settings.json",0,1,0,1)
  2. txturbo

    Configuration file at startup

    I have been trying to get this to work but I get an error. I changed the attributes on file open to replace the blanks from the example above with "0" but that did not seem to help. I tried to set up global variables to match the locals from the class as well. I created a test file. I set up a sequence named createClasses with this: class CSystem local debug = local string rootDirectory = "c:\daqfactory" local mySetting = 5 local AnotherSetting = 6 local string AStringSetting = "Some string" function saveSettings() try private string out = toJson() private handle = file.Open(rootDirectory + "\Settings.json",,1,,1) file.Write(handle, out) file.Close(handle) catch() ? strLastError endcatch endfunction function loadSettings() try private string in private handle = file.Open(rootDirectory + "\Settings.json",1,,,1) in = file.Read(handle) file.Close(handle) fromJson(in) catch("F0002") ? "Settings not found, creating new file" saveSettings() endcatch catch() ? strLastError endcatch endfunction endclass Then I run a start up sequence with this: createClasses() global gSys = new(CSystem) gSys.loadSettings() I get this error: C1000 Channel or function not found: startup Line 3 - Uncaught error in sequence startup sysloadtest.ctl
  3. txturbo

    Time since restart

    I am trying to display the time since last restart but I get a day added to my result: I set a value at restart then display this: FormatDateTime("D: %j H:%H M:%M S:%S",SysTime() -(v.time_of_last_restart[0])) How do I avoid the offset?
  4. Is it possible to use an inline if to enter one of two possible values within a variable value component action? So for example I have a variable value component that I use an inline if to select display of one of two values. I would like to be able to use the action side to enter the value as the same variable selected in the inline if statement used within the main expression. I tried to use the set to selection and enter the iff in the action channel but it's not writing the expected result. Can I write a sequence that will take the output of the popup box and use the quick sequence action? Sort of like using the value part of a conversion?
  5. I have an application that is used on more than one system. Each system has slightly different hardware but the user interface is the same. How can I use a configuration file to select the proper hardware depending on the system at startup?
  6. I have been updating some code in my application and want to understand if there is a downside to using a single serial loop and flags. As an example I have a stepper controller that uses serial coms. I have a sequence that runs continuously getting status information, position, and home flags. Other sequences run programs that move the lift when called. On some pages I use quick sequences to move the stepper. As an example, most buttons have something like this: if (!device.step_1.LockPort()) delay(0.5) continue endif device.step_1.Purge() try device.step_1.Write("+" + (v.lift_move(0)) + chr(13) + chr(10)) device.step_1.UnlockPort() catch() device.step_1.UnlockPort() ? strLastError delay(0.5) endcatch Sometimes when I used the buttons the UI can bog or flash the screen. I suspect this is due to the delay. I have decided to try a different approach using one main loop for the stepper and reading if flags have been set during the loop. Any buttons or sequences that need to interact with the stepper motor would set a variable and flag. Is there a downside to this approach? Example: private count = 6 while(1) if (!device.step_1.LockPort()) //throw("port in use!") delay(0.1) continue endif device.step_1.Purge() try device.step_1.Write("Z" + chr(13) + chr(10)) //read the lift position datain = device.step_1.ReadUntil(10) v.lift_pos.AddValue(right(datain,11)) count -- // this is used to slow down any reads that are non critical if (count == 0) device.step_1.Write("] 1" + chr(13) + chr(10)) // read the home flag datain = device.step_1.ReadUntil(10) lift_home.AddValue(strtodouble(right(datain,6))) delay(.05) device.step_1.Write("] 0" + chr(13) + chr(10)) // read the limit flag datain = device.step_1.ReadUntil(10) lift_limits.AddValue(strtodouble(right(datain,3))) count = 6 endif delay(0.07) if(lift_jog_plus_flag ==1) device.step_1.Write("+" + (v.lift_move[0]) + chr(13) + chr(10)) // used to jog the lift postiive lift_jog_plus_flag = 0 endif if(lift_jog_negative_flag ==1) device.step_1.Write("-" + (v.lift_move[0]) + chr(13) + chr(10)) // used to jog the lift negative lift_jog_negative_flag = 0 endif if(Lift_relative_flag ==1) device.step_1.Write("R" + (v.lift_rel[0]) + chr(13) + chr(10)) // used to move the lift relative Lift_relative_flag = 0 endif if(lift_move_flag ==1) if(v.panel_lift_move[0] > 0) device.step_1.Write (("+") + (v.panel_lift_move[0]) + chr(13) + chr(10)) // used from the main page to move the lift + with presets else device.step_1.Write (("-") + (v.panel_lift_move[0]) + chr(13) + chr(10)) // used from the main page to move the lift - with presets endif lift_move_flag = 0 endif if(lift_stop_flag == 1) device.step_1.Write(CHR(27) + chr(13) + chr(10)) lift_stop_flag = 0 endif if(lift_zero_flag == 1) device.step_1.Write("R" + (0) + chr(13) + chr(10)) // used to zero the lift lift_zero_flag = 0 endif if(home_lift_flag == 1) device.step_1.Write("G" + chr(13)) // used to home the lift home_lift_flag = 0 endif device.step_1.UnlockPort() catch() device.step_1.UnlockPort() ? strLastError delay(0.1) //throw() endcatch delay(0.1) endwhile Thanks!
  7. Is it possible to look at a section an image, say 100 X 100 pixels and detect a change in color? For example I have an application where I have a camera that looks at a process in a plasma chamber. Sometimes the process goes out of control and grows something that glows orange. This happens slowly and always in the same location. I would like to isolate the section of the image, X pixels by Y pixels and record the RGB value of each as a reference. If some % of the values change from the given reference set a flag. Is something like this possible? I know that a machine vision system does this sort of thing but I already have a camera running in DF and I would prefer to use DF.
  8. I have been able to duplicate this. My workspace tree disappears and the only way I have found to restore it is to restart daqfactory. I am running 16.2 Build 2279. If I group and ungroup a few times the tree disappears, the popup for the workspace is their but it is blank.. Any ideas how to restore without restarting daqfactory?
  9. txturbo

    Problem With Autotuning

    I am having a problem with autotuning. When I start the autotune process on my PID loop the PV just stops. it never moves. Is there a set of conditions that needs to be met for the autotune process to work? Thanks...
  10. txturbo

    Modbus Functions 22 And 23 And Lrc

    Thanks for the response. There is not a bandwidth problem, the device is old and seems to be limited in it's ability to respond to commands. This is from the communication spec of the device: 5. Current usage supports Function Codes 23 (Read/Write 4X registers) and 22 (Mask Write 4X registers). 6. Each unit will provide communication for 1..16 (i.e. Channels). Each channel will be associated with an Input and Output Segment in 4X memory. Input Segments are contiguous in 4X memory and are in Channel Number order. Similarly Output Segments are contiguous in 4X memory and are in Channel Number order. The Modbus master will read locations in the Input Segments and will write and read locations in the Output Segments using functions 22 and 23. 7. The Modbus master, will determine the rate the various parts of 4X memory will be read and written (using Modbus functions 22 and 23). Are you suggesting that I can use the MODBUS ACSII Protocol? If so what I/O type would work?
  11. txturbo

    Modbus Functions 22 And 23 And Lrc

    I wanted to use an existing MODBUS ASCII Protocol to communicate with a device but no I/O type exists for the functions 22 and 23. SO I started to make a custom protocol. I can get the communication to work if I know the exact string to pass including the LRC. I assume that the MODBUS ASCII Protocol that is per configured can do this? Is it possible to edit this protocol so I can add function 22 and 23?
  12. I am new to daqfactory, having fun with my first real program. So far I have managed to get most of my program working, with the help of the manual and looking up answers on the forum. Now I am a bit stuck. My system uses a MKS 651 Pressure controller connected via a USB to serial adapter (com2) and an Omega IR2C temperature controller on the native com port (1). The computer is an IBM R51 Centrino laptop. When I poll the 651 controller using the sequence(s) below it runs for a minute then gives an error: C1136 Timeout: tvalvestatus Line 21 - Uncaught error in sequence tvalvestatus I have tried to add delays, increase the port timeout, change the speed of the communications but it does not seem to make any difference. I have also tried to adjust the channel number in the channel parameters. I am not sure if that makes a difference or not. I can’t find any reference to the channel number within the MKS 651 serial commands. I also notice that when the sequence is running and I look at the channel table the top line is updated correctly with the value but sometimes it puts the correct value down a line or two and puts NaN on the top. It’s strange because it’s not scrolling down. I have tried both sequences and they give the same error. Sequence 1 private string datain private data While(1) device.mks651.purge() device.mks651.write("R6" + chr(13) + chr(10)) datain = device.mks651.readUntil(10) data = strToDouble(mid(datain,3, 1000)) tvalvepos.addValue(data) device.mks651.write("R5" + chr(13) + chr(10)) datain = device.mks651.readUntil(10) data = strToDouble(mid(datain,3, 1000)) tvalvepress.addValue(data) device.mks651.write("R37" + chr(13) + chr(10)) datain = device.mks651.readUntil(10) data = strToDouble(mid(datain,1, 1000)) status651.addValue(data) delay(1) endwhile Sequence 2 private string datain1 private data1 private string datain2 private data2 private string datain3 private data3 While(1) device.mks651.purge() device.mks651.write("R6" + chr(13) + chr(10)) datain1 = device.mks651.readUntil(10) data1 = strToDouble(mid(datain1,3, 100)) tvalvepos.addValue(data1) delay(.5) device.mks651.write("R5" + chr(13) + chr(10)) datain2 = device.mks651.readUntil(10) data2 = strToDouble(mid(datain2,3, 100)) tvalvepress.addValue(data2) delay(.5) device.mks651.write("R37" + chr(13) + chr(10)) datain3 = device.mks651.readUntil(10) data3 = strToDouble(mid(datain3,4, 100)) status651.addValue(data3) delay(1) endwhile Any ideas? Thanks!!