How Can I Include 4.2V, 8.4V, 12.6V, etc Power Supplies (e.g., Lipos)

It looks like there is something wrong with the moduleId postfix. This moduleId

module moduleId=“hanmatek-HM305_2-DC2PowerModuleID”

causes this:

breadboard doesn’t render (but does if the normal moduleId is used) schematic is fine so the part is loading

looks like only dcpower2.fzp uses that moduleId (and it isn’t a pre or post fix just a straight moduleId

moduleId=“DC2PowerModuleID”

so I expect I need a different postfix but don’t know what.

Peter

Of course! I thought he just wanted the 4.2V battery

I just tried this and I can reproduce the issue. I checked and there is code in Fritzing that disables the BB view if the moduleID ends in DC2PowerModuleID. A trick could be to use the “CapacitorModuleID” at the end of the moduleID. That will enable that users can change the property in the inspector, but the voltage will not be able to be less than 5V (as defined in properties.xml). A nicer fix would be to create a new moduleID, but needs a change in the code.

@pcgraphix , how did you manage to change the voltage and still have the breadboard view working?

fai, here is what I did to “add” additional voltage options to an already existing 3.7V lipo battery.

NOTE: I believe this will only work IF you have created & saved a new blank breadboard.

  1. Search parts for “3.7V” and it will show a few existing 3.7V voltage lipo batteries that fall under the family of “sparkfun battery holder”
  2. Drag the first 3.7V lipo to the breadboard
  3. Right click on it and choose “Edit (New Parts Editor)”
  4. Click on the MetaData tab
  5. Change the Title to “4.2V Lipo Battery” and the Voltage to “4.2V” (exclude quotes)
  6. Click File | Save As New Part and gave it a Filename Prefix as “4.2V Lipo Battery” & click OK
  7. Now this where things get buggy but eventually it all works out in the end…
  8. Click File | Close Window BUT it keeps prompting to close without saving
  9. Click “Close Anyways” on the popup prompt
  10. Now the new part should appear in your Mine Parts Bin BUT the “4.2V” won’t appear in the voltage dropdown menu…yet
  11. Drag the new part to the breadboard view and repeat Step 6
  12. Verify that MetaData Title & Voltage are set correctly for 4.2V
  13. Now this time Click File | Save and keep the same file name you entered before
  14. Click File | Close and once again it will prompt that you are “closing without saving”. Must click on “Keep Working” to get out of the Parts Editor window.
  15. Click File | Quit to close out of Fritzing entirely
  16. Now you will get a new set of prompts. Click Yes to all of them as this is where the new part is finally added to your MINE parts bin. Fritzing app will then close out.
  17. Relaunch Fritzing and verify that the new part is in your MINE bin and that the voltage dropdown now includes the newly added “4.2V”
  18. If it doesn’t, then keep repeating this procedure until it finally works.

NOTE: To write this procedure, I added 16.8V to my set of 4.2, 8.4 & 12.6V dropdown options. When I say this procedure is buggy, I mean buggy! It took 3 or 4 attempts to finally get the correct set of prompts to appear as I mention in Step 16.

NOTE: I now have 4 new lipo batteries in MINE bin labeled 4.2V, 8.4V, 12.6V & 16.8V. What is interesting is that each one of them now has the full complement of voltage options available in the dropdown so it doesn’t matter which one I use in a circuit.

NOTE: To verify that the newly added lipos are functional & “accurate” I created 2 simple but identical circuits. One in Fritzing and one in TinkerCAD circuits. Then measured the simulated current in each circuit and they were in agreement at the various voltages!!

AHH. Ok, so you basically created several parts. When you change the voltage, you can only select specific ones that you have created. And then Fritzing changes the part.
For the lab power supply, we should fix the module id issue as the user needs to select an arbitrary voltage.

Replacing DC2PowerModuleID with CapacitorModuleID makes breadboard load. I don’t know if simulation will work though. Here is a new part for the lab supply with the new moduleId and the spice info to try:

edit: Correct a typo in the fzp file

hanmatek-HM305.fzpz (5.4 KB)

if this works I will replace the original power supply with this one.

Peter

fai, correct! The voltages are “hard coded” in the dropdown menu using the procedure I outlined above. Wondering if the underlying xml property code could be edited in order to enable the option for a user to enter any value “on the fly” as can be done with resistors. But I haven’t figured out how to access or even view the xml property code for a part. Can you tell me how to do that?

It is in the .fzp file. This tutorial may help somewhat (although this is a bit out of scope):

to obtain the .fzp file unzip your fzpz file the fzp is one of the files zipped in there.

<module moduleId="hanmatek-HM305_2-CapacitorModuleID" referenceFile="hanmatek-HM305_2.fzp" fritzingVersion="1.01">

You likely need to add the CapacitorModuleID to the module id as that is what enables the code. Then the properties are in the properties section of the .fzp file (this is from the power supply .fzp file posted above)

  <properties>
    <property name="variant">variant 1</property>
    <property name="family">Hanmatek HM305</property>
    <property name="voltage">showInLabel=“yes” 9V</property>
    <property name="internal resistance">0.1Ω</property>
    <property name="layer"/>
  </properties>

the voltage and internal resistance properties are the ones of interest.

Peter

shouldn’t that be:

<properties>
    <property name="variant">variant 1</property>
    <property name="family">Hanmatek HM305</property>
    <property name="voltage" showInLabel=“yes”>9V</property>
    <property name="internal resistance">0.1Ω</property>
    <property name="layer"/>
  </properties>

“showInLabel” should be an attribute, not part of the data.

With general part building, I have found that to be able to have maximum control to edit property values, they need to be defined in the fxp file without an initial value. This could interact with the ‘special’ module id logic. Try one, or combinations, of:

<property name="voltage"/>
<property name="voltage"></property>
<property name="voltage" showInLabel="yes"/>

I have never tried show in label combined with an empty property.

Defining empty properties allows anything to be filled in. However, if spice is referencing the property something appropriate will need to be supplied.

Yes, but correcting that causes this error on parsing

capture1

char 42 is the start of the “yes” in this line

    <property name="voltage" showInLabel=“yes”>9V</property>

the original added showInLabel=“yes” to the 9V value in Inspector the new one dies on load.

Peter

One of the copy/paste/edit steps changed the “normal” quote into a word process quote character. Just change back to the standard quote characters around that “yes”.

"yes" versus “yes”

AH! Thanks that makes more sense.

Peter

I am not sure what is the advantage of empty properties. However, I saw that empty properties can cause unwanted behaviors in the cases that you describe: 1) When it is a property used by the simulator (simulation will fail or give wrong results) and 2) When showing the property. I remember that the resistors did not specify the power and the label was “R3\n220OHM\nW”. The power was not set using the properties defined in the resources file by default. So, I prefer to give a default value.

