File I/O

Discuss issues and ideas you have to configuring displays with PowerVision
andymartyn
Posts: 25
Joined: Wed Oct 29, 2014 4:51 am

File I/O

Post by andymartyn » Wed Jun 17, 2015 5:07 am

I am looking to read and write some resistance values to a file in order to persist calibration values for a analog inputs such as fuel sender, air brakes etc and have some questions.

It looks like the file object is used for saving to/from the non-volatile memory but am I correct in saying that the version in the PV780 isn't the same as that in which you might see if you look online? What I mean is operations such as writeDouble() don't exist, are we limited purely to string reading/writing?

I'm thinking, I guess, of having some form of calibration list in a CSV format and it was how you would read/write and parse the file. Writing is simple but it is the reading aspect and how you tokenize a CSV

So could have something like this:

Code: Select all

10,0
25,0.5
35,1.5
to map resistance of an analog input to a pressure value. Wasn't sure if I would have multiple config files or a single file and how you would then differentiate but I once I know how to parse I could work this out better

When copying from/to a USB I have done this without mounting the USB and it worked fine, so another question is how should you do this? Is mounting optional, mandatory or best practice?
stalley
Enovation Controls Development
Enovation Controls Development
Posts: 618
Joined: Tue Mar 18, 2014 12:57 pm

Re: File I/O

Post by stalley » Wed Jun 17, 2015 1:59 pm

Hello andymartyn,

The only file type supported is text files, binary files are not. You are correct, you cannot use the writeDouble() to a file.

If you look at the Function Reference in a script, there are several string manipulation functions under the Central Control Module(CCM) section that will help parse the data from string into a numeric value.

The USB mount() is there for backward compatibility. It works, it isn't required though since it is incorporated into the embedded firmware.

If you need to have different data curves for your inputs and the user needs to be able to select which one is appropriate for their system, you might want to look at creating Pre Defined Curves and multiple IO Definitions. The analog inputs are designed to make it easier to be able to have multiple types (definitions) of the input uses so that the user can select at run time what type of sensor is being used. You can look at it yourself by switching the MPC20 Controller configuration to the MPC20 (Advanced).

I don't have a good example of this on a color display, but the Standard MPC20 configuration that comes with PowerVision Configuration Studio has many IO Definitions for each analog input. Let me know if this is what you need to accomplish and I can try to provide more information about how it can work.
Sara Talley
Software Engineer
Enovation Controls
andymartyn
Posts: 25
Joined: Wed Oct 29, 2014 4:51 am

Re: File I/O

Post by andymartyn » Thu Jun 18, 2015 1:03 am

I have seen the predefined curves but could not see how you would apply these onto IX32 analog inputs. If it is possible I would certainly be interested in knowing about it

There appears more configuration on the analog inputs for the built-in analog inputs compared to those on the IX32. For the IX32 all I saw was that I received the values of the mapped variable as voltage and then I had to convert this voltage back into the resistance to mapo onto the curve I set up within scripting, is this the approach?

It was believed the 2.2k pull-up on the resistive input of the IX32 was too high for our particular needs (We have resistance range of 3.2 to 88 on the fuel sender) so were looking to use a 390 resistor and use the 5V output on the IX32 to create our own resistive circuit. However I am now wondering if this is correct and maybe the 2.2 would work for these low resistance ranges?

Any help appreciated,
Andy
stalley
Enovation Controls Development
Enovation Controls Development
Posts: 618
Joined: Tue Mar 18, 2014 12:57 pm

Re: File I/O

Post by stalley » Thu Jun 18, 2015 10:05 am

Hello,

You are correct, the IO Definitions/Pre Defined Curves/Selectable definitions are for the built in analog inputs, not the IX32. :(

You are using the appropriate way to configure the inputs on the IX32. The display's inputs are raw A/D values, but the IX32 gives voltage values.

According to application engineers here,
  • A 33-240 ohm sender has been mapped to the IX32 and received enough resolution.
    The 5V output has a 50mA max output.
    If you use an analog input on the display, it only uses a 400 ohm pull up which will give you a lot more resolution.
Keep up the good work!
Sara Talley
Software Engineer
Enovation Controls
andymartyn
Posts: 25
Joined: Wed Oct 29, 2014 4:51 am

Re: File I/O

Post by andymartyn » Tue Jun 23, 2015 2:26 am

Thanks for the help. Not having the pre-defined curves isn't so bad, just needs a bit more thought as to how to do it but scripting is my friend here

I have connected up to the fuel sender now and am reading the voltages and mapping back into resistances using a set of calibrated points and interpolating between them and it's reading some values. Whether accurate needs some further investigation. I think I should be able to read the calibration data via scripting using file I/O so that should make it configurable

The 2.2k pull-up in the IX32 doesn't give as much resolution as we have discussed but it does allow a reasonable amount. Whether it is acceptable is a discussion point with the customer

I now just need to learn a bit more about the available AngelScript and how best to use it within the PV780 to determine the best approach