Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : Is PicoMite serial idle hight or low?
Author | Message | ||||
Gizmo Admin Group Joined: 05/06/2004 Location: AustraliaPosts: 5078 |
Silly question but I'm confused. Connected a simpleRTK2B GPS module to a PicoMite. Both set at 38400bd, I can see data with my cro, but PicoMite not getting anything. I noticed the data stream from the simpleRTK2B is high ( 3.3v ) at idle, and pulses low with data. I suspect the PicoMite is expecting the opposite, but wanted to confirm before I start modifying the circuit board. Glenn The best time to plant a tree was twenty years ago, the second best time is right now. JAQ |
||||
phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 2135 |
Yes, idle high is correct for TTL serial. And that is how the PicoMite works too. To check that the GPS output is correct feed it to a USB to serial TTL converter and see if a terminal program on the PC can make sense of the output. Going the other way use the USB to serial TTL converter to see if the PicoMite is receiving correctly. |
||||
VK2CBH Newbie Joined: 18/08/2014 Location: AustraliaPosts: 11 |
Glenn When you open up the serial port via the open command you and use an option of INV. See appendix A of the manual. Cheers Brett |
||||
Gizmo Admin Group Joined: 05/06/2004 Location: AustraliaPosts: 5078 |
Ok, added a USB-Serial adapter, set for 3.3v, wired the adapter Tx to pin 17 ( GP13 ) of the PiPico. Opened a terminal to the adapters com port, I type letters, can see the Tx led flashing, and see the data going into pin 17 on the PiPico. The following program shows no data coming in setpin 17, 16, COM1 open "COM1:38400" AS #1 do P$=input$(20,#1) print "<";P$;">" pause(500) loop The only thing I can think og is I did the OPTION SYSTEM I2C 1,2 to set up pins 1 & 2 for a I2C device, these can also be used for COM1, could that be it? Glenn Edited 2024-05-05 13:46 by Gizmo The best time to plant a tree was twenty years ago, the second best time is right now. JAQ |
||||
Gizmo Admin Group Joined: 05/06/2004 Location: AustraliaPosts: 5078 |
ok, sent a "option system I2C disable" ( couldnt find it in the manual but there was a disable option for SPI so I gave it a go. ) I can now receive serial data on pin 17. Next I'll see if it reads GPS data. Another weird thing I discovered, this configuration below causes the Pi Pico to drop the USB ( maybe lock up or reboot ).... Now thats a serial to USB adapter, not plugged into anything. It's Tx line was connected to pin 17 of the Pi Pico, and the earths connected. Thats it, no other wires. After I did the "option system I2C disable", it's fine Glenn The best time to plant a tree was twenty years ago, the second best time is right now. JAQ |
||||
phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 2135 |
That may be one for Peter to look into. I would not expect System I2C on 1 and 2 to affect Serial on 16 & 17. If your GPS module is configured for standard output then Close #1 and re-open with:- OPEN comspec$ AS GPS ,10 ,monitor '10 = EAST time-zone offset That will send the data stream straight to the terminal. If that looks good close and re-open without monitor and the built-in parsing should work. |
||||
Gizmo Admin Group Joined: 05/06/2004 Location: AustraliaPosts: 5078 |
Yipee, the GPS functions are working as well. I do need the I2C for a compass, so I'll play around and see what I can do with these pins. There may be some combinations that just dont work. Glenn The best time to plant a tree was twenty years ago, the second best time is right now. JAQ |
||||
phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 2135 |
I configured the same pins using GP numbers instead of Pin numbers and it seems to work. OPTION SYSTEM I2C GP0,GP1 > SETPIN gp13, gp12, COM1 > open "com1:9600" as gps > ? gps(latitude) -37.509493 > ? gps(altitude) 583.2 > Perhaps the firmware isn't converting Pin numbers to GP numbers correctly for those pins. |
||||
Gizmo Admin Group Joined: 05/06/2004 Location: AustraliaPosts: 5078 |
OK, here are my findings. If I issue a "OPTION SYSTEM I2C 1,2", my serial ports wont read data. If however is set up the I2C in code, its ok. But if I've previously issued a "OPTION SYSTEM I2C 1,2",I need to do a "OPTION STSTEM I2C DISABLE" and a reboot to get it working again. This code is now working. Its using 1,2 for the I2C compass, 17 for the GPS data, and a distance ultrasonic module on 24,25 'initiate I2C SetPin 1,2,I2C I2C OPEN 100, 1000 'initiate Serial 1 for RTK GPS input SetPin 17, 16, COM1 'Initiage compass I2C WRITE &H1E, 0,2,&H02, &H00 Dim MagData(6) Open "COM1:38400" As GPS Do I2C WRITE &H1E,0,1,&H03 I2C READ &H1E, 0, 6, MagData() X=(MagData(0)*256)+MagData(1) Y=(MagData(2)*256)+MagData(3) Z=(MagData(4)*256)+MagData(5) If X>32768 Then X=X-65536 If Y>32768 Then Y=Y-65536 If Z>32768 Then Z=Z-65536 ' Added the +190 And +127 to calibrate the sensor for my location CompassInRad = Atan2(Z+190, X+127) + DeclinationAngle CompassInDeg=Int(CompassInRad * 180/Pi) Print "[<COM>";CompassInDeg;"</COM>]" D=Distance(24,25) Print "[<DIS>";D;"</DIS>]" Print "GPS=";GPS(VALID) Print GPS(LATITUDE) Print GPS(LONGITUDE) Print GPS(DOP) Pause (500) Loop But if I issue a OPTION SYSTEM I2C 1,2, and modifiy the code like this... SetPin 17, 16, COM1 'Initiage compass I2C WRITE &H1E, 0,2,&H02, &H00 Dim MagData(6) Open "COM1:38400" As GPS Do I2C WRITE &H1E,0,1,&H03 I2C READ &H1E, 0, 6, MagData() X=(MagData(0)*256)+MagData(1) Y=(MagData(2)*256)+MagData(3) Z=(MagData(4)*256)+MagData(5) If X>32768 Then X=X-65536 If Y>32768 Then Y=Y-65536 If Z>32768 Then Z=Z-65536 ' Added the +190 And +127 to calibrate the sensor for my location CompassInRad = Atan2(Z+190, X+127) + DeclinationAngle CompassInDeg=Int(CompassInRad * 180/Pi) Print "[<COM>";CompassInDeg;"</COM>]" D=Distance(24,25) Print "[<DIS>";D;"</DIS>]" Print "GPS=";GPS(VALID) Print GPS(LATITUDE) Print GPS(LONGITUDE) Print GPS(DOP) Pause (500) Loop ( Just removed the 2 lines to set up the I2C ) It doesnt receive serial data on 17. Hope thats helps. Glenn The best time to plant a tree was twenty years ago, the second best time is right now. JAQ |
||||
phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 2135 |
While you were composing that I posted my experiment above. |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6783 |
I would strongly recommend that you avoid using pin numbers wherever possible, Glenn. They tie your program to one particular hardware platform. If you use the GPx format your program becomes much more portable as this format is native to the RP2040 chip itself rather than to the module it's mounted on. OPTION SYSTEM I2C GP0, GP1 'puts GP0 on I2C SDA and GP1 on I2C SCL SETPIN GP5, GP4, COM2 'allocates COM2 RX to GP5 and COM2 TX to GP4 should work ok. That gives you I2C on pins 1 & 2 and COM2 on pins 6 and 7 You will almost certainly ned pullup resistors to 3V3 from SDA and SCL unless they are provided in your module. You may even need a pullup on COM2 RX to reduce noise. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
Print this page |