Difference between revisions of "Emg 2009"

From DIDEAS Wiki
Jump to: navigation, search
m (serial numbers)
m (serial numbers)
Line 97: Line 97:
  
 
=serial numbers=
 
=serial numbers=
Serial numbers for the KKNEE1 (pic32 ver 1) PCA:
+
Serial numbers for the SPIEMG1 PCA:
  
 
*1 : hand build by CEB  100mA @ 15V
 
*1 : hand build by CEB  100mA @ 15V

Revision as of 18:48, 16 January 2011

Edit

PIC32 connections

The documentation in this section is only for the PCB: KKNEE1.pcb (04-15-2010)

About the PIC32 PCB

power

The primary power port is PJ1 (3 pins, 1.25mm space header). The pinout is "GND", "PWR", "GND". The voltage at PWR can vary between (~10V and 25.5V). The signal at this pin is distributed to many other connectors on the board (which may also serve as power inputs).

serial / programming

  • The Pic32 (v1) contains 5 total serial ports (of which 1 is SPI and 4 are UART).
    • The SPI port (PX1) and ISP port (PISP1) share serial signals; thus only one may be used.
  • The programming port is PISP1, is located on the bottom side, is 9 pin 1mm header, and is colored purple, black, red
    • For the EMG firmware this port no longer contains STDIO,
    • Connect to the Microchip programmer via a PSER (the programming cable pins 1,5,6,9 pass to the same pin, pins 7 and 8 should cross)
    • A special cable is used to interface the PSER programmer to the ISP port. Specifically the Tx signal must be cut.
  • STDIO is routed to PSW1 (EMG firmware ).
    • Serial port is 4x (460,800) baud, 8 data bits, 1 stop, no parity.
    • PSW1 does not provide 3.3V, thus the PSER2h can not be used with this port.
    • For PSER1, a cable that reverses pins 2 and 3 is required


  • SWIFI / dataport telemetry is routed to PSW2 (EMG firmware )
    • PSW2 does not provide 3.3V, thus the PSER2h can not be used with this port.
    • wifi_fast.py -p <port number> -V p32_emg -f xx
    • For PSER1, a cable that reverses pins 2 and 3 is required
    • For SWIFI, a straight cable is used, and connect to the MC port


  • In the future robots / motor controllers may be connected the connectors PMC(1/2) and PSC(1/2). This allows the Pic32 to receive data from the controller, and to send the motor commands.

PIC32 firmware

  • source code location [1]
  • Use the project p32_emg.mcp

LED status lights on P32

  • search code for "LED_INV", "LED_SET", "LED_CLR" for non #def uses of the LEDs
    • may wish to search for "LED_INV(0x"
#define LED_BACKGROUND_TGL   0x80   // orange
#define LED_MSG_VALID        0x40   // green2
#define LED_UART_EVENT       0x20   // red
#define LED_UART_QUEUE_EVENT 0x10   // blue
#define LED_TIC_TIMER        0x08
#define LED_MAIN_LOOP        0x04
#define LED_MSG_ERR          0x02
#define LED_CLUTCH           0x01   // white : used by the solinoid!
  • see the file io_led.h for the latest.

threads / tasks

The EMG firmware contains a background task (main loop), and interrupt based tasks at higher priority levels. The function "lib_task_add_callback()" is used to add a thread that will interrupt the main loop, but not each other. It operates at priority level 2. Its threads must operate cooperatively, which means that should not call delay functions or implment expensive algorithms. Generally they are coded as statemachines that implement "waits" changing state on some testable event. Anything that will take longer than ~1/2 the system loop interval (1mS) should be run from the main loop or a lower priority task.

Additional semi-non cooperative tasks may also be created. These would need to run at a level lower than the "lib_task" thread (2), but higher than the main loop (0).

main loop

The main loop for the EMG project is in the file "main_emg.c". As of present, there is mainly code to test / verify the systems operation. In general this file should not be modified by "users" as it will be modified by the developer.

user code

The file "emg_statemachine.c" is generally where the user should write their code.

The function "user_background()" is called from the main loop, and when there are free cycles. It may hog as many cycles as are available.

The function "user_statemachine()" is called from "user_system_statemachine()" which is called lib_task module at the system loop rate. It should return 'quickly'.


dataport (communicating with a computer and/or other microcontrollers)

