From aa5db713557c4974739a03af2836844328de02c9 Mon Sep 17 00:00:00 2001 From: Jan Michel Date: Fri, 30 Jun 2023 17:37:19 +0200 Subject: [PATCH] allow group=4 for common access to all outputs, fix current calculation --- atmega32u4/dcdc_mdc/mdc_powerboard.pl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/atmega32u4/dcdc_mdc/mdc_powerboard.pl b/atmega32u4/dcdc_mdc/mdc_powerboard.pl index 5d72fbe..5f9ae92 100755 --- a/atmega32u4/dcdc_mdc/mdc_powerboard.pl +++ b/atmega32u4/dcdc_mdc/mdc_powerboard.pl @@ -22,12 +22,12 @@ my $SEL_rw = 0; my $registers = { 'switch' => 0, 'adjust' => 1, - 'Vin' => 2, - 'Cin' => 3, + 'vin' => 2, + 'cin' => 3, 'temp' => 4, 'info' => 5, - 'Ioffset' => 6, - 'Vout' => 7 + 'ioffset' => 6, + 'vout' => 7 }; Getopt::Long::Configure(qw(gnu_getopt pass_through)); @@ -65,12 +65,12 @@ $SEL_board //= 0; $SEL_board = 0xff if $SEL_board == -1; $SEL_output = 0 unless defined $SEL_output && $SEL_output =~ /^\d$/; -die "Group number too high (0..3)" if $SEL_output > 3; +die "Group number too high (0..3,4)" if $SEL_output > 4; $SEL_channel = 0 unless defined $SEL_channel && $SEL_channel =~ /^\d$/; die "Channel number too high (0..1)" if $SEL_channel > 1; -if(defined $registers->{$SEL_register}) {$SEL_register = $registers->{$SEL_register};} +if(defined $registers->{lc($SEL_register)}) {$SEL_register = $registers->{lc($SEL_register)};} $SEL_register //= -1; die "Undefined register" unless ($SEL_register >= 0 && $SEL_register <= 7); @@ -134,7 +134,7 @@ sub PrintAnswerNice { printf "measured Voltage @ Input : %.3f Volt (RAW: 0x%x)\n", ($calc) , ($answ); } if ($command == 3) { # Current - my $calc = ($answ&0xFFF)/800.*2.5; # 800mV/A + my $calc = ($answ&0xFFF)/500.*2.5; # 500mV/A printf "measured Current @ Input : %.3f Ampere (RAW: 0x%x)\n", ($calc) , ($answ); } if ($command == 4) { # Temperature -- 2.43.0