Go Back   Home > Forums > >
Home Forums Rules Articles diyAudio Store Blogs Gallery Wiki Register Donations FAQ Calendar Search Today's Posts Mark Forums Read

Software Tools SPICE, PCB CAD, speaker design and measurement software, calculators

LTspice - limiting the number of decimals
LTspice - limiting the number of decimals
Please consider donating to help us continue to serve you.

Ads on/off / Custom Title / More PMs / More album space / Advanced printing & mass image saving
Reply
 
Thread Tools Search this Thread
Old 25th December 2017, 01:20 PM   #1
SSassen is offline SSassen  Netherlands
diyAudio Member
 
SSassen's Avatar
 
Join Date: Mar 2005
Location: Beta Zeticuly
Default LTspice - limiting the number of decimals

Alright, can't seem to figure this one out, not helped by the fact my Google-Fu is not what it used to be due to excessive intake of sugary treats (it is Christmas afterall).

I have a schematic drafted where I want to label a number of nodes with their DC voltages in a transient analysis.

I do this by simply left clicking on the nodes in question, et voila, the DC voltage shows up. However, it shows up formatted with 5 decimal places, which is a little too much. I'd like to round that off to one or two decimal places.

If I however right click the node and add the expression 'round(V(a1))' to round off the voltage at node 'a1' it rounds off to no decimal numbers, which in my case means that 1.38798V is rounded to 1V, that's not what I'm after, I'd like to see either 1.4V or 1.39V.

Any of you fine gentlemen know how to accomplish this undoubtedly trivial feat? Thanks and Merry Christmas!
__________________
Mediocre is not my middle name.
  Reply With Quote
Old 25th December 2017, 01:35 PM   #2
jazbo8 is offline jazbo8
diyAudio Moderator
 
jazbo8's Avatar
 
Join Date: Jan 2011
Location: In Transient
LTspice - limiting the number of decimals
Try round(V(a1)*1000k)/1000k.
  Reply With Quote
Old 25th December 2017, 01:38 PM   #3
SSassen is offline SSassen  Netherlands
diyAudio Member
 
SSassen's Avatar
 
Join Date: Mar 2005
Location: Beta Zeticuly
Quote:
Originally Posted by jazbo8 View Post
Try round(V(a1)*1000k)/1000k.
Thanks, but no, still shows as 1.38987V.
__________________
Mediocre is not my middle name.
  Reply With Quote
Old 25th December 2017, 01:39 PM   #4
SSassen is offline SSassen  Netherlands
diyAudio Member
 
SSassen's Avatar
 
Join Date: Mar 2005
Location: Beta Zeticuly
Ha! This seems to work, but looks like a bit of a cumbersome workaround?

round(V(a2)*0.01k)/0.01k
__________________
Mediocre is not my middle name.
  Reply With Quote
Old 25th December 2017, 01:40 PM   #5
jan.didden is offline jan.didden  Europe
diyAudio Member
 
jan.didden's Avatar
 
Join Date: May 2002
Location: Westende Resort, BE coast
Quote:
Originally Posted by SSassen View Post
Alright, can't seem to figure this one out, not helped by the fact my Google-Fu is not what it used to be due to excessive intake of sugary treats (it is Christmas afterall).

I have a schematic drafted where I want to label a number of nodes with their DC voltages in a transient analysis.

I do this by simply left clicking on the nodes in question, et voila, the DC voltage shows up. However, it shows up formatted with 5 decimal places, which is a little too much. I'd like to round that off to one or two decimal places.

If I however right click the node and add the expression 'round(V(a1))' to round off the voltage at node 'a1' it rounds off to no decimal numbers, which in my case means that 1.38798V is rounded to 1V, that's not what I'm after, I'd like to see either 1.4V or 1.39V.

Any of you fine gentlemen know how to accomplish this undoubtedly trivial feat? Thanks and Merry Christmas!
Sander I think it should be round(V(a1),2) . Does that work?

BTW, my latest install of LTspiceXVII crashes every 10 minutes or so. On two different machines, a laptop and a PC, both running W10 Pro. Anybody seen this too, know why?

Jan
__________________
Cable: a potential source of trouble interconnecting two other potential sources of trouble - Erik Margan
Linear Audio pubs and articles . The SilentSwitcher now at diyaudio store SilentSwitcher. Keeping in touch with SY.
  Reply With Quote
Old 25th December 2017, 01:41 PM   #6
jazbo8 is offline jazbo8
diyAudio Moderator
 
