# picoVirtualWireV07.py tlfong01 2021oct25hkt1009 # Pico GP Pin Assignment # GP0 = UART0 TxD = FS1000S # GP1 = UART0 RxD = MX05V # Setup # 1. To loop back, short TxD pin to RxD pin # 2. To test Xmit/Recv, connect GP0 pin to FS1000S (Note 1), GP1 pin to MX05V # Note 1 # Pico 3V3 Gp0 direct connect to 5V FS1000S, might cause "latching up", and fry Pico. # Note 2 # Suggestions # 1. Use HCT125 or HC03 to shift 3V3 logical level to 5V. # 2. Use 12V to power FS1000S to increae xmit power and therefore effective distance from machine import UART, Pin import utime uart0 = UART(0, baudrate = 1200, tx=Pin(0), rx=Pin(1)) def testUartLoopBackV01(): print('Begin testUartLoopBackV01(), ...') testMsg = 'Hello World' print(' writeTestMsg =', testMsg) uart0.write(testMsg) # write 5 bytes utime.sleep(0.5) bytesRead = uart0.read(20) # read up to 5 bytes print(' bytes read =', bytesRead) print('End testUartLoopBackV01().') return def testUartLoopBackV02(): print('Begin testUartLoopBackV02(), ...') #testMsg = 'Hello World' testBytes = b'\0x5b\0xb5' print(' bytes written =', testBytes) uart0.write(testBytes) utime.sleep(0.5) bytesRead = uart0.read(20) # print(' bytes read =', bytesRead) print(' Begin repeat printing bytes =', testBytes) for count in range(100000): uart0.write(testBytes) utime.sleep(0.01) print(' End repeat printing bytes =', testBytes) print('End testUartLoopBackV02().') return def testPicoDirectDriveFs1000sV03(): print('Begin Pico TxD (GP0) direct drive FS1000S, ...') testBytes = b'\0x5b\0xb5' for count in range(100000): uart0.write(testBytes) utime.sleep(0.01) print('End Pico GP0 direct drive FS1000S.') return def testFs1000sMx05vV04(): print('Begin testFs1000sMx05vV04(), ...') testBytes = b'\0x5b\0xb5' print(' bytes written to GP0 (UART0 TxD), connected to FS1000S =', testBytes) uart0.write(testBytes) utime.sleep(0.5) bytesRead = uart0.read(20) print(' bytes read from GP1 (UART0 RxD), connected to MX05V =', bytesRead) print('End testFs1000sMx05vV04().') return # *** Main *** #testUartLoopBackV01() #testUartLoopBackV02() #testPicoDirectDriveFs1000sV03() testFs1000sMx05vV04() # .END ''' *** Sample output 2021oct25hkt1016 *** >>> %Run -c $EDITOR_CONTENT Begin testFs1000sMx05vV04(), ... bytes written to GP0 (UART0 TxD), connected to FS1000S = b'\x00x5b\x00xb5' bytes read from GP1 (UART0 RxD), connected to MX05V = b'\x00\xff\xb3~\x10\xdd' End testFs1000sMx05vV04(). >>> '''