@vanepp , I am not sure about the “layer” property. Is it necessary?

Yes, I don’t remember exactly what but something fails if the layer isn’t there.

Peter

I could not reproduce that here. It works as expected without the layer property.
hanmatek-HM305 (1).fzpz (5.4 KB)

It may not matter in this particular case. I think (but am not sure) it affects pcb and this part doesn’t have pcb. It is however safer to have it in if it doesn’t cause some other problem.

Peter

Empty properties are always editable in inspector. In cases I tested, if a property as a value filled in, in the fxp, it can only be changed to a value that is in another version of the part. It triggers a part swap. Other than special cases like the resistors. I did not find another way to force a property to be editable.

I never saw that behavior. I tried to replicate that and it does not work in Fitzing 1.0.1 (Windows). I tried to change the power supply part to achieve that you can change the voltage in the inspector pane without being able to reproduce it.

<properties>
    <property name="variant">variant 1</property>
    <property name="family">Hanmatek HM305</property>
    <property name="voltage"/>
  </properties>

hanmatek-HM305 (1).fzpz (5.3 KB)
image

@microMerlin , can you edit the voltage property? Did I misunderstand anything?

Apparently I misremembered. No I can not edit the voltage, and my new tests did not find a way either. Exploring, I could only get part number to edit directly. To change anything else needed multiple parts with different values that inspector would swap using the drop down.

I must have been remembering parts of a conversation about what is needed. Something like an editable=“yes” attribute of properties.

No worries. Yes, part number is always editable.

Yes, that’s one way. The other is to use the specific moduleIDs that support editable properties as defined in resources/properties.xml (e.g., voltage and capacitance for CapacitorModuleId). But to support new editable properties, is is necessary to change that file and compile Fritzing.

I think you suggested that editable=“yes” in some open issue in the bug tracker :slight_smile: