Trace: Home » devices » devices:jpns » build

The jfish Peripheral Nerve Stimulator

About Specs How Build Use

Building the jPNS

Construction of the jPNS is relatively simple. With the neccessary tools and parts at hand, construction should take between 2 and 3 hours. You should have confidence working with a soldering iron and an intermediate level of skill constructing electronics projects.

Build of materials lists, schematic and pcb artwork files are individually referenced below. A complete package containing all the required files, along with build and usage instructions can be downloaded here.

In the future, the project plans to facilitate the provision of pre-constructed devices to those working in areas of need. If you are interested in such a service, please contact the project for more information.

1. Tools

Construction of the jPNS requires only fairly basic electronic tools. For a complete discussion of suitable tools, see the Tools page. The minimum tools required for construction of this device include:

  • Soldering iron with variable temperature.
  • Digital multimeter able to measure DC voltages up to 350 V for testing of the high voltage stage.
  • Oscilloscope - only require single channel CRO, used for visualising the final output pulse patterns and to confirm the correct pulse width.
  • Drill or ‘high speed rotary tool’ for mounting of the completed circuit in the device case.
  • Access to a personal computer for burning/loading of firmware onto the microcontroller.

Theoretically the device could be constructed without any test equipment as none of the circuit stages require calibration before use, and the relative simplicity of the circuit makes post-construction faults unlikely. However, the very utility of the device relies upon a clinician’s confidence in its reliability, so full testing as described below, should always be performed.

2. Prepare components

Collect all required parts as listed. Some more specialist components (eg. MAX641, microcontroller, MOSFETS) may need to be ordered from online merchants. For a list of suitable online electronic component suppliers see the suppliers list.

Qty Value            Device               Parts               

5   1K               RESISTOR 1%          R1, R5, R8, R15, R21
1   22K              RESISTOR 1%          R2                  
3   47R              RESISTOR 1%          R3, R4, R6          
1   10K              RESISTOR 1%          R7                  
2   3K9              RESISTOR 1%          R9, R17             
2   5K6              RESISTOR 1%          R10, R12            
1   6K9              RESISTOR 1%          R11                 
2   100K             RESISTOR 1%          R14, R18            
1   330K             RESISTOR 1%          R13                 
1   1M               RESISTOR 1%          R16
1   37R              RESISTOR 1%          R19                 
1   1k log           POTENTIOMETER        R20     

2   0.1uF            CAPACITOR            C1, C2              
1   10uF             ELECTROLYTIC         C3                  
1   1000pF           CAPACITOR            C4                  
1   10uF 250V        ELECTROLYTIC         C5                  
1   4.7uF 63V        ELECTROLYTIC         C6                  

1   0.05mH           INDUCTOR             L1                              

1   3.3V             1N4728               D1                  
1   1N4004           1N4004               D2                  
1   FR104            FR104                D3                  
1   1N5817           1N5817               D4                  

1   BC548            BC548                Q1                  
1   BD679            BD679                Q2                  
1   BC556            BC556                Q3                  
1   BUZ80            BUZ80                Q4                  
1   2N7000           2N7000               Q5                  
1   MJE340           MJE340               Q6                  

1   PICAXE           PICAXE08             IC1                 
1   MAX641           MAX641               IC2                 
1   78L05            78L05                IC3                 

1   GRN              LED 5MM              LED1                
1   YLW              LED 5MM              LED2                
1   RED              LED 5MM              LED3                
1   PIEZO            BUZZER               SG1                 

1   ON/OFF SWITCH    TOGGLE               S1               
4   PULSE SWITCH     SPST_MICROS          S2, S3, S4, S5      
1   9V+              PINHEAD-1X2          JP1                 
1   Serial IO        PINHEAD-1X2          JP2                 
1   Iout+            PINHEAD-1X2          JP3                 

1   9V battery and clip
1   Jiffy case 80x55x30 mm
1   Shielded insulated cable for output-leads
2   Alligator clips
1   Knob for potentiometer
2   8 pin IC sockets

A downloadable bill of matterials is also available:

3. Prepare printed circuit board

The jfish PNS printed circuit board (PCB) is a double-sided PCB with one ‘via’ (through-connection). Because of this, construction requires plated-through holes in order for the circuit to function correctly.

Options for obtaining or making the jPNS PCB are:

  1. Download the Gerber files and submit these to an online PCB manufacturer. This is the simplest method, is relatively cheap and will result in a high quality board. Suitable PCB manufacturers are listed in the suppliers section.
  2. Along with the Gerber files, postscript and pdf files of the top and bottom PCB artwork are available, allowing a skilled hobbyist to etch the boards themselves. If you take this path, it is essential that you careful check the quality of the resultant board.
  3. The jfish project can supply pre-fabricated PCBs for use by those working in areas of need. Please contact the project for more information on this.

PCB manufacturing files included in the jfish-pns package:

  • Gerber files: .cmp .drd .plc .sol .stc .sts .whl
  • Top & bottom artwork postscript (.ps) and PDF (.pdf) files
  • Schematic (.sch) and board (.brd) files for Cadsoft’s free Eagle schematic capture and layout software.
  • Plain image file (.png) of PNS schematic.

4. Upload firmware to microcontroller

The current jPNS release version (v1.57) requires a PICAXE08 microcontroller. This is essentially just a Microchip PIC 12F629 with a custom, and closed-source, boot-loader written by Revolution Education in the UK.

The firmware code is written in PICAXE BASIC, documented on the PICAXE web-site. The syntax is simple and easy to understand, and is shown below. The latest code is also included in the downloadable PNS package.

The firmware is uploaded to the PICAXE microcontroller from a personal computer over a simple serial link. No other hardware is required for the upload. A free programming editor/IDE is available from Revolution Education’s site that is used to upload the firmware. Further documentation on the PICAXE site describes this process and links to other resources.

Once uploaded the firmware will run on the microcontroller indefinitely.

The use of non-free and non-open hardware and software obviously runs counter to the ideals of the project. Version 2 of the jPNS will move to using Atmel AVR microcontrollers with a completely free and open source development chain. A complete discussion of the reasons for using the PICAXE for version 1 can be found in the project FAQ.

The project can provide pre-flashed microcontrollers for use by those constructing a jPNS and working in areas of need. Please contact the project for more information on this.

The firmware can be downloaded as a text file:

'
' Transcutaneous Peripheral Nerve Stimulator
' firmware v1.22
'
' The jfish Project
'
' Copyright Daniel Jolley, 2004
'
' www.jfish.org
'
' PICAXE code for PICAXE08
'
' All code released under GPL (GNU General Public License)
' Not for commercial use
' All changes must be released under the same license
'
' For full license see: www.jfish.org
'
' pin 1 (leg 6) - analogue input: user switches via voltage divider
' pin 2 (leg 5) - digital output: piezo & LED
' pin 3 (leg 4) - not used (digital input only)
' pin 4 (leg 3) - digital output: transistor switch controlling HV stage
' pin 0 (leg 7) - digital output: high voltage current mirror patient output
 
 
' *Initialise variables*
'
init:
	' *Constants*
	symbol USER_SWITCH = 1		' pin assignment constants
	symbol LED_OUT = 2
	symbol HV_OUT = 4
	symbol CM_OUT = 0
	symbol PULSE_WIDTH = 12		' duration of twitch pulses in 10 us (ie '10' * 10 us = 0.1 ms = 100 us)						' (duration corrected to 120 us, to allow for 20 us of circuit delay)
	symbol FILLER_WIDTH = 88	' filler duration in 10 us to give accurate tetany (used for LED & piezo) 1 ms = 880 + 120 us
 
	' *Variables*
	symbol COUNTER = b0		' for-next counter to use byte b0
	symbol ANALOGUE_INPUT = b1	' assign ANALOGUE_INPUT to byte b1
	symbol CYCLES = b2		' assign CYCLES to byte b2
	symbol CYCLE_PAUSE = w6		' assign CYCLE_PAUSE to word w6
 
	low CM_OUT			' set output pins 0 & 2 to LOW (ie. off) as precaution
	low LED_OUT
 
 
' *Begin main loop*
' Check for switch closure and pass control to appropriate subroutine
'
Main:
	low HV_OUT				' turn off HV stage of circuit to conserve power
	readadc USER_SWITCH,ANALOGUE_INPUT	' read analogue input (pin 1) and thus user input
	IF ANALOGUE_INPUT >= 160 THEN Twitch	' branch to sub-routine depending on analogue value
	IF ANALOGUE_INPUT >= 139 THEN Tof
	IF ANALOGUE_INPUT >= 117 THEN Ptc
	IF ANALOGUE_INPUT >= 96 THEN Dbs
GOTO Main
 
 
' ******************
' ** Sub-routines **
' ******************
 
' *Double-burst stimulation*
' 3:3 DBS = 3 pulses at 50 Hz, 750 ms between start of first and start of further 3 pulses
Dbs:
	CYCLES = 3				' 3 on-off tetany cycles = 60 ms 50 Hz tetany
	CYCLE_PAUSE = 18			' use 18 ms pause (ie. 1 / (18 ms + 1 ms + 1 ms delay) = 50 Hz)
	GOSUB Pulses			' deliver pulses
	pause 190				' pause for further 690 ms (in total, as 500 + 190 = 690) following mini-tetany
	CYCLE_PAUSE = 18			' use 18 ms pause (ie. 1 / (18 ms + 1 ms + 1 ms delay) = 50 Hz)
	GOSUB Pulses			' deliver pulses
	pause 500				' pause for 0.5 s in-case button is held down
GOTO Main
 
 
' *Post-tetanic count*
' 5 s 50 Hz tetany, 3 second pause, then 1 Hz twitches
' 
Ptc:
	CYCLES = 250			' 250 on-off tetany cycles = 5 second 50 Hz tetany
	CYCLE_PAUSE = 18			' Use 18 ms pause (ie. 1 / (19 ms + 1 ms + 1 ms delay) = 50 Hz)
	GOSUB Pulses			' Deliver pulses
	pause 2500				' Pause for 3000 ms (3 s) total (ie. 500 + 2500 = 3000) following tetany
	CYCLES = 10				' Deliver 10 (ie. 0 to 9) post-tetany twitches
	CYCLE_PAUSE = 999			' Pause 1000 ms (999 ms + 1 ms) to deliver 1 Hz pulses
	GOSUB Pulses			' Deliver pulses
GOTO Main
 
 
' *Train of four*
' 4 pulses (twitches) at 2 Hz
'
Tof:
	CYCLES = 4				' Deliver 4 twitches
	CYCLE_PAUSE = 499			' Pause 499 ms (499 ms + 1 ms = 0.5 s = 2 Hz pulses)
	GOSUB Pulses			' Deliver pulses	
GOTO Main
 
 
' *Twitch*
' Single pulse for PULSE_WIDTH ms, to give single twitch
'
Twitch:
	CYCLES = 1				' Single twitch = 1 cycle
	CYCLE_PAUSE = 1000		' pause for 1 s to de-bounce switch
	GOSUB Pulses			' Deliver pulses to outputs				
GOTO Main
 
 
' *Pulses*
' Deliver pulse(s) at x Hz (determined by CYCLE_PAUSE) for CYCLES no. of on-off cycles
'
Pulses:
	high HV_OUT			' turn HV stage on
	pause 500			' pause 0.5 s to allow inductor to charge
	FOR COUNTER = 1 TO CYCLES		' deliver pulses for (CYCLE/50) seconds
		pulsout CM_OUT, PULSE_WIDTH	' deliver 'PULSE_WIDTH' ms pulse = twitch
		pulsout LED_OUT, FILLER_WIDTH	' deliver 'FILLER_WIDTH' ms pulse to LED/piezo
		pause CYCLE_PAUSE			' pause CYCLE_PAUSE ms
	NEXT COUNTER
RETURN

5. Assemble the circuit

Circuit assembly is relatively simple, and should not take much longer than one hour. As with any project, components should be inserted and soldered in order of increasing sensitivity to heat damage.

  • Place and solder in order: chip sockets (highly recommended to use, but not essential), resistors, capacitors, diodes and transistors. These are all mounted on the ‘top’ of the board. The top of the board is the side with the silk-screened layout.
  • Place and solder the LEDs and switches on the ‘bottom’ of the board. This will become the side that is mounted under the case panel.
  • Place and solder the potentiometer, jumper pins (three sets) and the on-off switch.
  • Place and solder the piezzo buzzer and finally the inductor.
  • Place the two 8 pin ICs in their sockets, being careful to double check for correct pin placement.
  • Finally, construct the output electrodes using shielded cable, two alligator clips and a pin-header plug. Similarly, solder a pin-header plug to the battery clip.

Before powering the device check for:

  • Leg polarity of all the polarised components, in particular: electrolytic capacitors, Zener and Schottky diodes, LEDs, transistors and the two chips. Double check these with a printed copy of the schematic.
  • Visually check your board for dry-solder joints and shorted tracks.

For tips on soldering and construction technique, review the list of web resources.

6. Test the device

Testing the jPNS comprises three parts:

  1. Multimeter testing of the functionality of specific parts of circuit.
  2. Testing of the user interface and correct pulse patterns.
  3. Oscilloscope testing of the output current pulses under a real-use load condition.

Multimeter circuit testing

  • 9V supply line
  • Regulated 5V supply
  • High voltage stage

User interface testing

  • Power on green LED lights
  • Low battery red LED lights
  • Pulse patterns are correctly user selectible
  • Pulse patterns

Oscilloscope output testing

  • Load testing

7. Package the device

After packaging the device should again be checked to insure that the correct pulse patterns are delivered and it continues to function normally.

8. Extending and improving the jPNS

The open design of the jPNS means extending, improving and remixing it is very easy. The PNS Development and Design Guide and the jPNS v1.57 Design Notes are a good place to start for a better understanding of how the device may be made to evolve. The developers’ mailing list is a further source of ideas and information.

It should be noted, that in the spirit of openness, all changes, updates or improvements made to jfish technology must be released back to the community for the benefit of all. The licenses describe your responsibilities in this regard.

jfish.org is powered by the excellent Dokuwiki. Hosting, server, OS and design credits.
This work is licensed under a Creative Commons License.

Creative Commons License