How the dataport works

  • A "V3" dataport packet is implemented in the EMG firmware. Make sure that your "wifi_fast" supports this version.
  • The dataport data structure is defined in "dataport.h"
  • This structure needs to precisely match the data structure specified in the "vlist" file used on the command line with "wifi_fast.py"
  • The "printf" command "DB_PRINTF" is used to output text over the "dataport" link.
  • The dataport telemetry is sent with the function "do_dataport()". It should be called synchronously with the user state machine.
  • At present, a thread runs the function "user_system_statemachine()" at 500 hz. This function reads data from the EMG queue, stuffs the "USER_DATAPORT_OBJ" and then sends it with the do_dataport call.

issues

  • DP_PRINTF output is sometimes corrupted.
  • ISP UART and SPI are shared. Need to move ISP UART to different port.
  • this sharing also means that the MISO pin can be also driven by the ISP UART Tx signal. This appears to over drive the MISO signal - meaning that it is lost.

reading samples

The 24 bit ADC sequentially samples the n (upto 8) channels at upto ~20khz. When the conversion is complete, it is read via SPI and placed into a queue.

Samples can be read with:

ADS1258_DATA_T *ptr = ads1258_dequeue();
if (ptr) printf("%2.2x %2.2x %8.8x\n", ptr->status, ptr->channel, ptr->data);

filtering

The analog filter is a single pole LPF @ 800 hz, thus additional filtering may be required.

serial numbers

Serial numbers for the SPIEMG1 PCA:

  • 1 : hand build by CEB 100mA @ 15V
    • offset ~-200
    • Vcc 3.542e6
    • temp 1.046e6
    • gain 7.8589e6
    • ref 9.865e5
  • 2 : Ltronics 9-25-2010 50mA @ 15V
    • offset ~-1700
    • temp 1.032e6
    • gain 7.8672e6
    • ref 9.804e5


  • 3 : Ltronics 9-25-2010
    • Doesn't work. Verified has clock.
    • found 3 open pins on ADS1258. Fixed.

dsPIC firmware

dsPIC firmware development:

  • Use the workspace:

https://svn.media.mit.edu/r/biomech/trunk/prostheticsteam/code/cbarn/trunk/dspic_shared/hal_dev/hal_dev.mcw

  • and select the project:

https://svn.media.mit.edu/r/biomech/trunk/prostheticsteam/code/cbarn/trunk/dspic_shared/hal_dev/test_ads1258.mcp


spiemg1 SCH/PCB

  • 8 channel PRE-AMP style EMG amplifier with SPI interface
  • SCH [2]
  • SCH for 3.3V switcher : [3]
  • SCH for 5.4V switcher : [4]

assembly instructions

  • Start by assembling the 3.3V switching regulator and then testing it by verifying 3.3V at TP7. This module has reference designator in the 80s and physical reside in a tight location of the top side of the PCB.
  • To power the 3.3V switcher you'll need to apply ~5V to V.PROT from a ~100mA current limited supply. A successful test is the output of 3.3V, with nothing getting hot. To apply power, you may wish to install P1, F1, and D1 and use one of my power pole to 1.25mm adapters.
  • Next assemble the 5.4V switcher (refdes 90s) and test with ~7V. Verify ~5.4V at TP6.
  • Assemble the -5V switcher (UN1 and support components) and test with ~7V. Verify ~-5V at TP10
  • Assemble the +- 2.5V linear regulators (UA1, UA2, and support). Verify +-2.5V at TP8 and TP12.
  • Assemble the ADC voltage reference (UR1, UR2 and support). For UR2 use REF3312 in the kit. Verify at TP18 that you see -1.3V WRT to GND, or 1.2V WRT to the -2.5V.
  • At this point, it should be safe to assemble the primary IC US1 and the remainder of the PCB.


paconn1 SCH/PCB

  • 8 channel PRE-AMP connector PCA
  • SCH [9]
  • PCB TOP SIDE [10]
  • PCB BOT SIDE [11]
  • BOM [12]
  • BOM text [13]

known issues

  • silk screen for PACONN1 doesnt show connector orientation
  • V.FUSED net isn't driven on EMG
  • Pin 1 of the 2x10 connectors is on the right side.

previous

EMG09

future

  • Passive electrode amp: AD8228 PDF
  • Linear Tech LTC2053 : PDF
  • TI ADS1298 for bio amps : PDF