General Input Logic to implement

Discussion in 'General Discussion' started by Arielis, Jan 24, 2012.

  1. Arielis

    Arielis

    Joined:
    Jan 16, 2012
    Messages:
    45
    Likes Received:
    0
    Location:
    London
    Hello,

    I know that I am not on the good part of the forum but I can`t post on the logic one.

    I would like to get the current value of the voltage of the general input. Exactly, I send 0 to 10V to the Channel of the General Input and I am trying to get this value. How to get the value that we can see on the "Show Current level" en Volts. I mean I there isn`t any group address for this channel, and the function:

    GetUnitParameter(Network, UnitAddress, ParameterType) with ptVoltage, Voltage (Volts) deal only with the output C-Bus 2 Output Units.

    I`ll continue to find it but if anyone have an idea.

    Thanks,
     

    Attached Files:

    Arielis, Jan 24, 2012
    #1
  2. Arielis

    ChrisJC

    Joined:
    Jan 21, 2012
    Messages:
    53
    Likes Received:
    0
    Location:
    Edmonton Qld
    don't know if this'll help but.....

    On you GI unit there is a C-Bus group being driven by the 0-10V input. It's level will be 0V = 0% and 10V = 100%. If you write logic to sniff the level,

    VARIABLE
    Sniff_Level_Int : Integer;
    MODULE
    Sniff_Level_Int := "GetCBusLevel("Input Level");

    then you can do you conversions with code do bring it to a voltage which would be dividing the percentage by 10. I wont work that code out for you but to me that would be the principle.

    Check what curve is set on the GI Unit for that input. I'm pretty sure that 0-10V is a flat curve but I cannot remember. If it's not your conversion will be a pretty difficult one.

    Hope that this spurs your thinking.
     
    ChrisJC, Jan 24, 2012
    #2
  3. Arielis

    Arielis

    Joined:
    Jan 16, 2012
    Messages:
    45
    Likes Received:
    0
    Location:
    London
    Thanks, I `ll try it shortly.

    Exactly, what I want to do is because the curve doesn`t work, on my input:


    1. The 0V = 100% and the 10V = 0%.
    2. The code could be a function of y=-10x+100
    3. My actual process: - Get the input voltage in GlobalVariable
    - GlobalVariable *(-10) + 100
    - SetLightingLevel(Group, GlobalVariable)
     
    Arielis, Jan 25, 2012
    #3
  4. Arielis

    Arielis

    Joined:
    Jan 16, 2012
    Messages:
    45
    Likes Received:
    0
    Location:
    London
    Is there a difference if the GetCbusLevel("Input Level") is defined differently in the help?

    GetCBusLevel(Network, Application, GroupAddress)
     
    Arielis, Jan 25, 2012
    #4
  5. Arielis

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    Set the General Input Unit to use the measurement application. It will then transmit the value in volts on C-Bus.

    The measurement application does not use "group addresses".

    This is reading the C-Bus voltage. If you have the General Input Unit transmitting on the measurement application, then you will need to use the Measurement Application in-built System IO Variables to read this data.

    If this is not clear, I will post a more complete explanation of it all.
     
    Darren, Jan 25, 2012
    #5
  6. Arielis

    Arielis

    Joined:
    Jan 16, 2012
    Messages:
    45
    Likes Received:
    0
    Location:
    London
    I have one error on my code:

    Error C129 at line 32:50 - Type conflict of operands

    Why I have this error if all of theses values are integer.

    Code:
    if GetUnitParameter(254,3,ptVoltage) then      {get the value of the voltage on the input 3 of the general input device}
    {1.The network is 243, the unit address of the general input is 3 and the variable that I want to get is ptVoltage already defined}
    
    begin
    [COLOR="Red"]OutputLevel := (GetUnitParameter(254,3,ptVoltage) * (- 10));[/COLOR]
    {2.This variable is multiplied by (-10) and stocked in the OutputLevel variable}  
    OutputLevel := Round(OutputLevel + 100); 
    {3.100 is added to this variable and round the value}
    SetLightingLevel("Group 1 - Generic", OutputLevel, "0s");
    {4.The LightingLevel is setted to OutputLevel}
    end;
    
    
    {1. ptVoltage= 1.3
     2. OutpulLevel= 1.3 * (-10)= -10.3
     3. OutputLevel= 100 - 10.3=89.7
     3. OutputLevel= 90
     4. Lighting Level on the channel 1 of the DSI gateway is OutputLevel=90%}
    Here is the code for the curve that I am trying to program.
     

    Attached Files:

    Arielis, Jan 25, 2012
    #6
  7. Arielis

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    Actually, you have a lot more than one error.

    As described in my previous post, the function GetUnitParameter(254,3,ptVoltage) does not get the input voltage measurement from the general input unit (unit 3 in this case). It is reading the C-Bus voltage at unit 3.

    Use the measurement application as is recommended and it will all work nicely.
     
    Darren, Jan 25, 2012
    #7
  8. Arielis

    Arielis

    Joined:
    Jan 16, 2012
    Messages:
    45
    Likes Received:
    0
    Location:
    London
    Arielis, Jan 25, 2012
    #8
  9. Arielis

    Arielis

    Joined:
    Jan 16, 2012
    Messages:
    45
    Likes Received:
    0
    Location:
    London
    I used the Measurement Application, and you can see the screenshot below. I can see the value send to the channel. This value is only displayed on the log for the moment when I activate the broadcast functionnality on the General Input. I saw that the delay min. have to be set to 30s, hope that we can change that to a value to instantly because I need that my application reply instantly.

    My settings are:
    General Input: Network: 254, Address: 4, Channel: 3 physic and channel 2 on the software.

    And I`d corrected the logic with the last informations and that`s works on the log only when I set a lighting value of 100% for example instead of OutputLevel1

    But when I write
    it writes a error: "Error in type of standard function parameter"

    I`ve tried to convert the value with the function PercenttoLevel but I am not sure where come from the error.


    What is OID on the Log report? Why nothing is written after it?
    How can we see the OutputLevel and OutputLevel1 on the log to be sure that my program do the calculation that I want?

    On the log below we can see the exact value captured by the input 7294.10-3 but nothing about the OutputLevel.
     

    Attached Files:

    Last edited by a moderator: Jan 26, 2012
    Arielis, Jan 26, 2012
    #9
  10. Arielis

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    You should set the General Input Unit to send a new measurement message when the value changes by a certain amount (say 1%) or at a regular interval (around 1 minute). That way you will get a message as soon as the level changes, but will not flood C-Bus with messages at other times.


    Is OutputLevel1 an integer variable?

    Ignore the OID - it is only used by C-Gate and ToolKit.

    There are two options:
    1. Enable the Send WriteLn output to Log option in the logic editor; or
    2. Use the LogMessage logic function
     
    Darren, Jan 26, 2012
    #10
  11. Arielis

    Arielis

    Joined:
    Jan 16, 2012
    Messages:
    45
    Likes Received:
    0
    Location:
    London
    Ok, I understand where was the error about the OutputLevel1. Actually, it was an integer value but the OutputLevel has to be an Real value.
    I used the LogMessage and had already modified the option of the Logic but nothing is displayed. That`s not the most important.

    That I would like to understand is why the procedure don`t apply the different operations. I mean I can see on the Log report, the value of the input Voltage that I send. But, the value of the lighting group are not inversed. The 0V still stay on 0% for the group 249, on the lighting Application 56. So May be, the function SetLightingLevel don`t receive the OutputLevel1 in parameter.

    I took a screenshot of the log and that I can see is when I create an icon on the PICED to control the lighting channel:
    to 13:17:10 -> Set Channel On (User click) the lighting on reply on the source unit=1.

    Is there another method to know if the parameter in the SetLightingLevel is well implemented?

    Regards,
     

    Attached Files:

    Last edited by a moderator: Jan 27, 2012
    Arielis, Jan 27, 2012
    #11
  12. Arielis

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    The SetLightingLevel function definitely does work properly.

    I see that you are multiplying the voltage by -10000, rather than by -10.

    You are not logging the value of the output level, but the text "OutputLevel".

    Also you have not converted the value from percent to a level.

    I would suggest doing the code something like this:

    Code:
    Procedure Affine;
    begin
      OutputLevel := GetRealIBSystemIO("Measurement App Real Value",254,3,2);
      WriteLn('OutputLevel=', OutputLevel);
      OutputLevel1 := PercentToLevel(Round(100 - 10 * OutputLevel));
      WriteLn('OutputLevel1=', OutputLevel);
      SetLightingLevel(249,OutputLevel1,1);
    end; 
    Make sure you enable the logic debug messages in the log. Remove the WriteLn when it all works.

    How often are you calling procedure Affine? Make sure you don't do it more than every few seconds or you will flood C-Bus with messages. Alternatively, add some extra code to only set the lighting group when it changes.

    You have a Monitor measuring the C-Bus voltage on unit 3. You should remove that unless it is really needed.
     
    Darren, Jan 27, 2012
    #12
  13. Arielis

    Arielis

    Joined:
    Jan 16, 2012
    Messages:
    45
    Likes Received:
    0
    Location:
    London
    I`ve multiplied the voltage by -10000 because the voltage in in mV when I am in the log display.
    I haven`t converted the value because it`s written on the help that I can use the percent.


    I did it but I don`t see OutputLevel : xxx ??? May be that`s the software.

    That`s true. I was just thinking to be sure that`s works before.

    Ok.


    Thanks, but nothing else happen. I mean the calculation isn`t implemented. I modified the function to

    Code:
      
      SetLightingLevel(249,PercentToLevel(Round(100 - 10 * OutputLevel)),1);
    
    
    The only thing that I can see is on the log

    Set Channel1 to 34% for example. That mean that the value is sent to the Lighting function but the calculation isn`t realized.

    Are my parameters of the general input are right?

    Regards,
     

    Attached Files:

    Arielis, Jan 30, 2012
    #13
  14. Arielis

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    According to your log, it is transmitting in volts (for example 7294E-3 = 7.294V). I recall that there is some issue with the scaling of the General Input Unit, but I don't remember details.

    You can use a constant in percent like:

    SetLightingLevel(249, 50%, 1);

    because the compiler turns 50% into a level of 127 automatically. If you do this:

    SetLightingLevel(249,OutputLevel1,1);

    the value of OutputLevel1 must be a level, not a percent.

    I am not aware of any problems with logging the WriteLn messages. It is working for me.

    It would help if you could post an extract of the log showing what is happening.
     
    Darren, Jan 31, 2012
    #14
  15. Arielis

    Arielis

    Joined:
    Jan 16, 2012
    Messages:
    45
    Likes Received:
    0
    Location:
    London
    Darren,

    Well done and thanks you very much for your explications and help. The prog works correctly.

    Regards,
     
    Arielis, Jan 31, 2012
    #15
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.