OPTION EXPLICIT OPTION VCC 3.322 'as measured with a DMM 'PICO #1 'set as required 'options to be set using the terminal 'this only needs to be done once 'OPTION POWER PWM 'OPTION CASE UPPER 'OPTION CPUSPEED 378000 'OPTION AUTORUN ON 'This program triggers an ADC conversion when it receives a 'pulse on the trigger input (GP14) 'Version 2a: try different ways to compress the data. Trying STR2BIN(UINT16.... ' note - the code below suits all the PICOs. Just comment out what's ' not required. Removed 'pulldown' on the trigger input. Set PICOs ' cpuspeed to 378MHz for reliable serial transfer 'Version 2: PICO0 does 2 jobs, it collects data for channels 0-3 and also ' collects data from the other PICOs and sends it all to the computer ' Just comment out or enable lines as described for the different PICOs 'Version 1a: single channel working, now try all 4 channels on a PICO mini 'version 1: basic operation, single channel, written by Peter Ihnat, 5/2024 'arrays to hold the ADC data DIM da0(1),da1(1),da2(1),da3(1) 'strings to hold the compressed data DIM dstring1$,dstring2$ 'make each data collecting PICO wait a different delay time before sending data 'so that the data being sent is sequential without any overlap 'simply enable the correct 'delaytime' line further down DIM delaytime 'how long to wait (ms) before sending data to serial port 'for PICO0 (ch 0-3), delay = 0 'for PICO1 (ch 4-7), delay = 0 'for PICO2 (ch 8-11), delay = 250us 'for PICO3 (ch 12-15), delay = 500us DIM i%,j,j1 'only used in the TESTing section at the end 'Setup I/O pins SETPIN GP14,INTL,getvalue SETPIN GP1,GP0,COM1 OPEN "COM1:460800" AS #5 ADC OPEN 125000,4 'for PICO0 and PICO1 (delay=0) comment out the PAUSE line in the interrupt routine 'for the other PICOs, uncomment one of the following lines & enable the PAUSE command 'delaytime = 0.25 'for PICO2 'delaytime = 0.5 'for PICO3 'i%=0 'uncomment for TESTing 'stay in the next loop, use the interrupt routine to do all the work DO LOOP 'INTERRUPT ROUTINE SUB getvalue ' dstring1$=input$(50,#5) 'clear buffer (for PICO0 only, comment out for others) ADC START da0(),da1(),da2(),da3() 'get data from the 4 ADCs dstring1$=BIN2STR$(UINT16,1000*da0(0))+BIN2STR$(UINT16,1000*da1(0))+BIN2STR$(UINT16,1000*da2(0))+BIN2STR$(UINT16,1000*da3(0)) PAUSE delaytime 'comment out for PICO0 & 1 'for PICO0 we need to wait to receive data from other PICOs 'Depending on how many PICOs used, in the LOOP line 'use 8 if only 1 extra PICO is used 'use 16 if 2 extra PICOs used or 'use 24 if all 3 PICOs are used 'comment out the next lines for PICOs 1-3 ' DO ' LOOP UNTIL LOC(#5)>=24 ' dstring2$=INPUT$(30,#5) ' PRINT dstring2$ 'for TESTing 'ready to send data to computer or PICO0. Comment out one of the PRINT lines 'this line is for PICOs 1-3 to send data to PICO0 PRINT #5,dstring1$; 'this line is for PICO0 to send all data to computer ' PRINT dstring1$;dstring2$; 'for TESTing 'check PICO0 data ' PRINT STR2BIN(UINT16,MID$(dstring1$,1,2)); ' PRINT STR2BIN(UINT16,MID$(dstring1$,3,2)); ' PRINT STR2BIN(UINT16,MID$(dstring1$,5,2)); ' PRINT STR2BIN(UINT16,MID$(dstring1$,7,2)) 'check PICO1 data ' PRINT STR2BIN(UINT16,MID$(dstring2$,1,2)); ' PRINT STR2BIN(UINT16,MID$(dstring2$,3,2)); ' PRINT STR2BIN(UINT16,MID$(dstring2$,5,2)); ' PRINT STR2BIN(UINT16,MID$(dstring2$,7,2)) 'check PICO2 data ' PRINT STR2BIN(UINT16,MID$(dstring2$,9,2)); ' PRINT STR2BIN(UINT16,MID$(dstring2$,11,2)); ' PRINT STR2BIN(UINT16,MID$(dstring2$,13,2)); ' PRINT STR2BIN(UINT16,MID$(dstring2$,15,2)) 'check PICO3 data ' PRINT STR2BIN(UINT16,MID$(dstring2$,17,2)); ' PRINT STR2BIN(UINT16,MID$(dstring2$,19,2)); ' PRINT STR2BIN(UINT16,MID$(dstring2$,21,2)); ' PRINT STR2BIN(UINT16,MID$(dstring2$,23,2)) ' PRINT END SUB 'the next few lines are just for TESTing. If used, comment out the previous END SUB line IF i% MOD 1000 = 0 THEN j=TIMER PRINT j-j1;" "; j1=j ENDIF i%=i%+1 END SUB