# Pressure switch

Explosion-proof pressure switch on a 1/2" weld-neck flange (port process, facing down) through a bar-stock block valve with bleed plug: a bolted diaphragm-sealed sensing element under a cast Ex d enclosure with a threaded round cover, set-point access cap and a gland on the conduit entry.

**Standards:** IEC 60079-1, IEC 60947-5-1, ASME B16.5

## Installation

```bash
npx -y https://decktwin.com/cli/deck-twin-0.2.2.tgz add pressure-switch
```

Copies `instruments/pressure-switch.tsx`, any helper files it imports and the shared `lib/` into `src/components/deck-twin/`. Needs `three`, `@react-three/fiber` and `@react-three/drei`.

## Usage

```tsx
import { Canvas } from '@react-three/fiber'
import { OrbitControls } from '@react-three/drei'
import { Stage } from './components/deck-twin/lib/stage'
import { PressureSwitch } from './components/deck-twin/instruments/pressure-switch'

export default function Scene() {
  return (
    <Canvas shadows camera={{ position: [8, 5, 9], fov: 35 }}>
      <Stage>
        <PressureSwitch />
      </Stage>
      <OrbitControls makeDefault />
    </Canvas>
  )
}
```

## Props

| Prop | Type | Default | Range |
| --- | --- | --- | --- |
| `rating` | `150 \| 300 \| 600 \| 900 \| 1500 \| 2500` | `600` |  |
| `housing` | `"actuatorBlue" \| "stainless" \| "aluminium" \| "equipmentPaintDark"` | `"equipmentPaintDark"` |  |
| `tag` | `string` | `"PSHH-1101"` |  |
| `...group` | position, rotation, scale… |  |  |

## Ports

Flange faces in the component's local frame, metres. Origin: pipe centreline, flow along X.

| Id | Label | Position | Direction | Size | Class |
| --- | --- | --- | --- | --- | --- |
| `process` | Process connection | 0.000, 0.000, 0.000 | 0, -1, 0 | 1/2" | 600 |

## P&ID

Field bubble with PS plus H / HH / L / LL (PSH, PSHH, PSL, PSLL) on a short process connection, usually feeding a trip.

ISA PSH · ISA PSHH · ISA PSL · ISA PSLL · ISA PS · ISA 5.1 (field-mounted instrument bubble)

Switches have S as the function letter and no T. A PSV is a relief valve, not a switch: PSV has V for valve. PDSH across a filter is a differential pressure switch.

Pressure switch specification form (ISA-TR20.00.01) fields and the props they set:

| Field | Prop |
| --- | --- |
| Flange rating | `rating` |
| Housing material / finish | `housing` |
| Tag number | `tag` |

## Typical suppliers

Ashcroft. The geometry is generic and sized from public standards. It is not vendor CAD.

## Source

`instruments/pressure-switch.tsx`. This is the component file only: it imports shared code, so install it with the command above rather than pasting it alone. https://decktwin.com/r/pressure-switch.json has every file.

```tsx
// Pressure switch: 1/2" flanged connection, block valve, diaphragm-sealed sensing element and an Ex d switch enclosure with threaded cover, set-point cap and conduit entry. IEC 60079-1, ASME B16.5.
import { Kit, type MatKey } from '../lib/kit'
import { KitMesh, useKit, type GroupProps } from '../lib/mesh'
import { port, type Port } from '../lib/ports'
import type { Rating } from '../lib/standards'
import { SS, flange, tag as tagPlate, valveHandle } from './_parts'

export interface PressureSwitchProps {
  rating?: Rating
  housing?: MatKey
  tag?: string
}

export const defaults = { rating: 600 as Rating, housing: 'equipmentPaintDark' as MatKey, tag: 'PSHH-1101' }

export function ports(p: PressureSwitchProps = {}): Port[] {
  const { rating } = { ...defaults, ...p }
  return [port('process', 'Process connection', [0, 0, 0], [0, -1, 0], 0.5, rating, 'instrument')]
}

export function PressureSwitch({ rating = defaults.rating, housing = defaults.housing, tag = defaults.tag, ...group }: PressureSwitchProps & GroupProps) {
  const data = useKit((k) => build(k, rating, housing, tag), [rating, housing, tag])
  return (
    <group {...group}>
      <KitMesh data={data} />
    </group>
  )
}

export default PressureSwitch

function build(k: Kit, rating: Rating, housing: MatKey, tag: string) {
  let y = flange(k, 0.5, rating, [0, 0, 0], '-y')
  const yTag = y + 0.02
  k.cyl(SS, 0.0107, 0.04, [0, y + 0.02, 0], 'y', 14)
  y += 0.04
  // bar-stock block valve with bleed plug
  k.box(SS, [0.04, 0.05, 0.036], [0, y + 0.025, 0])
  valveHandle(k, [0, y + 0.03, 0.018], [0, 0, 1], 'handwheel')
  k.hex(SS, 0.012, 0.008, [-0.024, y + 0.014, 0], 'x')
  y += 0.05
  k.cyl(SS, 0.0107, 0.03, [0, y + 0.015, 0], 'y', 14)
  y += 0.03
  // diaphragm-sealed sensing element: upper and lower housings with a bolt ring
  k.cyl(SS, 0.04, 0.014, [0, y + 0.007, 0], 'y', 32)
  k.cyl(SS, 0.042, 0.004, [0, y + 0.016, 0], 'y', 32)
  k.cyl(SS, 0.04, 0.014, [0, y + 0.025, 0], 'y', 32)
  k.around(6, 0.034, [0, y + 0.033, 0], 'y', (p) => k.hex('nut', 0.009, 0.005, p, 'y'), Math.PI / 6)
  y += 0.032
  k.cyl(housing, 0.022, 0.016, [0, y + 0.008, 0], 'y', 20)
  y += 0.016
  // Ex d switch enclosure: cast body, round threaded cover on +Z, set-point cap on top, conduit entry on +X
  const W = 0.11
  const H = 0.14
  const Dp = 0.085
  const yc = y + H / 2
  k.rbox(housing, [W, H, Dp], 0.01, [0, yc, 0])
  k.cyl(housing, 0.044, 0.018, [0, yc, Dp / 2 + 0.009], 'z', 32)
  k.torus(housing, 0.044, 0.003, [0, yc, Dp / 2 + 0.004], 'z', 6, 32)
  for (let i = 0; i < 8; i++) {
    const a = (i / 8) * Math.PI * 2
    k.box(housing, [0.006, 0.006, 0.012], [Math.cos(a) * 0.045, yc + Math.sin(a) * 0.045, Dp / 2 + 0.012])
  }
  k.box('nameplate', [0.05, 0.022, 0.0015], [0, yc, Dp / 2 + 0.0185])
  k.cyl(housing, 0.016, 0.014, [0, y + H + 0.007, 0], 'y', 16)
  k.hex(SS, 0.024, 0.012, [0, y + H + 0.02, 0])
  k.cyl(housing, 0.014, 0.016, [W / 2 + 0.008, yc - H * 0.25, 0], 'x', 14)
  k.hex('brass', 0.028, 0.018, [W / 2 + 0.025, yc - H * 0.25, 0], 'x')
  k.cyl('rubberBlack', 0.0085, 0.012, [W / 2 + 0.04, yc - H * 0.25, 0], 'x', 10)
  k.cyl(SS, 0.005, 0.008, [-W / 2 - 0.004, yc - H * 0.35, 0], 'x', 8)
  tagPlate(k, tag, [0, yTag, 0.0116], 'z', 0.045)
}
```
