Hi Allie,
The code you have from PhenixRising prints the counts to screen.
If you open a serial port on the picomite, you can send the same data to the CMM2.
This is the current main loop
'main loop
do
a$=inkey$ 'just for control
'get the data from the fifo and print
if sm0 then print str$(read_fifo(0),12,0); 'get data from decoder
if sm1 then print str$(read_fifo(1),12,0); 'get data from decoder
if sm2 then print str$(read_fifo(2),12,0); 'get data from decoder
if sm3 then print str$(read_fifo(3),12,0); 'get data from decoder
print
'just some pause
pause 100 'any delay needed
'reset position (PIO X register) under control of keyboard
if a$="r" then 'press r to zero position
if sm0 then pio execute 1,0,&hA023 '= assembly "mov X, null" (zero X reg)
if sm1 then pio execute 1,1,&hA023 '= assembly "mov X, null" (zero X reg)
if sm2 then pio execute 1,2,&hA023 '= assembly "mov X, null" (zero X reg)
if sm3 then pio execute 1,3,&hA023 '= assembly "mov X, null" (zero X reg)
a$=""
end if
loop while a$="" 'exit when any key not r
That would convert to
'serial comms to CMM2 using GP20 and GP21
SETPIN GP21,GP20,COM2
OPEN "COM2:112500" AS #1
'main loop
do
a$=inkey$ 'just for control
'get the data from the fifo and print
if sm0 then print #1,str$(read_fifo(0),12,0); 'get data from decoder
if sm1 then print #1,str$(read_fifo(1),12,0); 'get data from decoder
if sm2 then print #1,str$(read_fifo(2),12,0); 'get data from decoder
if sm3 then print #1,str$(read_fifo(3),12,0); 'get data from decoder
print
'just some pause
pause 100 'any delay needed
'reset position (PIO X register) under control of keyboard
if a$="r" then 'press r to zero position
if sm0 then pio execute 1,0,&hA023 '= assembly "mov X, null" (zero X reg)
if sm1 then pio execute 1,1,&hA023 '= assembly "mov X, null" (zero X reg)
if sm2 then pio execute 1,2,&hA023 '= assembly "mov X, null" (zero X reg)
if sm3 then pio execute 1,3,&hA023 '= assembly "mov X, null" (zero X reg)
a$=""
end if
loop while a$="" 'exit when any key not r
In this code you would still use the keyboard of the picomite (or console) to reset the counters. For full automation using the CMM2 you would replace the a$=inkey$ with a$=INPUT(#1,1) or similar.
And maybe you want to replace the
loop while a$=""
with
loop
To make sure the loop on the pico never stops.
Volhout
.
Edited 2025-05-23 22:16 by Volhout