jazbo8's Avatar
 
Join Date: Jan 2011
Location: In Transient
LTspice - limiting the number of decimals
The x1000k seems to work with current reading but not voltage.
  Reply With Quote
Old 25th December 2017, 01:51 PM   #7
SSassen is offline SSassen  Netherlands
diyAudio Member
 
SSassen's Avatar
 
Join Date: Mar 2005
Location: Beta Zeticuly
Quote:
Originally Posted by jan.didden View Post
Sander I think it should be round(V(a1),2) . Does that work?
No, unfortunately not, syntax error.

Quote:
Originally Posted by jan.didden View Post
BTW, my latest install of LTspiceXVII crashes every 10 minutes or so. On two different machines, a laptop and a PC, both running W10 Pro. Anybody seen this too, know why?
Using W10 Pro (64bit) here too, have not had it crash yet (fingers crossed).
__________________
Mediocre is not my middle name.
  Reply With Quote
Old 26th December 2017, 07:50 AM   #8
jan.didden is offline jan.didden  Europe
diyAudio Member
 
jan.didden's Avatar
 
Join Date: May 2002
Location: Westende Resort, BE coast
Quote:
Originally Posted by jazbo8 View Post
The x1000k seems to work with current reading but not voltage.
Try .option numdgt = 3

Default, numdgt = 6.
Historically "numdgt" was used to set the number of significant figures used for output data. In LTspice, if "numdgt" is set to be > 6, double precision is used for dependent variable data.

Found it in here: Linear Audio | your tech audio resource ;-)

Jan
__________________
Cable: a potential source of trouble interconnecting two other potential sources of trouble - Erik Margan
Linear Audio pubs and articles . The SilentSwitcher now at diyaudio store SilentSwitcher. Keeping in touch with SY.
  Reply With Quote
Old 26th December 2017, 07:57 AM   #9
jazbo8 is offline jazbo8
diyAudio Moderator
 
jazbo8's Avatar
 
Join Date: Jan 2011
Location: In Transient
LTspice - limiting the number of decimals
The above command controls the precision of the calculation, not the number of decimal places that LTSpice displays AFAIK.

In any case, after further searches, here is the way to limit the decimal places per ltwiki:
Undocumented LTspice - LTwiki-Wiki for LTspice

Code:
round($*1k)/1k ; display no more than 3 digits (typically automatically expressed in engineering format).
round(I(R1)*1k)/1k ; same display format as above, but expression is of the current through R1.
round(V(1,2)*1k)/1k ; same format, but expression is of the voltage difference between nodes 1 & 2.
  Reply With Quote
Old 26th December 2017, 10:15 AM   #10
SSassen is offline SSassen  Netherlands
diyAudio Member
 
SSassen's Avatar
 
Join Date: Mar 2005
Location: Beta Zeticuly
Quote:
Originally Posted by jazbo8 View Post
The above command controls the precision of the calculation, not the number of decimal places that LTSpice displays AFAIK.
Exactly, that was the 1st thing I tried.

Quote:
Originally Posted by jazbo8 View Post
In any case, after further searches, here is the way to limit the decimal places per ltwiki:
Undocumented LTspice - LTwiki-Wiki for LTspice

Code:
round($*1k)/1k ; display no more than 3 digits (typically automatically expressed in engineering format).
round(I(R1)*1k)/1k ; same display format as above, but expression is of the current through R1.
round(V(1,2)*1k)/1k ; same format, but expression is of the voltage difference between nodes 1 & 2.
Yeah, that's basically what we discussed in previous replies, it is a bit cumbersome though, as you'll have to manually relabel every node, rather than apply a global rule that applies to all number rounding.
__________________
Mediocre is not my middle name.
  Reply With Quote

Reply


LTspice - limiting the number of decimalsHide this!Advertise here!
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Decimals in LTspice Elvee Software Tools 1 25th August 2010 09:06 PM
Limiting Inrush?? Deltat Power Supplies 11 31st March 2006 03:38 PM
V/I Limiting richie00boy Solid State 17 29th August 2004 03:25 AM
Help understandin Self's V-I limiting sam9 Solid State 3 2nd October 2003 12:45 PM


New To Site? Need Help?

All times are GMT. The time now is 10:57 PM.


Search Engine Optimisation provided by DragonByte SEO (Pro) - vBulletin Mods & Addons Copyright © 2018 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 15.79%
vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2018 DragonByte Technologies Ltd.
Copyright ©1999-2018 diyAudio
Wiki