전압, 전류를 측정할 수 있는 4채널 AD입력 모듈, Dip스위치 설정으로 전류(0~20mA) 또는 전압(0~10V) 입력을 선택할 수 있습니다.
var cfheader0 = Cfheader.Instances[0]; var analogInputModule0 = cfheader.AnalogInputModules[0]; // Channel 0 will perform 2 conversions first, // then Channel 1 will perform 2 conversions, // channels 2 and 3 will be immediately skipped, // then back to channel 0. analogInputModule0.Channels[0].NumberOfConversions = 2; analogInputModule0.Channels[1].NumberOfConversions = 2; analogInputModule0.Channels[2].NumberOfConversions = 0; analogInputModule0.Channels[3].NumberOfConversions = 0;
채널의 상태는 RawValue라는 디지털 원시 값, 전압(Voltage), 또는 전류(Current)로 읽을 수 있습니다. Voltage와 Current 속성은 RawValue 속성으로부터 계산됩니다. 보정(Calibration)이 필요할 수 있습니다.
var cfheader0 = Cfheader.Instances[0]; var analogInputModule0 = cfheader0.AnalogInputModules[0]; cfheader0.Open(); while (true) { cfheader0.Sync(); foreach (var c in analogInputModule0.Channels) { Console.WriteLine($"Channel {c.Address,2}: {c.RawValue,8} {c.Voltage,8:F2}V {c.Current,8:F2}A"); } }
채널의 모든 NumberOfConversions가 완료되고 Sync를 통해 읽힐 때마다 ConversionCompleted 이벤트가 발생합니다. 이 이벤트는 채널의 상태(RawValue)가 변경되지 않았더라도 항상 발생합니다.
반면, RawValue 값이 변경되어 전압(Voltage) 및 전류(Current) 속성에도 영향을 줄 경우 이를 감지하려면 RawValueChanged 이벤트를 사용하세요.
var cfheader0 = Cfheader.Instances[0]; var analogInputModule0 = cfheader0.AnalogInputModules[0]; foreach(var channel in analogInputModule0.Channels) { channel.ConversionCompleted += c => { Console.WriteLine($"Channel {c.Address,2}: {c.RawValue,8} {c.Voltage,8:F2}V {c.Current,8:F2}A"); }; } cfheader0.Open(); while (true) { cfheader0.Sync(); }
sing ComfileTech.Cfnet.Cfheader; var cfheader0 = Cfheader.Instances[0]; var analogInputModule0 = cfheader0.AnalogInputModules[0]; var CFADC_0_CH0 = analogInputModule0.Channels[0]; cfheader0.Open(); while (true){ cfheader0.Sync(); Console.WriteLine($"Channel {CFADC_0_CH0.Address,2}: {CFADC_0_CH0.RawValue,8} {CFADC_0_CH0.Voltage,8:F2}V {CFADC_0_CH0.Current,8:F2}A"); }
고객님께서 개발 중이신 소스 코드는 기술 지원 대상에 포함되지 않습니다. 제품이 이상이 있다고 판단되시는 경우, 제품 자체를 저희 회사로 보내주시기 바랍니다. 저희가 만든 소스와 지그로 테스트 한뒤 이상 유무를 판단해서 이상이 발견된 경우 조치해드리고 있습니다.