Block Read Functions
    The Block Read functions are used for digitizing waveforms fed to the ADC inputs. The read_block() function brings the specified number of points from the channel selected by the last call to select_adc(). The existing setting of ADC data size also is used. The output is formatted in to a List of tuples having two elements in each tuple, time (microseconds) and voltage (milli volts).
   
There are 4 ADC channels. Before proceeding towards multi_read_block() , we need to select the channels to be digitized. This is done by add_channel(ch) and del_channel(ch) functions, channel number is from 0 to 3.
      It is possible to Synchronize the digitization with a Level Change on one of the Digital inputs or Analog Comparator Input. You can also Specify some Digital SET/CLEAR BIT actions to be performed just before the digitization starts. These setting are done by enable_set_high(bit), enable_set_low(bit), enable_raising_wait(bit), enable_falling_wait(bit) functions. The wait/set effects are cleared by disable_set() and disable_wait(calls). At the moment these Calls SET/CLEAR only one BIT.

None = add_channel(integer ch)
Adds the specified channel to the active channel list, to be used by multi_read_block().
# Add first and second channels
p.add_channel(0)
p.add_channel(1)

None = del_channel(integer ch)
Deletes the specified channel from the active channel list, to be used by multi_read_block().
# Remove all channels
for i in range(4)             # i  from 0 to 3
       p.del_channel(i)

None = enable_set_high(integer input_socket)
Makes the Sspecified Digital Output BIT HIGH just before digitization starts.
enable_set_low() is a similar function.
# Set D3 HIGH before digitizing
p.enable_set_high(3)

None = enable_wait_high(integer bit) , None = enable_wait_low(integer bit)
Start digitization only after detecting a HIGH / LOW on the specified BIT
# Start after seeing a HIGH on D3 input
p.enable_raising_wait(3)

[(float ts, float adval),....] = read_block (integer np, integer delay, integer bipolar)
Digitizes the selected ADC input
np: number of samples ( upto 800 bytes of data)
delay : gap between two samples(10 to 1000 usecs)
bipolar: Set to 1 if feeding through the (x+5)/5 amplifier
ts : time stamps
adval   : voltage in mv.
#200 points, 20 usec apart, using (x+5)/2 amplifier
result = p.read_block (200, 20, 1)
for k in range(256):
      print result[k][0], ' ', result[k][1]

[(float ts, float ad0, float  ad1, ..), ..] = multi_read_block (integer np, integer delay, integer bipolar)
Digitizes the ADC inputs (multiple channels)
np : number of digitizations.(maximum data 800 bytes)
delay    : interval between two digitizations(10 to 1000)
ts          : time stamp
This routine digitizes the active channels one by one. Due to the delay between samples, you will see a phase shift even if same wave is given to all inputs.
#digitize and print selected bipolar channels with timestamp
p.add_channel(0)
p.add_channel(1)
result = p.multi_read_block (200,10,1)
for val in result:
      print val[0], val[1], val[2]


Slow Multi Read Block (SMRB) calls
    The maximum delay between samples is 1000 micro seconds for the normal readblock calls. If you read 800 samples (limited by the microcontroller RAM size), the total time taken will be 800 milliseconds. Since the python function waits for the reply, blocking the program execution, it is not good to have a longer delay. If you want to digitize at slower speeds, use the SMRB calls instead. The SMRB calls initiate a read_block() and returns. Later the program can check the status and get the collected data. The actual data reading is one by the interrupt routines.
boolean = smrb_start (integer np, integer delay, integer bipolar)
Digitizes the ADC inputs (multiple channels)
np : number of digitizations.(maximum data 800 bytes)
delay    : interval between two digitizations(10 to 1000) milli seconds
ts          : time stamp
This routine digitizes the active channels one by one. Due to the delay between samples, you will see a phase shift even if same wave is given to all inputs.
#digitize selected inputs fed through (x+5)/2 amp
p.add_channel(0)
p.add_channel(1)
p.smrb_start(200,10,1)


boolean smrb_running()
Returns True if an SMRB read is in progress
while p.smrb_running() == True:   # wait loop
     pass

[(float ts, float ad0, float  ad1, ..), ..] = smrb_getdata()
Returns the SMRB data in a list of tuplets. Same format as MRB. Call this only after SMRB is over.
res = p.smrb_getdata()
for val in result:
      print val[0], val[1], val[2]

PROM Multi Read Block (PMRB) calls
    This one is used only with the EEPROM plug-in module to convert Phoenix into a multi-channel data recorder. The delay is specified in seconds. The data is saved into the EEPROM plug-in. The returned data is a List of two Lists, the second one contains channel information. Since PMRB stores actual time stamps set_time()  must be called before starting PMRB. The data returned is the Input voltage at the ADC input, ie from 0 to 5000 mV. No (x+5)/2 is assumed.
Making PMRB calls without plugin EEPROM will crash the C program.
boolean = pmrb_start (integer np, integer delay)
Digitizes the ADC inputs (multiple channels)
np : number of digitizations.(maximum data 800 bytes)
delay    : interval between two digitizations(10 to 1000) milli seconds
ts          : time stamp
This routine digitizes the active channels one by one. Due to the delay between samples, you will see a phase shift even if same wave is given to all inputs.
#digitize selected inputs fed through (x+5)/2 amp
p.add_channel(0)
p.add_channel(1)
p.set_time()
p.pmrb_start(200,10,1)


boolean smrb_running()
Returns True if an PMRB read is in progress
while p.pmrb_running() == True:   # wait loop
     pass

[ [(float ts, float ad0, float  ad1, ..), ..] [info] ]= smrb_getdata()
Returns a list containing two lists. PMRB and the info list containing
[npoints, delay, size, numchans, chmask, start_timestamp, end_timestamp]
data = p.pmrb_getdata()[0]
for item in data:
      for x in item:
          print x