M581/M950 slight confusion re pin inversion
-
Just upgraded to latest RRF 3.1.1. from a very early RRF3 pre-release candidate version. Slightly confused about high/low setting and pin inversion for my trigger macros. Basically my DC UPS has a set of contacts which change state on mains power failure. The trigger macros are used to change the bed heater fault detection (the bed stops heating on power fail).
Old code was :
M581 P"!0.io3.in" T2 C0; (high to low trigger).
M581 P"0.io3.in" T3 C0; (low to high trigger).New code that needs checking please:
M950 J1 C"!0.io3.in"
M581 P1 T2 R0 S1; high to low trigger).
M581 P1 T3 R0 S0 ;(low to high trigger).I'm assuming that I only need a single M950 yes?.
Do I need to invert the pin as I have done in that M950? If so, have got the S1 and S0 the right way round in the two M581 commands? If I don't invert the pin, same question. i.e. what should I use for "S" in the two M581 commands to replicate the old behaviour.?
It isn't easy to test on the printer itself- hence the reason for asking.
-
The S parameter used in RRF_2.x is removed. The command waits for a low-to-high input transition. To wait for a high-to-low transition, invert the pin name using '!'.
So the trigger is always low to high in RRF3, no S parameter. If you need a high to low transition, invert the pin (from reading the docs, can try to test it this afternoon if no-one verifies before that)
-
@bearer Scroll down a bit further to RepRapFirmware 3.01RC2 and later.
Quote :
"S Whether trigger occurs on an inactive-to-active edge of that input (S1, default), active-to-inactive edge (S0), or ignores that input (S-1). By default, all triggers ignore all inputs."
-
my bad!
what transition do you need to trigger on btw? i'll try to poke it in a bit
-
@bearer said in M581/M950 slight confusion re pin inversion:
my bad!
what transition do you need to trigger on btw? i'll try to poke it in a bit
TBH, I'm not exactly sure which state on the UPS is high and which is low. Basically, if you look at my OP, those two original M581 commands did the job. So that's what I want to replicate. The first used pin inversion and I've annotated it "high to low", the second used the same pin but no inversion and I've annotated it "low to high".
EDIT - but there is no guarantee that my original annotation was correct
-
this is the Meanwell DR-UPS40 - and you need both a power fail and power good trigger right?
edit; hmm, it would depend on wiring, is the other side of the "DC OK" relay wired to ground or 24v(/5v/etc)?
-
@bearer IIRC, it's just a pair of contacts, neither of which are connected to anything at the UPS end. I'll take a gander at the printer when I get chance and let you know which pins I've connected those contacts to - I suspect it will have been io.in and gnd but I'll confirm.
-
Confirmed - UPS contacts are connected to io.in and gnd on the Duet board.
Edit. Pretty sure they are normally open but close on mains power failure.
Edit 2 - On the other hand, it could be the other way round
-
@deckingman said in M581/M950 slight confusion re pin inversion:
Edit. Pretty sure they are normally open but close on mains power failure.
according to the datasheet (asuming it is the meanwell ups) it is Relay contact : Short when DC voltage between 21~29V( 3%), relay contacts.
I have a similar setup 95% done, will poke it a little in an hour or two, I need to sort it out soner or later myself anyway
-
@bearer It is the Meanwell one https://www.meanwell.com/Upload/PDF/DR-UPS40/DR-UPS40-SPEC.PDF
Those contacts you mention are battery fail. I'm using the other set of contacts "Battery Discharge" on that pdf I linked to.
Quote :
"Relay contact : Short when battery in discharge condition, relay contacts" -
Battery Discharge - gotcha, the DC OK would presumably stay OK even when using battery power.
M950 J1 C"^exp.4" ;battery discharge NO Relay. Short to ground when running off batteries + pull up M581 P1 T2 R0 S0 ;S0=falling edge, i.e. when switch closes to ground = dc input loss M581 P1 T3 R0 S1 ;S1=raising edge, i.e. when contacts opens to pull up = dc input restore
does the comments make more sense now? tested with 3.1.1 on a Duet 2
(the rest is just to complete the refrence for anyone who stumbles into the thread.)
Shorting exp.4 to ground causes T2/trigger2.g to run.;trigger2.g power fail M300 S2000 P300 G4 P200 M300 S1500 P150 G4 P300 M118 P3 S"Power fail"
releasing the short causes T3/trigger3.g to run
;trigger3.g power restore M300 S2000 P300 G4 P200 M300 S2500 P150 G4 P300 M118 P3 S"Power restore"
edit; oh and Duet people: would having the most recent notes up top make more sense in the wiki thingy, to match the whats_new order?
-
@bearer Cheers - I'll go with that. I did wonder about enabling pull ups (but I didn't before on the old pre RC beta firmware).
But I'm unable to test it out. Long story short - I managed to cycle the mains power with the aid of a long stick but neither macro triggered. Then I dragged the printer out of it's "booth" (which is no mean feat) and discovered that I'm not getting a change of state on the relay contacts (nor the battery discharge light) when mains power gets interrupted. Either the UPS has developed on fault on that relay, or maybe the battery voltage needs to drop below a threshold. With mains power I have 27.6 V on the DC output, but without mains power I still have 26.8 V because the batteries are fully charged. I don't have a hot end fitted at the moment so no easy way to put a load on the system to bring the battery voltage down.
I'll put your code in (without the beeps in the macros
) and test it out when I get the printer put back together.
Thanks for the help.
-
Either the UPS has developed on fault on that relay, or maybe the battery voltage needs to drop below a threshold
Its not immediately clear if the discharge contact follows the same condition as the discharge LED, if so yo need 2A load to trigger the contact, something to test when you get a hotend (or 6 or 7) wired back in
BTW, the io4.in on the 6HC have hardwired pull ups, but adding the ^ just ensures anyone else who finds and copies the config will have it working if they use a pin without a hardwired pull up (like exp.4 on the Duet2)
-
@bearer One final quick question on this. If one were to invert the input in the M950 and then switch the S0 and S1 in the two M581 commands, would it still work? (i.e. a kind of double inversion).
-
It does, but when I tested that it seemed more prone to noise, i.e. multiple triggers (although there is no scientific reason for it afaik, could be gremlins). But I chose the non inverted option as I hoped the comments would be clearer that way