Move potentiometer pin model to r0, wiper, r1, and remove flipping code.
Fixes https://gitlab.com/kicad/code/kicad/issues/13741
This commit is contained in:
parent
200bf696af
commit
8b03c093f9
|
@ -1394,7 +1394,24 @@ void SIM_MODEL::MigrateSimModel( T_symbol& aSymbol, const PROJECT* aProject )
|
|||
|| aSymbol.FindField( SIM_PINS_FIELD )
|
||||
|| aSymbol.FindField( SIM_PARAMS_FIELD ) )
|
||||
{
|
||||
// Has a V7 model field -- skip.
|
||||
// Has a V7 model field.
|
||||
|
||||
// Up until 7.0RC2 we used '+' and '-' for potentiometer pins, which doesn't match
|
||||
// SPICE. Here we remap them to 'r0' and 'r1'.
|
||||
if( T_field* deviceType = aSymbol.FindField( SIM_TYPE_FIELD ) )
|
||||
{
|
||||
if( deviceType->GetShownText().Lower() == wxS( "pot" ) )
|
||||
{
|
||||
if( T_field* pins = aSymbol.FindField( SIM_PINS_FIELD ) )
|
||||
{
|
||||
wxString pinMap = pins->GetText();
|
||||
pinMap.Replace( wxS( "=+" ), wxS( "=r1" ) );
|
||||
pinMap.Replace( wxS( "=-" ), wxS( "=r0" ) );
|
||||
pins->SetText( pinMap );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2022 Mikolaj Wielgus
|
||||
* Copyright (C) 2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2022-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -41,37 +41,6 @@ std::string SPICE_GENERATOR_R_POT::ModelLine( const SPICE_ITEM& aItem ) const
|
|||
}
|
||||
|
||||
|
||||
std::string SPICE_GENERATOR_R_POT::ItemPins( const SPICE_ITEM& aItem ) const
|
||||
{
|
||||
std::string result;
|
||||
int ncCounter = 0;
|
||||
|
||||
wxCHECK( GetPins().size() == 3, "" );
|
||||
|
||||
// Swap pin order so that pos=1 is +, and pos=0 is -.
|
||||
std::vector<std::reference_wrapper<const SIM_MODEL::PIN>> inverted( GetPins() );
|
||||
std::swap( inverted[0], inverted[2] );
|
||||
|
||||
for( const SIM_MODEL::PIN& pin : GetPins() )
|
||||
{
|
||||
auto it = std::find( aItem.pinNumbers.begin(), aItem.pinNumbers.end(),
|
||||
pin.symbolPinNumber );
|
||||
|
||||
if( it != aItem.pinNumbers.end() )
|
||||
{
|
||||
long symbolPinIndex = std::distance( aItem.pinNumbers.begin(), it );
|
||||
result.append( fmt::format( " {}", aItem.pinNetNames.at( symbolPinIndex ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
result.append( fmt::format( " NC-{}-{}", aItem.refName, ncCounter++ ) );
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
std::string SPICE_GENERATOR_R_POT::TunerCommand( const SPICE_ITEM& aItem,
|
||||
const SIM_VALUE_FLOAT& aValue ) const
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2022 Mikolaj Wielgus
|
||||
* Copyright (C) 2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2022-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -35,7 +35,6 @@ public:
|
|||
using SPICE_GENERATOR::SPICE_GENERATOR;
|
||||
|
||||
std::string ModelLine( const SPICE_ITEM& aItem ) const override;
|
||||
std::string ItemPins( const SPICE_ITEM& aItem ) const override;
|
||||
std::string TunerCommand( const SPICE_ITEM& aItem, const SIM_VALUE_FLOAT& aValue ) const override;
|
||||
};
|
||||
|
||||
|
@ -48,7 +47,7 @@ public:
|
|||
const PARAM* GetTunerParam() const override { return FindParam( "pos" ); }
|
||||
bool HasPrimaryValue() const override { return true; }
|
||||
|
||||
std::vector<std::string> GetPinNames() const override { return { "+", "wiper", "-" }; }
|
||||
std::vector<std::string> GetPinNames() const override { return { "r0", "wiper", "r1" }; }
|
||||
|
||||
private:
|
||||
static const std::vector<PARAM::INFO> makeParamInfos();
|
||||
|
|
|
@ -102,8 +102,8 @@ BOOST_AUTO_TEST_CASE( Potentiometers )
|
|||
{
|
||||
TestNetlist( "potentiometers" );
|
||||
TestOpPoint( 0.5, "V(/out1)" );
|
||||
TestOpPoint( 0.3, "V(/out2)" );
|
||||
TestOpPoint( 0.1, "V(/out3)" );
|
||||
TestOpPoint( 0.7, "V(/out2)" );
|
||||
TestOpPoint( 0.9, "V(/out3)" );
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue