when in the following terms such as “ upper ” and “ lower ”, “ right ” and “ left ”, “ horizontal ” and “ vertical ” or similar relative expressions are used , these only refer to the appended figures and not necessarily to an actual situation of use . the shown figures are schematic representations for which reason the configuration of the different structures as well as their relative dimensions are intended to serve illustrative purposes only . when the term member or element is used for a given component it generally indicates that in the described embodiment the component is a unitary component , however , the same member or element may alternatively comprise a number of sub - components just as two or more of the described components could be provided as unitary components , e . g . manufactured as a single injection moulded part . when it is defined that members are mounted axially free to each other it generally indicates that they can be moved relative to each other , typically between defined stop positions whereas when it is defined that members are mounted rotationally free to each other it generally indicates that they can be rotated relative to each other either freely or between defined stop positions . the terms “ assembly ” and “ subassembly ” do not imply that the described components necessary can be assembled to provide a unitary or functional assembly or subassembly during a given assembly procedure but is merely used to describe components grouped together as being functionally more closely related . fig1 a and 1b show a drug delivery assembly 1 with a pen - formed drug delivery device 200 on which an electronic logging module 100 is mounted . in the present context the device represents a “ generic ” drug delivery device providing a specific example of a device in combination with which embodiments of the present invention is intended to be used or which can form a basis for aspects of the present invention . more specifically , the logging module 100 comprises a body portion 110 and a ring - formed portion 120 allowing the module to be mounted on a generally cylindrical pen device . the body portion comprises electronic circuitry and sensor means allowing a property to be detected representing an amount of drug being expelled from the cartridge , as well as a display 130 for displaying data to a user . the ring portion comprises coupling means allowing the module to be securely and correctly mounted on the pen body . the electronic circuitry and the sensor means may in part be arranged in the ring portion . exemplary embodiments of a logging module will be described with reference to fig6 - 10 below . the pen device 200 comprises a cap part 207 and a main part having a proximal body or drive assembly portion with a housing 201 in which a drug expelling mechanism is arranged or integrated , and a distal cartridge holder portion in which a drug - filled transparent cartridge 213 with a distal needle - penetrable septum is arranged and retained in place by a non - removable cartridge holder attached to the proximal portion , the cartridge holder having openings allowing a portion of the cartridge to be inspected as well as distal coupling means 215 allowing a needle assembly to be releasably mounted . the cartridge is provided with a piston driven by a piston rod forming part of the expelling mechanism and may for example contain an insulin , glp - 1 or growth hormone formulation . a proximal - most rotatable dose member 280 serves to manually set a desired dose of drug shown in display window 202 and which can then be expelled when the button 290 is actuated . depending on the type of expelling mechanism embodied in the drug delivery device , the expelling mechanism may comprise a spring as in the shown embodiment which is strained during dose setting and then released to drive the piston rod when the release button is actuated . alternatively the expelling mechanism may be fully manual in which case the dose member and the actuation button moves proximally during dose setting corresponding to the set dose size , and then is moved distally by the user to expel the set dose . as appears , fig1 shows a drug delivery device of the pre - filled type , i . e . it is supplied with a pre - mounted cartridge and is to be discarded when the cartridge has been emptied . in alternative embodiments the drug delivery device may be designed to allow a loaded cartridge to be replaced , e . g . in the form of a “ rear - loaded ” drug delivery device in which the cartridge holder is adapted to be removed from the device main portion , or alternatively in the form of a “ front - loaded ” device in which a cartridge is inserted through a distal opening in the cartridge holder which is non - removable attached to the main part of the device . as the invention relates to a module adapted to be secured to and interact with a drug delivery device , as well as a drug delivery device allowing such an interaction , an exemplary embodiment of such a device will be described for better understanding of the invention . fig2 shows an exploded view of the pen - formed drug delivery device 200 shown in fig1 . more specifically , the pen comprises a tubular housing 201 with a window opening 202 and onto which a cartridge holder 210 is fixedly mounted , a drug - filled cartridge 213 being arranged in the cartridge holder . the cartridge holder is provided with distal coupling means 215 allowing a needle assembly 216 to be releasably mounted , proximal coupling means in the form of two opposed protrusions 211 allowing a cap 207 to be releasably mounted covering the cartridge holder and a mounted needle assembly , as well as a protrusion 212 preventing the pen from rolling on e . g . a table top . in the housing distal end a nut element 225 is fixedly mounted , the nut element comprising a central threaded bore 226 , and in the housing proximal end a spring base member 208 with a central opening is fixedly mounted . a drive system comprises a threaded piston rod 220 having two opposed longitudinal grooves and being received in the nut element threaded bore , a ring - formed piston rod drive element 230 rotationally arranged in the housing , and a ring - formed clutch element 240 which is in rotational engagement with the drive element ( see below ), the engagement allowing axial movement of the clutch element . the clutch element is provided with outer spline elements 241 adapted to engage corresponding splines 204 ( see fig4 b ) on the housing inner surface , this allowing the clutch element to be moved between a rotationally locked proximal position , in which the splines are in engagement , and a rotationally free distal position in which the splines are out of engagement . as just mentioned , in both positions the clutch element is rotationally locked to the drive element . the drive element comprises a central bore with two opposed protrusions 231 in engagement with the grooves on the piston rod whereby rotation of the drive element results in rotation and thereby distal axial movement of the piston rod due to the threaded engagement between the piston rod and the nut element . the drive element further comprises a pair of opposed circumferentially extending flexible ratchet arms 235 adapted to engage corresponding ratchet teeth 205 arranged on the housing inner surface . the drive element and the clutch element comprise cooperating coupling structures rotationally locking them together but allowing the clutch element to be moved axially , this allowing the clutch element to be moved axially to its distal position in which it is allowed to rotate , thereby transmitting rotational movement from the dial system ( see below ) to the drive system . the interaction between the clutch element , the drive element and the housing will be shown and described in greater detail with reference to fig4 a and 4b . on the piston rod an end - of - content ( eoc ) member 228 is threadedly mounted and on the distal end a washer 227 is rotationally mounted . the eoc member comprises a pair of opposed radial projections 229 for engagement with the reset tube ( see below ). the dial system comprises a ratchet tube 250 , a reset tube 260 , a scale drum 270 with an outer helically arranged row of dose numerals , a user - operated dial member 280 for setting a dose of drug to be expelled , a release button 290 and a torque spring 255 ( see fig3 ). the reset tube is mounted axially locked inside the ratchet tube but is allowed to rotate a few degrees ( see below ). the reset tube comprises on its inner surface two opposed longitudinal grooves 269 adapted to engage the radial projections 229 of the eoc member , whereby the eoc can be rotated by the reset tube but is allowed to move axially . the clutch element is mounted axially locked on the outer distal end portion of the ratchet tube 250 , this providing that the ratchet tube can be moved axially in and out of rotational engagement with the housing via the clutch element . the dial member 280 is mounted axially locked but rotationally free on the housing proximal end , the dial ring being under normal operation rotationally locked to the reset tube ( see below ), whereby rotation of dial ring results in a corresponding rotation of the reset tube and thereby the ratchet tube . the release button 290 is axially locked to the reset tube but is free to rotate . a return spring 295 provides a proximally directed force on the button and the thereto mounted reset tube . the scale drum 270 is arranged in the circumferential space between the ratchet tube and the housing , the drum being rotationally locked to the ratchet tube via cooperating longitudinal splines 251 , 271 and being in rotational threaded engagement with the inner surface of the housing via cooperating thread structures 203 , 273 , whereby the row of numerals passes the window opening 203 in the housing when the drum is rotated relative to the housing by the ratchet tube . the torque spring is arranged in the circumferential space between the ratchet tube and the reset tube and is at its proximal end secured to the spring base member 208 and at its distal end to the ratchet tube , whereby the spring is strained when the ratchet tube is rotated relative to the housing by rotation of the dial member . a ratchet mechanism with a flexible ratchet arm 252 is provided between the ratchet tube and the clutch element , the latter being provided with an inner circumferential teeth structures 242 , each tooth providing a ratchet stop such that the ratchet tube is held in the position to which it is rotated by a user via the reset tube when a dose is set . in order to allow a set dose to be reduced a ratchet release mechanism 262 is provided on the reset tube and acting on the ratchet tube , this allowing a set dose to be reduced by one or more ratchet increments by turning the dial member in the opposite direction , the release mechanism being actuated when the reset tube is rotated the above - described few degrees relative to the ratchet tube . having described the different components of the expelling mechanism and their functional relationship , operation of the mechanism will be described next with reference mainly to fig3 a and 3b . the pen mechanism can be considered as two interacting systems , a dose system and a dial system , this as described above . during dose setting the dial mechanism rotates and the torsion spring is loaded . the dose mechanism is locked to the housing and cannot move . when the push button is pushed down , the dose mechanism is released from the housing and due to the engagement to the dial system , the torsion spring will now rotate back the dial system to the starting point and rotate the dose system along with it . the central part of the dose mechanism is the piston rod 220 , the actual displacement of the plunger being performed by the piston rod . during dose delivery , the piston rod is rotated by the drive element 230 and due to the threaded interaction with the nut element 225 which is fixed to the housing , the piston rod moves forward in the distal direction . between the rubber piston and the piston rod , the piston washer 227 is placed which serves as an axial bearing for the rotating piston rod and evens out the pressure on the rubber piston . as the piston rod has a non - circular cross section where the piston rod drive element engages with the piston rod , the drive element is locked rotationally to the piston rod , but free to move along the piston rod axis . consequently , rotation of the drive element results in a linear forwards movement of the piston . the drive element is provided with small ratchet arms 234 which prevent the drive element from rotating clockwise ( seen from the push button end ). due to the engagement with the drive element , the piston rod can thus only move forwards . during dose delivery , the drive element rotates anti - clockwise and the ratchet arms 235 provide the user with small clicks due to the engagement with the ratchet teeth 205 , e . g . one click per unit of insulin expelled . turning to the dial system , the dose is set and reset by turning the dial member 280 . when turning the dial , the reset tube 260 , the eoc member 228 , the ratchet tube 250 and the scale drum 270 all turn with it . as the ratchet tube is connected to the distal end of the torque spring 255 , the spring is loaded . during dose setting , the arm 252 of the ratchet performs a dial click for each unit dialled due to the interaction with the inner teeth structure 242 of the clutch element . in the shown embodiment the clutch element is provided with 24 ratchet stops providing 24 clicks ( increments ) for a full 360 degrees rotation relative to the housing . the spring is preloaded during assembly which enables the mechanism to deliver both small and large doses within an acceptable speed interval . as the scale drum is rotationally engaged with the ratchet tube , but movable in the axial direction and the scale drum is in threaded engagement with the housing , the scale drum will move in a helical pattern when the dial system is turned , the number corresponding to the set dose being shown in the housing window 202 . the ratchet 252 , 242 between the ratchet tube and the clutch element 240 prevents the spring from turning back the parts . during resetting , the reset tube moves the ratchet arm 252 , thereby releasing the ratchet click by click , one click corresponding to one unit iu of insulin in the described embodiment . more specifically , when the dial member is turned clock - wise , the reset tube simply rotates the ratchet tube allowing the arm of the ratchet to freely interact with the teeth structures 242 in the clutch element . when the dial member is turned counter - clockwise , the reset tube interacts directly with the ratchet click arm forcing the click arm towards the centre of the pen away from the teeth in the clutch , thus allowing the click arm on the ratchet to move “ one click ” backwards due to torque caused by the loaded spring . to deliver a set dose , the push button 290 is pushed in the distal direction by the user as shown in fig3 b . the reset tube 260 decouples from the dial member and subsequently the clutch element 240 disengages the housing splines 204 . now the dial mechanism returns to “ zero ” together with the drive element 230 , this leading to a dose of drug being expelled . it is possible to stop and start a dose at any time by releasing or pushing the push button at any time during drug delivery . a dose of less than 5 iu normally cannot be paused , since the rubber piston is compressed very quickly leading to a compression of the rubber piston and subsequently delivery of insulin when the piston returns to the original dimensions . the eoc feature prevents the user from setting a larger dose than left in the cartridge . the eoc member 228 is rotationally locked to the reset tube , which makes the eoc member rotate during dose setting , resetting and dose delivery , during which it can be moved axially back and forth following the thread of the piston rod . when it reaches the proximal end of the piston rod a stop is provided , this preventing all the connected parts , including the dial member , from being rotated further in the dose setting direction , i . e . the now set dose corresponds to the remaining drug content in the cartridge . the scale drum 270 is provided with a distal stop surface adapted to engage a corresponding stop surface on the housing inner surface , this providing a maximum dose stop for the scale drum preventing all the connected parts , including the dial member , from being rotated further in the dose setting direction . in the shown embodiment the maximum dose is set to 80 iu . correspondingly , the scale drum is provided with a proximal stop surface adapted to engage a corresponding stop surface on the spring base member , this preventing all the connected parts , including the dial member , from being rotated further in the dose expelling direction , thereby providing a “ zero ” stop for the entire expelling mechanism . to prevent accidental over - dosage in case something should fail in the dialling mechanism allowing the scale drum to move beyond its zero - position , the eoc member serves to provide a security system . more specifically , in an initial state with a full cartridge the eoc member is positioned in a distal - most axial position in contact with the drive element . after a given dose has been expelled the eoc member will again be positioned in contact with the drive element . correspondingly , the eoc member will lock against the drive element in case the mechanism tries to deliver a dose beyond the zero - position . due to tolerances and flexibility of the different parts of the mechanism the eoc will travel a short distance allowing a small “ over dose ” of drug to be expelled , e . g . 3 - 5 iu of insulin . the expelling mechanism further comprises an end - of - dose ( eod ) click feature providing a distinct feedback at the end of an expelled dose informing the user that the full amount of drug has been expelled . more specifically , the eod function is made by the interaction between the spring base and the scale drum . when the scale drum returns to zero , a small click arm 206 on the spring base is forced backwards by the progressing scale drum . just before “ zero ” the arm is released and the arm hits a countersunk surface on the scale drum . the shown mechanism is further provided with a torque limiter in order to protect the mechanism from overload applied by the user via the dial member . this feature is provided by the interface between the dial member and the reset tube which as described above are rotationally locked to each other . more specifically , the dial member is provided with a circumferential inner teeth structure 281 engaging a number of corresponding teeth arranged on a flexible carrier portion 261 of the reset tube . the reset tube teeth are designed to transmit a torque of a given specified maximum size , e . g . 150 - 300 nmm , above which the flexible carrier portion and the teeth will bend inwards and make the dial member turn without rotating the rest of the dial mechanism . thus , the mechanism inside the pen cannot be stressed at a higher load than the torque limiter transmits through the teeth . in fig4 a the clutch element , the drive element and the housing ( in partial ) are shown in the dose setting state , and in fig4 b the same components are shown in the expelling state . as appears , the piston rod on which the drive element is arranged and the ratchet tube on which the clutch element is mounted are not shown . to better show the structures provided on the inner surface of the housing fig4 c shows a partial clutch element 240 arranged in the housing 201 . the inner surface of the housing 201 comprises a circumferential ring - formed array of axially oriented spline elements 204 protruding into the interior , each having a pointed distal end 209 , as well as a circumferential ring - formed array of one - way ratchet teeth 205 . the inner surface further comprises a male helical thread 203 adapted to engage the female helical thread 273 on the scale drum 270 . a distal circumferential groove is formed to engage and mount the nut element 225 . the clutch element 240 comprises an inner circumferential ring - formed array of ratchet teeth 242 adapted to engage the ratchet arm 252 on the ratchet tube 250 , and an outer circumferential ring - formed array of axially oriented spline elements 241 adapted to engage the spline elements 204 of the housing as well as the coupling slots in the drive element ( see below ), each spline having a pointed proximal end 243 . the drive element 230 comprises a pair of opposed coupling portions each comprising two proximally extending skirt portions 232 between which an axially extending coupling slot 233 is formed , the slot being adapted to engage a portion of the clutch element spline elements . in this way the engaging surfaces serve to transmit a rotational force and thereby torque from the clutch element to the drive element in the expelling state . the drive element further comprises a pair of opposed circumferentially extending flexible ratchet arms adapted to engage the ring - formed array of one - way ratchet teeth 205 . during dose delivery , the drive element rotates anti - clockwise and the ratchet arms 235 also provide the user with small clicks due to the engagement with the ratchet teeth 205 , e . g . one click per unit of insulin expelled . in the shown embodiment 24 ratchet teeth are provided corresponding to 15 degrees rotation per unit of insulin . the central bore of the drive element comprises two opposed protrusions 231 adapted to engage with the axially oriented grooves on the piston rod . in the dose setting state shown in fig4 a the spline elements 241 of the clutch element are in engagement with the spline elements 204 of the housing thereby rotationally locking the clutch element relative to the housing . as can be seen from fig4 a a group of clutch spline elements are received in the corresponding coupling slot with a slight rotational play . in the expelling state shown in fig4 b the spline elements 241 of the clutch element are moved distally out of engagement with the spline elements 204 of the housing thereby allowing rotation of the clutch element relative to the housing . as can be seen from fig4 b the group of clutch spline elements are now received in the corresponding coupling slot without rotational play . fig5 shows a detail view of the clutch element 240 showing the above - described inner circumferential ring - formed array of ratchet teeth 242 and the outer circumferential ring - formed array of axially oriented spline elements 241 . as appears , the spline elements are not arranged equidistantly on the ring but in groups , the groups comprising two opposed coupling groups 245 serving as the coupling means engaging the coupling slots 233 . whereas thus only some of the spline elements serve as coupling means between the clutch element and the drive element they all serve as coupling means between the clutch element and the housing splines 204 . in the shown embodiment the entire clutch element is manufactured in magnetic material , preferably moulded using a magnetic polymeric compound containing grinded magnetic particles , as this technique can produce intricate shapes . a large magnetic volume is subsequently obtained by magnetizing the whole part , thereby obtaining a larger external magnetic field with a larger magnetic moment than what would be possible with just a region of the part being magnetic . in the shown example a magnetic dipole oriented in the a - a direction is created . as will be described in greater detail below , the magnetic field can be detected by an electronic sensing component and the information be used to determine the rotational and / or axial position of the clutch element in relation to the sensor means . turning to fig6 an exemplary embodiment of a logging module 300 is shown in which the exterior housing has been removed to reveal the interior design and components . the module comprises a main body 310 having a generally cylindrical ring - formed portion 320 and a body portion 330 on which the majority of the electronic circuitry is mounted . the main body is formed from a lds polymer whereby integrated wiring can be achieved by using lds ( laser direct structuring ) technology , the polymer having elastic properties allowing a flexible hinged latch to be formed integrally . more specifically , the ring portion comprises an inner generally cylindrical surface adapted to be mounted on a drug delivery pen body as well as a pair of opposed integrally formed coupling structures 321 adapted to engage corresponding coupling structures on the pen device to assure that the module is securely mounted . the distal part of the ring portion has a larger diameter with a distally facing circumferential stop surface 329 adapted to receive and engage a cap when the module is mounted on a pen , see below . the inner ring surface and the outer pen body surface may be in either form - fitting or slight frictional engagement . each coupling structure on the module is in the form of a latch 322 having a proximal portion 323 , a distal portion 324 and a central portion , the latter being pivotally connected to the ring portion by integrally formed flexible hinges 325 allowing the latch to pivot a few degrees corresponding to a circumferential axis . by this arrangement the distal latch portion moves inwards when the proximal portion is moved outwards and vice versa . the proximal latch portions each comprises an inner protrusion 326 adapted to engage a corresponding coupling structure on the pen device and the distal latch portions each comprises a protrusion 327 adapted to engage the cap when a cap is mounted on the pen body . to assure correct rotational mounting of the module on the pen the shown module is provided with a funnel - shaped slot 528 ( see fig8 ) adapted to axially engage a corresponding protrusion on the pen . in the shown embodiment of fig1 a the protrusion 212 is provided on the pen cartridge holder 210 and arranged opposite the pen display window 202 , the electronic display 130 thereby being arranged next to the pen display window when the module is mounted on a pen . the interactions between the logging module , the pen body and the cap will be described in greater detail below . on the body portion 330 the majority of the electronic components 340 including processors means , a display 341 , a flexible cap switch 342 and a battery 343 are mounted . in the shown embodiment the logging module comprises two opposed sensors in the form of magnetometers 345 mounted directly on the ring portion 320 , the sensors as well as the majority of the electronic components being connected using lds . further sensors may be provided allowing e . g . the type of the device to be recognized . the logging module may be provided with user input means in the form of e . g . one or more buttons ( not shown ) allowing the user to control the module . the logging module may further be provided with transmission means allowing data to be transmitted to or from the module , e . g . log data may be transmitted to a user &# 39 ; s smartphone by nfc or other wireless means . fig7 shows an alternative embodiment 400 in which the electronics including the sensors are mounted on a flexible pcb 440 which then is mounted on the main body 410 using metal clips 446 . fig8 shows an alternative embodiment of a module main body 510 comprising a generally cylindrical ring - formed portion 520 and a body portion 530 , the main body being formed from a lds polymer . corresponding to the fig6 embodiment the ring portion 520 is provided with a pair of opposed coupling latches 522 having proximal and distal coupling protrusions 526 , 527 as well as a coupling slot 528 . fig9 shows a further alternative embodiment of a module main body 610 comprising a generally cylindrical ring - formed portion 620 , however , in contrast to the above - described embodiments comprising integrally formed latches , the latch structures are here provided as separate metal latch members 621 attached to the ring portion . corresponding to the integrally formed latches , each latch member comprises a proximal portion 623 with an inner protrusion 626 adapted to engage a corresponding coupling structure on the pen device , as well as a distal portion 624 with an inner protrusion 327 adapted to engage the cap when a cap is mounted on the pen body . in the shown embodiment the metal latch members each comprises a pair of proximal legs attached to the ring portion by rivets . the shown embodiment of a metal latch does not comprise a specific hinge structure , however , when mounted on a pen the latch member will provide the same “ dual - purpose ” functionality as the integrally formed latch , see below . fig1 shows the main body 610 incorporated in a logging module 600 comprising a circumferential stop surface 629 and being provided with metal latch members 622 . with reference to fig2 and 8 mounting and operation of a logging module of the type shown in fig1 a and 1b will be described . to mount the module on the pen body the cap is removed allowing the module to be slid over the cartridge holder 210 . during mounting the user orients the module display 130 in line with the pen display 202 whereby the funnel - shaped slot 528 will catch the protrusion 212 which then will orient the module rotationally correct , this ensuring that the proximal latch protrusions 526 will snap into engagement with the cartridge protrusions 211 , the module now being in its operational position , this allowing information to be transferred between the drug delivery device and the logging module ( see below ). as appears from fig1 b , in the mounted position a ring - formed gap 214 is formed between the cartridge holder and the distal portion of the module , this allowing the cap to be inserted into the gap as shown in fig1 b and 8 . for normal use without a mounted logging module the cap comprises inner coupling means adapted to engage the cartridge protrusions 211 , however , with a mounted logging module the cartridge protrusions are “ occupied ”. correspondingly , the module is provided with the above - described distal latch protrusions 527 which in the shown embodiment frictionally engage the outer cap surface to securely hold it in place . in addition , also the flexible cap switch 342 contributes to hold the cap in place . alternatively , the cap may be provided with coupling means , e . g . a circumferential groove , which would allow the cap to engage the module by snap action . the coupling between the pen main part and the module is designed to provide both ease of attachment and a firm and secure grip during normal use , however , this should also be the case for the cap when attached to the pen in cooperation with the module . correspondingly , when the cap is removed from the pen a distally directed force is transmitted to the coupling between the module and the pen via the coupling between the module and the cap which under given circumstances may result in the module being unintentionally pulled off the pen . to reduce the risk of this happening the module coupling latches 522 are provided with a “ snap booster ” feature . more specifically , each latch has a hinged design as described with reference to fig6 , this providing that the distal latch portion moves ( further ) inwards into the circumferential gap when the proximal latch portions are moved outwards as the module is mounted on the pen . as the proximal latch portions cannot be moved further inwards when the module is mounted , the outwards movement of the distal latch portions due to insertion of the cap into the gap 214 will result in an inwardly directed force being applied on the proximal latch portions via the latch central portion , this ensuring an enhanced grip between the module and the pen when the cap is mounted , this reducing the risk that the module is unintentionally pulled off the pen when the cap is removed . a proximal stop for the cap is provided by a circumferential stop surface of the module . having described the different components of the system , next a typical situation of use will be described with reference to fig1 a and 1b . when the user desires to dispense a dose of drug , e . g . performing an intravenous injection of an amount of an insulin formulation , the cap 207 is removed and a needle assembly , if not already in place , is mounted on the cartridge holder coupling means 215 . when the cap is removed the logging module is turned on from its sleeping state by activation of the module cap switch to its “ on ” position , e . g . the electronic circuitry with the sensor system is powered up and the display is turned on showing e . g . the last logged dose and the time since then . the user will then turn the rotatable dose member 280 to manually set a desired dose of drug shown in display window 202 and which can then be expelled when the button 290 is actuated . depending on the design of the logging module a given dose may be registered corresponding to a set dose , an expelled dose or both . in the shown embodiment in which movement of the clutch element is detected it follows that only an expelled dose can be registered . correspondingly , the module display will not show information in respect of the dose being set . when the dose has been set , the user releases the spring - driven expelling mechanism whereby the clutch element is released and starts to rotate in a fixed relationship to the expelled amount , this allowing the expelled amount to be determined by the logging module . as the module has not acquired information in respect of the set dose and as the expelling of a set dose can be paused by releasing the pressure on the release button , a given dose , e . g . a large dose , may be split into two or more amounts , which would result in the logging of two or more expelled doses . correspondingly , to treat such split doses as a single dose the shown logging module is designed to combine and log individual doses as a single dose under given circumstances , typically within a given window of time , e . g . 5 minutes , after which the “ combine feature ” would time out . such a feature would also allow the module to be moved to a new pen should a given desired dose be larger than the amount of drug remaining in the cartridge of a used pen . if it for any reason is desired to have split doses logged individually the “ combine window ” can be closed by mounting the cap on the pen to thereby bring the cap switch in its “ off ” position terminating a logging event . correspondingly , during normal operation in which a given dose is expelled as a single amount of drug the combine window is closed when the cap is mounted , this resulting in the determined dose ( single or combined ) being logged in the memory together with a time value as well as displayed in the electronic display for a given amount of time , e . g . 30 seconds , before the electronics power down and the display is turned off . turning to the sensor system of the logging module , the shown embodiment may be designed to detect one or more movements of one or more magnetic members . for example , a “ simple ” design may be implemented in which the number of incremental rotational movements of the clutch element is counted , i . e . the number of 15 degrees increments , each increment corresponding to 1 unit ( iu ) of insulin . the system would be designed to scan the pen at a frequency sufficiently high to securely detect that the clutch element has moved into a new of 24 pre - determined sectors each corresponding to 15 degrees rotation and thus 1 iu . using the same basic sensor design and sensor positions a magnetic drive element could be used as an alternative magnetic element . as a further alternative using the same general sensor design a component which is moved in accordance with both the set and the expelled dose could be used as a magnetic element , e . g . the ratchet tube . as the ratchet tube extends axially outside the part of the pen enclosed by the module ring only a portion of the ratchet tube may have magnetic properties , e . g . provided by a separate element . as a yet further alternative the sensor system may be designed to determine the absolute rotational position of a given element , however , as most pens using a rotating expelling mechanism are designed to expel a dose size requiring more than one full rotation of a given element , it would be necessary to count the number of full revolution . this could be accomplished using the same magnetic element to both count incremental movement ( here : number of rotations ) and an absolute position . the same or different sensor systems may be provided to detect the two type of information . determination of an absolute position would prevent errors due to missed counts . alternatively the sensor system may be designed to use an additional “ secondary ” element which is moved axially as a dose is expelled to indicate full rotations of the “ primary ” rotating element , e . g . a magnetic eoc member , however , as the movement of such an element primarily takes place outside the part of the pen enclosed by the module ring it may be necessary to provide further sensors . in the following a magnetometer - based detection system will be described which basically can accurately detect the position of a magnet moving in a predefined way , e . g . rotating relative to an axis . the system is therefore applicable in many technical areas in which accurate non - contact position sensing is relevant . in the following a system will be described which has been set up for application in a drug delivery system comprising a magnetic member which is configured to perform a rotational movement , see e . g . fig4 a , and which will determine the absolute rotational position of a magnetic member . in fig6 an exemplary embodiment of a sensor assembly is configured as comprising 3 3d magnetic sensors 345 equidistantly around the pre - determined axis for the above - described ring - formed clutch element rotating inside the distal portion of a pen - formed drug delivery . in the following an exemplary algorithm for estimating a current orientation of a magnet will be described . the algorithm is general to any movement of a magnet , but in the present application , it is applied to a system with rotational movement of a magnet . the algorithm is adapted for a system having deviations from nominal movement of the magnet . therefore , it requires a pre - determined model of the magnet movement from which one can derive derivatives . let b nom k ( n ) denote the field having nominal geometry of the system , where n is the position of the axial displacement and k is the sensor measuring the field . if the magnet has a given geometry and if the relative distance between sensors and magnet is assumed to be in the magnetic far - field for all positions , the pre - determined model can be estimated using a dipole field model . thus , we can estimate b nom k ( n ) to all positions by the following : where m is the dipole moment vector of that given position n , r is the distance vector between the magnet and the sensor k and r is the distance between the magnet and sensor k . if the sensors are positioned in the magnetic near - field , then b nom k ( n ) can be estimated using finite element analysis of the magnet geometry . the concept is to have a model that both estimates the non - nominal behaviour and compensates the pre - determined nominal model , if non - nominal behaviour is found to be acceptable . in order to do so , a linearized model of the pre - determined model is defined : where we have included the following deviation parameters in the linearized model : δx , δy radial offsets of magnet position relative to nominal model { circumflex over ( b )} n ( e )= b n nom + j n e [ 4 ] where j n =∂ b n nom /∂ e is the jacobian matrix . then we determine e to minimize the difference between the measured field and the linearized model . i . e . : where g n denotes a diagonal matrix with weights for each sensor k and position n . thus , e is given by : e n min =[ j n t g n j n ] − 1 [ j n t g n ( b meas - b n nom )] [ 6 ] e n min = m n ( b meas - b n nom ) [ 7 ] m n =[ j n t g n j n ] − 1 [ j n t g n ] [ 8 ] this matrix is constant . thus , it can be stored on the processor to save computational power . the parameter offset vector , e n min , is then inserted into the linearized model : { circumflex over ( b )} n ( e n min )= b n nom + j n e n min [ 9 ] this provides an updated version of the nominal model accounting for the difference between the measured field and the nominal model . the estimated position is found to be the position with the smallest difference , i . e . minimizing the residual : r n =∥ b meas - { circumflex over ( b )} n ( e n min )∥ [ 10 ] the algorithm makes use of constant tables that can be stored on the processor , i . e . it consists of b n nom , j n and m n . the algorithm provides measures that can be used as fail - safe measure , i . e . the quality of the fit can be estimated from e n min and the size of the residuals , r n . the shown column vector e is merely an example of selected deviation parameters . if the risk of external magnetic fields other than earth &# 39 ; s magnetic field and disturbances in the internal magnetic field by the presence of iron nearby can be positively excluded , the most likely candidate of actual position found in the table can be relayed or displayed as actual position . however , in most applications the risk of disturbances in the magnetic field must be considered likely from a variety of sources and in some applications the consequences of a wrong determination of position could have serious and unacceptable consequences . in such applications a number of fail - safe measures can be taken , for example : ( 1 ) taking a number of readings and use mean axis value from each axis from each sensor only when variations between readings are less than a predefined level . this could prevent wrong readings from the sensors caused by a fluctuating disturbance in the magnetic field . ( 2 ) subtracting readings from diametrically opposite sensors to eliminate the magnet field contribution and the homogenous external field contribution and hence calculate the gradient of an inhomogeneous external field . comparison against threshold values may be used as criteria for using the readings . ( 3 ) using readings to calculate the external field . comparison against threshold values may be used as criteria for using the readings . ( 4 ) using readings from an over - determined sensor configuration to calculate deviations from pre - determined nominal mechanical geometry and magnet characteristics . comparison against threshold values may be used as criteria for using the readings . ( 5 ) comparing the deviance of the most likely position and the deviances of rejected positions ( e . g . the second most likely position ) to determine the credibility of the most likely position . comparison against threshold values may be used as criteria for using the readings . ( 6 ) comparing the most likely position and rejected positions , e . g . the top 10 next most likely positions , to determine the distribution of the positions . the distribution , e . g . span between minimum and maximum position , may be used as criteria for using the readings . ( 7 ) using the most likely position to calculate the field contribution from the magnet and subtracting the contribution from the readings to obtain an estimated external field . the estimated external field may be used as input for calculating a most likely position which should be rejected by one or more of the fail - safe measures since the field contribution from the magnet has been eliminated . the field contribution from a position different from the most likely positions may be calculated and added to the estimated external field . the resulting field may be used as input for calculating a most likely position . correspondence between the selected position and calculated position may be used as criteria for using the readings . ( 8 ) using calculated positions to determine the mechanical movement , e . g . direction , speed and position stability . comparison against threshold values may be used as criteria for using the readings . ( 9 ) only appoint a most likely candidate of actual position if the minimum sum of deviance is less than a predefined value , to ensure a certain level of coherence between measured values and ( expected ) table values . this predefined value may be dependent on where in the range of operation the most likely candidate is , since the distances between neighboring candidates vary with distance from sensor . this should prevent a constant disturbance above a certain magnitude from causing the wrong position to be appointed most likely candidate and can also prevent a most likely candidate from being appointed if one of the sensors axis &# 39 ; have gone into saturated mode . if sensors are exposed to a magnetic field of a strength exceeding their limit of operation , they will go into saturation mode and give a readout of ( a known predefined ) maximum value . the above mentioned fail - safe measures will only be able to help prevent read - out of dose data based on false positions by giving no read - out at all . the system can then ( if change of position is either prevented or monitored not to occur ) repeat measurements until the system is clear of the external disturbance of the internal magnetic field . as a given pre - filled drug delivery device may be part of a system it may be provided to the users with different types of drugs , e . g . drugs for the treatment of different conditions such as diabetes and growth disorders , different classes of drugs for the treatment of a given condition such as insulins and glp - 1 for treatment of diabetes , different types of drugs from a given class such as long - acting and fast - acting insulin formulations , or different concentrations for a given specific drug such as 100 iu or 200 iu of insulin per ml of formulation . although the above - described logging module normally would be designed to be mounted on only one type of drug delivery device it could in theory be mounted on devises containing a variety of different drugs . to prevent that a given logging module would be used in a way resulting in incorrect determination of dose data , it should be ensured that a given logging module in a given state is used in combination with the corresponding drug . for example , a given logging module may be adapted to be used with only one type of drug , e . g . a given insulin formulation having a given concentration , this being indicated on the logging module e . g . text , colour or other visual markings . indeed , this would still allow a given logging module to be used in combination with the wrong delivery device . to prevent this from taking place the logging module and the different delivery devices of a given system may be coded allowing mating of only modules and devices corresponding to each other , e . g . mechanically or electronically . for example , when a given pen type is used for different types of drugs it will be marked accordingly , e . g . by text , colour and / or codes . by providing such visual markings on the pen body on the part of the surface which would be covered by a mounted logging module , the logging module could be provided with optical sensor means adapted to detect such markings . for example , a given pen device may be fully or partly manufactured from a material having a given colour or it may be provided with a label having a given colour . if a given logging module is adapted to be used only for one type of drug it would require that the corresponding colour is positively identified , otherwise the logging module would indicate an error condition . alternatively , the logging module may be adapted to be used in combination with a variety of drugs , such that the positive identification of a given pre - specified colour would set up the logging module accordingly . for example , when mounted on a pen device with insulin of a given concentration it would register and display the correct number of iu , whereas when mounted on a pen device with glp - 1 of a given concentration it would register and display the correct number of mg . the type or brand name of the drug may be displayed e . g . a short time each time the display is turned on . in the above description of exemplary embodiments , the different structures and means providing the described functionality for the different components have been described to a degree to which the concept of the present invention will be apparent to the skilled reader . the detailed construction and specification for the different components are considered the object of a normal design procedure performed by the skilled person along the lines set out in the present specification .
a drug delivery assembly comprises a drug delivery device , an electronic dose logging module releasably attachable to the drug delivery device , and a cap releasably attachable to the logging module to cover an outlet portion of a mounted drug reservoir . the logging module and the drug delivery device comprise mating snap coupling means . the logging module comprises locking means acting on the locking module snap coupling means , wherein the locking means is actuated from the unlocked to the locked state when the cap is attached to the logging module in a first direction , and the locking means is actuated from the locked to the unlocked state when the cap is detached from the logging module in a second direction opposed to the first direction .